aboutsummaryrefslogtreecommitdiff
path: root/tests/test_other.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-06-11 13:59:24 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-06-11 13:59:24 -0700
commitd344eda057c3455a3900a31df48a8aac30473382 (patch)
tree61a053557963e1f63145a4d905ff06a27c3d42d2 /tests/test_other.py
parentd2768d2eee9075c3d0c5f4222f463b6bca2b9194 (diff)
add test for d2768d2ee
Diffstat (limited to 'tests/test_other.py')
-rw-r--r--tests/test_other.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_other.py b/tests/test_other.py
index 6e04ead5..14c3f00b 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -2869,4 +2869,26 @@ int main(int argc, char **argv) {
assert 'eval.' not in src
assert 'new Function' not in src
+ def test_init_file_at_offset(self):
+ open('src.cpp', 'w').write(r'''
+ #include <stdio.h>
+ int main() {
+ int data = 0x12345678;
+ FILE *f = fopen("test.dat", "wb");
+ fseek(f, 100, SEEK_CUR);
+ fwrite(&data, 4, 1, f);
+ fclose(f);
+
+ int data2;
+ f = fopen("test.dat", "rb");
+ fread(&data2, 4, 1, f); // should read 0s, not that int we wrote at an offset
+ printf("read: %d\n", data2);
+ fseek(f, 0, SEEK_END);
+ int size = ftell(f); // should be 104, not 4
+ fclose(f);
+ printf("file size is %d\n", size);
+ }
+ ''')
+ Popen([PYTHON, EMCC, 'src.cpp']).communicate()
+ self.assertContained('read: 0\nfile size is 104\n', run_js('a.out.js'))