diff --git a/mozilla/js/js2/tests/methods.js b/mozilla/js/js2/tests/methods.js new file mode 100644 index 00000000000..15ff72a85aa --- /dev/null +++ b/mozilla/js/js2/tests/methods.js @@ -0,0 +1,16 @@ + +load("verify.js"); + +class C { + var x:Integer = 3; + function m() {return x} + function n(x) {return x+4} + } + + var c:C = new C; +verify( c.m(), 3 ); // returns 3 +verify( c.n(7), 11 ); // returns 11 + var f:Function = c.m; // f is a zero-argument function with this bound to c +verify( f(), 3 ); // returns 3 + c.x = 8; +verify( f(), 8 ); // returns 8 \ No newline at end of file diff --git a/mozilla/js2/src/tests/methods.js b/mozilla/js2/src/tests/methods.js new file mode 100644 index 00000000000..15ff72a85aa --- /dev/null +++ b/mozilla/js2/src/tests/methods.js @@ -0,0 +1,16 @@ + +load("verify.js"); + +class C { + var x:Integer = 3; + function m() {return x} + function n(x) {return x+4} + } + + var c:C = new C; +verify( c.m(), 3 ); // returns 3 +verify( c.n(7), 11 ); // returns 11 + var f:Function = c.m; // f is a zero-argument function with this bound to c +verify( f(), 3 ); // returns 3 + c.x = 8; +verify( f(), 8 ); // returns 8 \ No newline at end of file