From 94fd6cbddb43c512d920265d1f80ff7070e5302d Mon Sep 17 00:00:00 2001 From: "rogerl%netscape.com" Date: Thu, 16 Nov 2000 23:50:37 +0000 Subject: [PATCH] Example from Waldemar's spec. git-svn-id: svn://10.0.0.236/trunk@82710 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/js2/tests/methods.js | 16 ++++++++++++++++ mozilla/js2/src/tests/methods.js | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 mozilla/js/js2/tests/methods.js create mode 100644 mozilla/js2/src/tests/methods.js 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