aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 17:12:54 +0200
committerVasilis Kalintiris <ehostunreach@gmail.com>2013-12-07 19:36:02 +0200
commita5f8823964c30222ba9cddc370a814ba9c4528f3 (patch)
tree1aff5b7c90e07a7a28f853c64caa8a610ee59e31 /tests
parent4dbb76786ee2d914c13ced432b7ede74a3799433 (diff)
Use do_run_from_file() for test_static_variable
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_static_variable.in26
-rw-r--r--tests/core/test_static_variable.out1
-rw-r--r--tests/test_core.py28
3 files changed, 30 insertions, 25 deletions
diff --git a/tests/core/test_static_variable.in b/tests/core/test_static_variable.in
new file mode 100644
index 00000000..82fcadac
--- /dev/null
+++ b/tests/core/test_static_variable.in
@@ -0,0 +1,26 @@
+
+ #include <stdio.h>
+
+ struct DATA
+ {
+ int value;
+
+ DATA()
+ {
+ value = 0;
+ }
+ };
+
+ DATA & GetData()
+ {
+ static DATA data;
+
+ return data;
+ }
+
+ int main()
+ {
+ GetData().value = 10;
+ printf( "value:%i", GetData().value );
+ }
+ \ No newline at end of file
diff --git a/tests/core/test_static_variable.out b/tests/core/test_static_variable.out
new file mode 100644
index 00000000..8ab80f3b
--- /dev/null
+++ b/tests/core/test_static_variable.out
@@ -0,0 +1 @@
+value:10 \ No newline at end of file
diff --git a/tests/test_core.py b/tests/test_core.py
index 4f3d9cb5..6349d47c 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -4469,33 +4469,11 @@ return malloc(size);
def test_static_variable(self):
if self.emcc_args is None: Settings.SAFE_HEAP = 0 # LLVM mixes i64 and i8 in the guard check
- src = '''
- #include <stdio.h>
-
- struct DATA
- {
- int value;
-
- DATA()
- {
- value = 0;
- }
- };
- DATA & GetData()
- {
- static DATA data;
-
- return data;
- }
+ test_path = path_from_root('tests', 'core', 'test_static_variable')
+ src, output = (test_path + s for s in ('.in', '.out'))
- int main()
- {
- GetData().value = 10;
- printf( "value:%i", GetData().value );
- }
- '''
- self.do_run(src, 'value:10')
+ self.do_run_from_file(src, output)
def test_fakestat(self):
src = r'''