mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
Add test for attr calls specifically
This commit is contained in:
parent
268868f102
commit
2f444542ab
@ -2,7 +2,15 @@
|
||||
|
||||
load_module("test_module")
|
||||
|
||||
auto t0 = TestBaseType()
|
||||
class MyClass
|
||||
{
|
||||
var func_member;
|
||||
|
||||
def MyClass() {}
|
||||
|
||||
}
|
||||
|
||||
auto t0 = MyClass();
|
||||
|
||||
t0.func_member = fun(int i){ i * 3; };
|
||||
|
||||
|
||||
13
unittests/function_members.chai
Normal file
13
unittests/function_members.chai
Normal file
@ -0,0 +1,13 @@
|
||||
// Test attributes/members that are functions
|
||||
|
||||
load_module("test_module")
|
||||
|
||||
auto t0 = TestBaseType()
|
||||
|
||||
t0.func_member = fun(int i){ i * 3; };
|
||||
|
||||
assert_true(func_member(t0)(2) == 6)
|
||||
assert_true((func_member(t0))(2) == 6)
|
||||
assert_true((t0.func_member)(2) == 6)
|
||||
assert_true(t0.func_member(2) == 6)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user