diff options
author | alon@honor <none@none> | 2010-09-14 20:10:32 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-09-14 20:10:32 -0700 |
commit | 0dd0f40a7a2c2fdf5e8344d492b3575fab8268a6 (patch) | |
tree | d44f340caa56c9533483dacc72daf66b338c5f5b /tests | |
parent | a8d7622f69054a6970906b2512f3107ea1e29c58 (diff) |
proper flattening of nested structures +test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/runner.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 5398327a..20849681 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -670,6 +670,55 @@ class T(unittest.TestCase): ''' self.do_test(src, '*staticccz*') + def test_nestedstructs(self): + src = ''' + #include <stdio.h> + #include "emscripten.h" + + struct base { + int x; + float y; + union { + int a; + float b; + }; + char c; + }; + + struct hashtableentry { + int key; + base data; + }; + + struct hashset { + typedef hashtableentry entry; + struct chain { entry elem; chain *next; }; + // struct chainchunk { chain chains[100]; chainchunk *next; }; + }; + + struct hashtable : hashset { + hashtable() { + base *b = NULL; + entry *e = NULL; + chain *c = NULL; + printf("*%d,%d,%d,%d,%d,%d|%d,%d,%d,%d,%d,%d,%d,%d|%d,%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n", + ES_SIZEOF(base), + int(&(b->x)), int(&(b->y)), int(&(b->a)), int(&(b->b)), int(&(b->c)), + ES_SIZEOF(hashtableentry), + int(&(e->key)), int(&(e->data)), int(&(e->data.x)), int(&(e->data.y)), int(&(e->data.a)), int(&(e->data.b)), int(&(e->data.c)), + ES_SIZEOF(hashset::chain), + int(&(c->elem)), int(&(c->next)), int(&(c->elem.key)), int(&(c->elem.data)), int(&(c->elem.data.x)), int(&(c->elem.data.y)), int(&(c->elem.data.a)), int(&(c->elem.data.b)), int(&(c->elem.data.c)) + ); + } + }; + + int main() { + hashtable t; + return 0; + } + ''' + self.do_test(src, '*4,0,1,2,2,3|5,0,1,1,2,3,3,4|6,0,5,0,1,1,2,3,3,4*') + def test_fannkuch(self): results = [ (1,0), (2,1), (3,2), (4,4), (5,7), (6,10), (7, 16), (8,22) ] for i, j in results: |