diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/js/tjsffi.nim | 4 | ||||
-rw-r--r-- | tests/js/tthismangle.nim | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/tests/js/tjsffi.nim b/tests/js/tjsffi.nim index 156ca89e3..213d05964 100644 --- a/tests/js/tjsffi.nim +++ b/tests/js/tjsffi.nim @@ -267,8 +267,8 @@ block: type TestObject = object a: int onWhatever: proc(e: int): int - proc handleWhatever(that: TestObject, e: int): int = - e + that.a + proc handleWhatever(this: TestObject, e: int): int = + e + this.a proc test(): bool = let obj = TestObject(a: 9, onWhatever: bindMethod(handleWhatever)) obj.onWhatever(1) == 10 diff --git a/tests/js/tthismangle.nim b/tests/js/tthismangle.nim new file mode 100644 index 000000000..880abcc83 --- /dev/null +++ b/tests/js/tthismangle.nim @@ -0,0 +1,23 @@ +proc moo1(this: int) = + doAssert this == 42 + +proc moo2(x: int) = + var this = x + doAssert this == 42 + +proc moo3() = + for this in [1,1,1]: + doAssert this == 1 + +proc moo4() = + type + X = object + this: int + + var q = X(this: 42) + doAssert q.this == 42 + +moo1(42) +moo2(42) +moo3() +moo4() |