Add some unit tests for reflection and recently discovered array lookup returned from a method problem
This commit is contained in:
parent
31feab6053
commit
efae821996
@ -149,10 +149,11 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
catch (std::exception &e) {
|
catch (std::exception &e) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
unittests/deep_array_lookup.chai
Normal file
11
unittests/deep_array_lookup.chai
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
var a = [1,2,3, [4,5,6] ]
|
||||||
|
|
||||||
|
assert_equal(a[3][0], 4)
|
||||||
|
|
||||||
|
|
||||||
|
def Test::Test() { this.a = [1,2,3]; }
|
||||||
|
attr Test::a;
|
||||||
|
|
||||||
|
var t = Test();
|
||||||
|
|
||||||
|
assert_equal(t.a[0], 1)
|
14
unittests/reflection_test.chai
Normal file
14
unittests/reflection_test.chai
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
load_module("reflection")
|
||||||
|
var fname = "INPUT"
|
||||||
|
var parser := ChaiScript_Parser()
|
||||||
|
var parse_success = parser.parse("3 + 4", fname.c_str())
|
||||||
|
var a := parser.ast()
|
||||||
|
|
||||||
|
assert_equal(eval(a), 7)
|
||||||
|
|
||||||
|
var childs := a.children.front().children
|
||||||
|
var node := childs[0]
|
||||||
|
|
||||||
|
node.text = "9"
|
||||||
|
|
||||||
|
assert_equal(eval(a), 13)
|
Loading…
x
Reference in New Issue
Block a user