aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-05-21 14:21:52 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-05-21 14:21:52 -0700
commit62b07e91298336aefb3380f7e707d4f46865797d (patch)
treefdf4914ada2c142a0109010519c1d9cd827c2123 /tests
parent7a0ae20872841e0f3a242fba33cb18e65b95b14e (diff)
parent179dfed363127088299179f252b88e8abc3ff3be (diff)
Merge branch 'incoming' of github.com:hyperlogic/emscripten into incoming
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runner.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py
index afb71ad9..37fb2bbb 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6363,6 +6363,31 @@ def process(filename):
self.emcc_args += ['--embed-file', 'eol.txt']
self.do_run(src, 'SUCCESS\n')
+ def test_fscanf(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+ open(os.path.join(self.get_dir(), 'three_numbers.txt'), 'w').write('''-1 0.1 -.1''')
+ src = r'''
+ #include <stdio.h>
+ #include <assert.h>
+ #include <float.h>
+ int main()
+ {
+ float x = FLT_MAX, y = FLT_MAX, z = FLT_MAX;
+
+ FILE* fp = fopen("three_numbers.txt", "r");
+ if (fp) {
+ int match = fscanf(fp, " %f %f %f ", &x, &y, &z);
+ printf("match = %d\n", match);
+ printf("x = %0.1f, y = %0.1f, z = %0.1f\n", x, y, z);
+ } else {
+ printf("failed to open three_numbers.txt\n");
+ }
+ return 0;
+ }
+ '''
+ self.emcc_args += ['--embed-file', 'three_numbers.txt']
+ self.do_run(src, 'match = 3\nx = -1.0, y = 0.1, z = -0.1\n')
+
def test_folders(self):
add_pre_run = '''
def process(filename):