2011-09-24 12:05:08 -06:00

35 lines
596 B
ChaiScript

def add(x, y)
{
return x + y;
}
assert_equal(2, add.get_arity());
auto b = bind(add, 2, _);
assert_equal(1, b.get_arity());
auto c = bind(b, 3);
assert_equal(0, c.get_arity());
assert_equal(6, b(4));
assert_equal(5, c());
def concat2(a,b,c,d)
{
return to_string(a) + to_string(b) + to_string(c) + to_string(d);
}
auto d = bind(concat2, _, " Hello ", _, " World");
assert_equal(2, d.get_arity());
assert_equal("1 Hello 3 World", d(1,3));
auto e = bind(`<`, _, 5);
auto types = e.get_param_types();
assert_equal(2, types.size());
assert_equal(true, types[0].bare_equal(bool_type));