diff --git a/src/test/01-Basic/204-op-overload-foo.ck b/src/test/01-Basic/204-op-overload-foo.ck index 1a8b95000..afe4d45c9 100644 --- a/src/test/01-Basic/204-op-overload-foo.ck +++ b/src/test/01-Basic/204-op-overload-foo.ck @@ -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; } @@ -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 >>>; diff --git a/src/test/01-Basic/204-op-overload-foo.txt b/src/test/01-Basic/204-op-overload-foo.txt index 5ca66e98f..570bcaddd 100644 --- a/src/test/01-Basic/204-op-overload-foo.txt +++ b/src/test/01-Basic/204-op-overload-foo.txt @@ -1 +1 @@ -7 :(int) +3 :(int) diff --git a/src/test/01-Basic/211-mfun-invoke-vars.ck b/src/test/01-Basic/211-mfun-invoke-vars.ck new file mode 100644 index 000000000..515d3ab91 --- /dev/null +++ b/src/test/01-Basic/211-mfun-invoke-vars.ck @@ -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; diff --git a/src/test/01-Basic/211-mfun-invoke-vars.txt b/src/test/01-Basic/211-mfun-invoke-vars.txt new file mode 100644 index 000000000..44d08927c --- /dev/null +++ b/src/test/01-Basic/211-mfun-invoke-vars.txt @@ -0,0 +1 @@ +1 2.000000 3 4 diff --git a/src/test/01-Basic/79.ck b/src/test/01-Basic/216-chugen-passthrough.ck similarity index 100% rename from src/test/01-Basic/79.ck rename to src/test/01-Basic/216-chugen-passthrough.ck diff --git a/src/test/01-Basic/211-cast-to-child.ck b/src/test/01-Basic/79-cast-to-child.ck similarity index 100% rename from src/test/01-Basic/211-cast-to-child.ck rename to src/test/01-Basic/79-cast-to-child.ck