diff options
-rw-r--r-- | tests/core/test_statics.in | 39 | ||||
-rw-r--r-- | tests/core/test_statics.out | 2 | ||||
-rw-r--r-- | tests/test_core.py | 42 |
3 files changed, 44 insertions, 39 deletions
diff --git a/tests/core/test_statics.in b/tests/core/test_statics.in new file mode 100644 index 00000000..0935aade --- /dev/null +++ b/tests/core/test_statics.in @@ -0,0 +1,39 @@ + + #include <stdio.h> + #include <string.h> + + #define CONSTRLEN 32 + + char * (*func)(char *, const char *) = NULL; + + void conoutfv(const char *fmt) + { + static char buf[CONSTRLEN]; + func(buf, fmt); // call by function pointer to make sure we test strcpy here + puts(buf); + } + + struct XYZ { + float x, y, z; + XYZ(float a, float b, float c) : x(a), y(b), z(c) { } + static const XYZ& getIdentity() + { + static XYZ iT(1,2,3); + return iT; + } + }; + struct S { + static const XYZ& getIdentity() + { + static const XYZ iT(XYZ::getIdentity()); + return iT; + } + }; + + int main() { + func = &strcpy; + conoutfv("*staticccz*"); + printf("*%.2f,%.2f,%.2f*\n", S::getIdentity().x, S::getIdentity().y, S::getIdentity().z); + return 0; + } +
\ No newline at end of file diff --git a/tests/core/test_statics.out b/tests/core/test_statics.out new file mode 100644 index 00000000..c34f2cb6 --- /dev/null +++ b/tests/core/test_statics.out @@ -0,0 +1,2 @@ +*staticccz* +*1.00,2.00,3.00*
\ No newline at end of file diff --git a/tests/test_core.py b/tests/test_core.py index a69764eb..f1fbae7a 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2507,46 +2507,10 @@ The current type of b is: 9 Settings.SAFE_HEAP = 3 Settings.SAFE_HEAP_LINES = ['src.cpp:19', 'src.cpp:26', 'src.cpp:28'] - src = ''' - #include <stdio.h> - #include <string.h> - - #define CONSTRLEN 32 - - char * (*func)(char *, const char *) = NULL; - - void conoutfv(const char *fmt) - { - static char buf[CONSTRLEN]; - func(buf, fmt); // call by function pointer to make sure we test strcpy here - puts(buf); - } - - struct XYZ { - float x, y, z; - XYZ(float a, float b, float c) : x(a), y(b), z(c) { } - static const XYZ& getIdentity() - { - static XYZ iT(1,2,3); - return iT; - } - }; - struct S { - static const XYZ& getIdentity() - { - static const XYZ iT(XYZ::getIdentity()); - return iT; - } - }; + test_path = path_from_root('tests', 'core', 'test_statics') + src, output = (test_path + s for s in ('.in', '.out')) - int main() { - func = &strcpy; - conoutfv("*staticccz*"); - printf("*%.2f,%.2f,%.2f*\\n", S::getIdentity().x, S::getIdentity().y, S::getIdentity().z); - return 0; - } - ''' - self.do_run(src, '*staticccz*\n*1.00,2.00,3.00*') + self.do_run_from_file(src, output) def test_copyop(self): if self.emcc_args is None: return self.skip('requires emcc') |