From 8a245b3f00f7dabb1b4134f7cf328b4b45259c2f Mon Sep 17 00:00:00 2001 From: mtardy Date: Wed, 12 Aug 2020 10:41:04 +0200 Subject: [PATCH] Add tests for incdec and object instanciation --- test-incdec.txt | 43 +++++++++++++++++++++++++++++++++++++++++++ test-object.txt | 29 +++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 test-incdec.txt create mode 100644 test-object.txt diff --git a/test-incdec.txt b/test-incdec.txt new file mode 100644 index 0000000..b944925 --- /dev/null +++ b/test-incdec.txt @@ -0,0 +1,43 @@ +var a = { x: 42}; + +a.x; +++a.x; +a.x; +++a[#"x"]; +a.x; + +var b = 666; +b; +++b; +b; + +a.x; +a.x++; +a.x; +a[#"x"]++; +a.x; + +b; +b++; +b; + +a.x; +--a.x; +a.x; +--a[#"x"]; +a.x; + +var b = 666; +b; +--b; +b; + +a.x; +a.x--; +a.x; +a[#"x"]--; +a.x; + +b; +b--; +b; diff --git a/test-object.txt b/test-object.txt new file mode 100644 index 0000000..b48b3db --- /dev/null +++ b/test-object.txt @@ -0,0 +1,29 @@ +var Object = { __name__: #"Object" }; + +print("Object is ", Object); + +var Point = { __name__: #"Point", __proto__ : Object }; + +print("Point is ", Point); + +Object.new = fun () { + print("ARGS are ", __arguments__); + var obj= { __proto__ : this }; + var init= this.init; + print("INIT is ", init); + init && invoke(null, obj, init, __arguments__); + obj; +}; + +print("Object.new is ", Object.new); + +print("Point.new is ", Point.new); + +print("Object.new() is ", Object.new()); + +Point.init = fun (x, y) { + this.x = x; + this.y = y; +} + +print("Point.new(3, 4) is ", Point.new(3, 4));