Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Oct 8, 2023
1 parent a44d2d2 commit c6711bf
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/test/01-Basic/204-op-overload-foo.ck
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ fun Foo @operator +( Foo lhs, Foo rhs )
fun Foo @operator *( Foo lhs, Foo rhs )
{ Foo retval; lhs.num * rhs.num => retval.num; return retval; }

// NOTE % can be overloaded, but due to polar e.g., `%(1,pi)`
// need to use the formal parenthesis notation to disambiguate
fun int @operator(%)( Foo foo, int mod )
{ mod %=> foo.num; return foo.num; }

// define unary operator overload for '!'
fun int @operator !( Foo foo )
{ return !foo.num; }
Expand All @@ -38,5 +43,5 @@ Foo a, b; 1 => a.num; 2 => b.num;
a + b * b + a @=> Foo c;
// post ++ on c
c++;
// should print 7
<<< c.num >>>;
// should print 3
<<< c % 4 >>>;
2 changes: 1 addition & 1 deletion src/test/01-Basic/204-op-overload-foo.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7 :(int)
3 :(int)
31 changes: 31 additions & 0 deletions src/test/01-Basic/211-mfun-invoke-vars.ck
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// verify a system-invoked member function can properly access
// variables at different relative scopes

// event
EventFoo e;

// file-scope
1 => int fileVar;
// global
2 => global float globalVar;

// class def
class EventFoo extends Event
{
// member variable
3 => int memberVar;
// static variable
4 => static int staticVar;

// VM calls this special function when a shred waits on events
fun void waiting_on()
{
// print different scopes
<<< fileVar, globalVar, memberVar, staticVar >>>;
// this should reactivate the shred
this.broadcast();
}
}

// wait to trigger the waiting_on()
e => now;
1 change: 1 addition & 0 deletions src/test/01-Basic/211-mfun-invoke-vars.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 2.000000 3 4
File renamed without changes.
File renamed without changes.

0 comments on commit c6711bf

Please sign in to comment.