- Timestamp:
- Mar 21, 2017, 10:07:52 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- cb91437
- Parents:
- 829c907 (diff), a53e10a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/tests
- Files:
-
- 9 edited
-
avltree/avl.h (modified) (1 diff)
-
avltree/avl1.c (modified) (1 diff)
-
avltree/avl_test.c (modified) (2 diffs)
-
completeTypeError.c (modified) (1 diff)
-
coroutine.c (modified) (3 diffs)
-
dtor-early-exit.c (modified) (1 diff)
-
monitor.c (modified) (1 diff)
-
multi-monitor.c (modified) (2 diffs)
-
thread.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/avltree/avl.h
r829c907 r87d13cd 61 61 void ?{}(tree(K, V) *t, K key, V value); 62 62 63 forall(otype K | Comparable(K), otype V)63 forall(otype K, otype V) 64 64 void ^?{}(tree(K, V) * t); 65 65 -
src/tests/avltree/avl1.c
r829c907 r87d13cd 12 12 } 13 13 14 forall(otype K | Comparable(K), otype V)14 forall(otype K, otype V) 15 15 void ^?{}(tree(K, V) * t){ 16 16 delete(t->left); -
src/tests/avltree/avl_test.c
r829c907 r87d13cd 25 25 26 26 // int -> char * 27 tree(int, c har *) * smap = create(-1, "baz");27 tree(int, const char *) * smap = create(-1, "baz"); 28 28 insert(&smap, 12, "bar"); 29 29 insert(&smap, 2, "foo"); … … 35 35 delete(smap); 36 36 37 // char* -> char* 38 struct c_str { char *str; }; // wraps a C string 39 int ?<?(c_str a, c_str b) { 40 return strcmp(a.str,b.str) < 0; 37 // const char* -> const char* 38 int ?<?(const char * a, const char * b) { 39 return strcmp(a, b) < 0; 41 40 } 42 tree(c_str, char *) * ssmap = create((c_str){"queso"}, "cheese"); 43 insert(&ssmap, (c_str){"foo"}, "bar"); 44 insert(&ssmap, (c_str){"hello"}, "world"); 41 42 tree(const char *, const char *) * ssmap = create("queso", "cheese"); 43 insert(&ssmap, "foo", "bar"); 44 insert(&ssmap, "hello", "world"); 45 45 assert( height(ssmap) == 2 ); 46 46 47 printf("%s %s %s\n", *find(ssmap, (c_str){"hello"}), *find(ssmap, (c_str){"foo"}), *find(ssmap, (c_str){"queso"}));47 printf("%s %s %s\n", *find(ssmap, "hello"), *find(ssmap, "foo"), *find(ssmap, "queso")); 48 48 49 remove(&ssmap, (c_str){"foo"});49 remove(&ssmap, "foo"); 50 50 delete(ssmap); 51 51 } -
src/tests/completeTypeError.c
r829c907 r87d13cd 62 62 63 63 forall(dtype T | sized(T)) 64 void qu x(T * z) {64 void quux(T * z) { 65 65 // okay 66 66 bar(z); -
src/tests/coroutine.c
r829c907 r87d13cd 2 2 #include <coroutine> 3 3 4 structFibonacci {4 coroutine Fibonacci { 5 5 int fn; // used for communication 6 coroutine_desc c;7 6 }; 8 7 … … 11 10 } 12 11 13 coroutine_desc* get_coroutine(Fibonacci* this) {14 return &this->c;15 }16 17 12 void main(Fibonacci* this) { 18 #ifdef MORE_DEBUG19 sout | "Starting main of coroutine " | this | endl;20 sout | "Started from " | this->c.last | endl;21 #endif22 13 int fn1, fn2; // retained between resumes 23 14 this->fn = 0; … … 45 36 int main() { 46 37 Fibonacci f1, f2; 47 #ifdef MORE_DEBUG48 Fibonacci *pf1 = &f1, *pf2 = &f2;49 coroutine_desc *cf1 = &f1.c, *cf2 = &f2.c;50 covptr_t *vf1 = vtable(pf1), *vf2 = vtable(pf2);51 coroutine_desc *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);52 Fibonacci *ov1 = (Fibonacci *)get_object(vf1), *ov2 = (Fibonacci *)get_object(vf2);53 54 sout | "User coroutines : " | pf1 | ' ' | pf2 | endl;55 sout | "Coroutine data : " | cf1 | ' ' | cf2 | endl;56 sout | "Vptr address : " | vf1 | ' ' | vf2 | endl;57 sout | "Vptr obj data : " | ov1 | ' ' | ov2 | endl;58 sout | "Vptr cor data : " | cv1 | ' ' | cv2 | endl;59 #endif60 38 for ( int i = 1; i <= 10; i += 1 ) { 61 39 sout | next(&f1) | ' ' | next(&f2) | endl; -
src/tests/dtor-early-exit.c
r829c907 r87d13cd 28 28 // don't want these called 29 29 void ?{}(A * a) { assert( false ); } 30 void ?{}(A * a, c har * name) { a->name = name; sout | "construct " | name | endl; a->x = (int*)malloc(); }31 void ?{}(A * a, c har * name, int * ptr) { assert( false ); }30 void ?{}(A * a, const char * name) { a->name = name; sout | "construct " | name | endl; a->x = (int*)malloc(); } 31 void ?{}(A * a, const char * name, int * ptr) { assert( false ); } 32 32 33 33 A ?=?(A * a, A a) { sout | "assign " | a->name | " " | a.name; return a; } -
src/tests/monitor.c
r829c907 r87d13cd 13 13 } 14 14 15 monitor_desc * get_monitor( global_t * this ) { 16 return &this->m; 17 } 18 15 19 static global_t global; 16 20 17 void increment( /*mutex*/ global_t * this ) { 18 monitor_desc * mon = &this->m; 19 monitor_guard_t g1 = { &mon }; 20 { 21 monitor_guard_t g2 = { &mon }; 22 { 23 monitor_guard_t g3 = { &mon }; 24 this->value += 1; 25 } 26 } 21 void increment3( global_t * mutex this ) { 22 this->value += 1; 27 23 } 28 24 29 struct MyThread { thread_desc t; }; 25 void increment2( global_t * mutex this ) { 26 increment3( this ); 27 } 28 29 void increment( global_t * mutex this ) { 30 increment2( this ); 31 } 32 33 struct MyThread { thread_desc __thrd; }; 30 34 31 35 DECL_THREAD(MyThread); 32 36 33 37 void ?{}( MyThread * this ) {} 38 void ^?{}( MyThread * mutex this ) {} 34 39 35 40 void main( MyThread* this ) { 36 for(int i = 0; i < 1 000000; i++) {41 for(int i = 0; i < 1_000_000; i++) { 37 42 increment( &global ); 38 43 } -
src/tests/multi-monitor.c
r829c907 r87d13cd 6 6 static int global12, global23, global13; 7 7 8 static monitor_desc m1, m2, m3; 8 struct monitor_t { 9 monitor_desc m; 10 }; 9 11 10 void increment( /*mutex*/ monitor_desc * p1, /*mutex*/ monitor_desc * p2, int * value ) { 11 monitor_desc * mons[] = { p1, p2 }; 12 monitor_guard_t g = { mons, 2 }; 12 monitor_desc * get_monitor( monitor_t * this ) { 13 return &this->m; 14 } 15 16 static monitor_t m1, m2, m3; 17 18 void increment( monitor_t * mutex p1, monitor_t * mutex p2, int * value ) { 13 19 *value += 1; 14 20 } 15 21 16 22 struct MyThread { 17 thread_desc t;23 thread_desc __thrd; 18 24 int target; 19 25 }; … … 24 30 this->target = target; 25 31 } 32 33 void ^?{}( MyThread * mutex this ) {} 26 34 27 35 void main( MyThread* this ) { -
src/tests/thread.c
r829c907 r87d13cd 4 4 #include <thread> 5 5 6 struct First { thread_desc t; signal_once* lock; };7 struct Second { thread_desc t; signal_once* lock; };6 struct First { thread_desc __thrd; signal_once* lock; }; 7 struct Second { thread_desc __thrd; signal_once* lock; }; 8 8 9 9 DECL_THREAD(First); … … 12 12 void ?{}( First * this, signal_once* lock ) { this->lock = lock; } 13 13 void ?{}( Second * this, signal_once* lock ) { this->lock = lock; } 14 15 void ^?{}( First * mutex this ) {} 16 void ^?{}( Second * mutex this ) {} 14 17 15 18 void main(First* this) {
Note:
See TracChangeset
for help on using the changeset viewer.