Modify "var" to "auto" for unit tests.

This commit is contained in:
Jason Turner
2011-09-24 12:05:08 -06:00
parent e3350fe55f
commit 92de42e42b
70 changed files with 127 additions and 127 deletions

View File

@@ -1,2 +1,2 @@
var prod = bind(foldl, _, `*`, 1.0)
auto prod = bind(foldl, _, `*`, 1.0)
assert_equal(60, prod([3, 4, 5]))

View File

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

View File

@@ -1,4 +1,4 @@
var i = 0
auto i = 0
while (i < 10) {
if (++i == 5) {
break

View File

@@ -3,5 +3,5 @@ assert_equal(false, 1.is_var_reference());
assert_equal(true, 1.is_var_pointer());
assert_equal(false, 1.is_var_null());
assert_equal(false, 1.is_var_undef());
var i;
auto i;
assert_equal(true, i.is_var_undef());

View File

@@ -1,3 +1,3 @@
var v = collate(1, 2)
auto v = collate(1, 2)
assert_equal(1, v[0])
assert_equal(2, v[1])

View File

@@ -1,4 +1,4 @@
var v = concat([1, 2], [3, 4]);
auto v = concat([1, 2], [3, 4]);
assert_equal(4, v.size());
assert_equal(1, v[0]);

View File

@@ -1,4 +1,4 @@
var a = [1,2,3, [4,5,6] ]
auto a = [1,2,3, [4,5,6] ]
assert_equal(a[3][0], 4)
@@ -6,6 +6,6 @@ assert_equal(a[3][0], 4)
def Test::Test() { this.a = [1,2,3]; }
attr Test::a;
var t = Test();
auto t = Test();
assert_equal(t.a[0], 1)

View File

@@ -6,6 +6,6 @@ assert_equal(get_arity.get_contained_functions().size(), 0);
assert_equal(get_arity.get_arity(), 1);
assert_equal(get_arity.get_param_types().size(), 2);
var paramtypes = get_arity.get_param_types();
auto paramtypes = get_arity.get_param_types();
assert_equal(true, paramtypes[1].bare_equal(Function_type));

View File

@@ -17,7 +17,7 @@ int main()
chaiscript::ChaiScript chai;
chai("attr bob::z; def bob::bob() { this.z = 10 }; var x = bob()");
chai("attr bob::z; def bob::bob() { this.z = 10 }; auto x = bob()");
chaiscript::dispatch::Dynamic_Object &mydo = chai.eval<chaiscript::dispatch::Dynamic_Object &>("x");

View File

@@ -1,4 +1,4 @@
var x=.5
auto x=.5
assert_equal(.5, x)
var y=-.5
auto y=-.5
assert_equal(-.5, y)

View File

@@ -20,7 +20,7 @@ def func()
def doing()
{
for (var i = 0; i < 10; ++i)
for (auto i = 0; i < 10; ++i)
{
func();
}
@@ -34,6 +34,6 @@ def while_doing()
}
}
var f = fun() { while_doing(); }
auto f = fun() { while_doing(); }
assert_equal(get_eval_error(f).call_stack.size(), 16)

View File

@@ -1,4 +1,4 @@
var x = 1
auto x = 1
try {
throw(x)
x = 2

View File

@@ -1,4 +1,4 @@
var finallyone = false;
auto finallyone = false;
try {
throw(3)
@@ -12,9 +12,9 @@ finally {
assert_equal(true, finallyone);
var try2 = false;
var catch2 = false;
var finally2 = false;
auto try2 = false;
auto catch2 = false;
auto finally2 = false;
try {

View File

@@ -1,6 +1,6 @@
var results = [];
auto results = [];
for (var i = 2; i < 6; ++i) {
for (auto i = 2; i < 6; ++i) {
try {
throw(i)
}

View File

@@ -1,6 +1,6 @@
var ret = []
auto ret = []
for (var i = 0; i < 5; ++i) {
for (auto i = 0; i < 5; ++i) {
ret.push_back(i);
}

View File

@@ -1,3 +1,3 @@
var v = [1,2,3];
var r = range(v);
auto v = [1,2,3];
auto r = range(v);
for_each(r, fun(x) { assert_equal(true, x>0); } )

View File

@@ -1,4 +1,4 @@
// Don't bother checking the output from this one, just makes sure it executes
var v = [1,2,3];
var r = retro(range(v));
auto v = [1,2,3];
auto r = retro(range(v));
for_each(r, print)

View File

@@ -31,7 +31,7 @@ assert_equal(test_fun.get_arity(), 1);
assert_equal(test_fun.get_contained_functions.size(), 1);
assert_equal(test_fun.get_param_types().size(), 2);
assert_equal(test_fun, test_fun);
var test_fun_types = test_fun.get_param_types();
auto test_fun_types = test_fun.get_param_types();
assert_equal(true, test_fun_types[0].bare_equal(Object_type));
assert_equal(true, test_fun_types[1].bare_equal(int_type));
@@ -42,7 +42,7 @@ assert_equal(2, `==`.get_arity());
// < should be the merging of two functions bool <(PODObject, PODObject) and bool <(string, string)
// we want to peel it apart and make sure that's true
var types = `<`.get_param_types();
auto types = `<`.get_param_types();
assert_equal(3, types.size());
assert_equal(true, types[0].bare_equal(bool_type));
assert_equal(true, types[1].bare_equal(Object_type));
@@ -62,7 +62,7 @@ assert_equal(true, with_guard.has_guard());
assert_equal(false, without_guard.has_guard());
assert_equal(2, group_guard.get_contained_functions().size());
var group = group_guard.get_contained_functions();
auto group = group_guard.get_contained_functions();
assert_equal(true, group[0].has_guard())
assert_equal(false, group[1].has_guard())
@@ -70,7 +70,7 @@ assert_equal(false, group[1].has_guard())
assert_throws("Function does not have a guard", fun() { group[0].get_guard(); } );
assert_throws("Function does not have a guard", fun() { without_guard.get_guard(); } );
var guard = with_guard.get_guard();
auto guard = with_guard.get_guard();
assert_equal(false, guard.has_guard());
assert_throws("Function does not have a guard", fun() { guard.get_guard(); } );

View File

@@ -22,7 +22,7 @@ int main()
chai.add(chaiscript::fun(&test_two), "test_fun");
int res1 = chai.eval<int>("test_fun(1)");
int res2 = chai.eval<int>("var i = 1; test_fun(i)");
int res2 = chai.eval<int>("auto i = 1; test_fun(i)");
int res3 = chai.eval<int>("test_fun(\"bob\")");
int res4 = chai.eval<int>("test_fun(\"hi\")");

View File

@@ -1,3 +1,3 @@
var x = `+`
auto x = `+`
x = `-`
assert_equal(1, x(5,4))

View File

@@ -1,4 +1,4 @@
var t = false;
auto t = false;
if (true) {
t = true;

View File

@@ -1,6 +1,6 @@
var i = 3
var b1 = false;
var b2 = false;
auto i = 3
auto b1 = false;
auto b2 = false;
if (i == 2) {
b1 = true;

View File

@@ -1,8 +1,8 @@
var b1 = false;
var b2 = false;
var b3 = false;
auto b1 = false;
auto b2 = false;
auto b3 = false;
var i = 3
auto i = 3
if (i == 2) {
b1 = true;
}

View File

@@ -1,5 +1,5 @@
var i = 3
var b = false
auto i = 3
auto b = false
if (i == 2) {
assert_equal(false, true)
}

View File

@@ -3,7 +3,7 @@
def Bob::bob3() { return [1,2,3]; }
def Bob::Bob() {}
var b = Bob();
auto b = Bob();
assert_equal(b.bob3()[0], 1);

View File

@@ -1,7 +1,7 @@
load_module("test_module")
var t0 = TestBaseType()
var t = TestDerivedType();
auto t0 = TestBaseType()
auto t = TestDerivedType();
assert_equal(t0.func(), 0);
assert_equal(t.func(), 1);

View File

@@ -1,3 +1,3 @@
var bob = 5.5
auto bob = 5.5
assert_equal("5.5", "${bob}")
assert_equal("val: 8 and 8", "val: ${5.5 + 2.5} and ${bob + 2.5}")

View File

@@ -1 +1 @@
assert_throws("Invalid function reassignment", fun() { var x = 5; x = `-`; } );
assert_throws("Invalid function reassignment", fun() { auto x = 5; x = `-`; } );

View File

@@ -1,4 +1,4 @@
var i;
auto i;
assert_equal(true, i.is_var_undef());
i = 5;
assert_equal(false, i.is_var_undef());

View File

@@ -1,2 +1,2 @@
var bob = fun(x) { x + 1 }
auto bob = fun(x) { x + 1 }
assert_equal(4, bob(3));

View File

@@ -1,6 +1,6 @@
load_module("stl_extra")
var x = List()
auto x = List()
x.push_back(3)
x.push_back("A")

View File

@@ -1,6 +1,6 @@
load_module("stl_extra")
var x = List()
auto x = List()
x.push_front(3)
x.push_front("A")

View File

@@ -1,7 +1,7 @@
var total = 0
auto total = 0
for (var i = 0; i < 10; ++i) {
for (var j = 0; j < 10; ++j) {
for (auto i = 0; i < 10; ++i) {
for (auto j = 0; j < 10; ++j) {
total += 1
}
}

View File

@@ -1,2 +1,2 @@
var x = ["bob":2, "fred":3]
auto x = ["bob":2, "fred":3]
assert_equal(3, x["fred"])

View File

@@ -1,3 +1,3 @@
var x = ["bob":1, "fred":2]
auto x = ["bob":1, "fred":2]
assert_equal(2, x.size());

View File

@@ -1,3 +1,3 @@
var i = 3
auto i = 3
assert_equal(2, --i)
assert_equal(2, i)

View File

@@ -1,3 +1,3 @@
var i = 3
auto i = 3
assert_equal(4, ++i)
assert_equal(4, i)

View File

@@ -8,5 +8,5 @@ def Vector3::Vector3(x, y, z) {
this.z = z
}
var v = Vector3(1,2,3);
auto v = Vector3(1,2,3);
assert_equal(1, v.x);

View File

@@ -1,9 +1,9 @@
var x = [1, 2,
auto x = [1, 2,
3, 4]
assert_equal(1, x[0])
var y = map(x,
auto y = map(x,
fun(x) { x + 1 })
assert_equal(2, y[0])

View File

@@ -1,6 +1,6 @@
attr bob::z
def bob::bob() { this.z = 10 }
var x = bob()
auto x = bob()
def bob::fred(x) { this.z - x }
assert_equal(7, x.fred(3))

View File

@@ -1,10 +1,10 @@
attr bob::z
def bob::bob() { }
var x = bob();
auto x = bob();
x.z = 10;
var y = clone(x);
auto y = clone(x);
y.z = 20;
assert_equal(10, x.z)

View File

@@ -3,8 +3,8 @@ attr bob::val
def bob::bob(x) : x < 10 { this.val = "Less Than Ten: " + x.to_string(); }
def bob::bob(x) { this.val = "Any Other Value: " + x.to_string(); }
var b = bob(12)
var c = bob(3)
auto b = bob(12)
auto c = bob(3)
assert_equal("Any Other Value: 12", b.val )
assert_equal("Less Than Ten: 3", c.val )

View File

@@ -42,15 +42,15 @@ int main()
int count = chai.eval<int>("count()");
int count2 = chai.eval<int>("var i = 0; { var t = Test(); } return i;");
int count2 = chai.eval<int>("auto i = 0; { auto t = Test(); } return i;");
int count3 = chai.eval<int>("var i = 0; { var t = Test(); i = count(); } return i;");
int count3 = chai.eval<int>("auto i = 0; { auto t = Test(); i = count(); } return i;");
int count4 = chai.eval<int>("var i = 0; { var t = Test(); { var t2 = Test(); i = count(); } } return i;");
int count4 = chai.eval<int>("auto i = 0; { auto t = Test(); { auto t2 = Test(); i = count(); } } return i;");
int count5 = chai.eval<int>("var i = 0; { var t = Test(); { var t2 = Test(); } i = count(); } return i;");
int count5 = chai.eval<int>("auto i = 0; { auto t = Test(); { auto t2 = Test(); } i = count(); } return i;");
int count6 = chai.eval<int>("var i = 0; { var t = Test(); { var t2 = Test(); } } i = count(); return i;");
int count6 = chai.eval<int>("auto i = 0; { auto t = Test(); { auto t2 = Test(); } } i = count(); return i;");
if (count == 0
&& count2 == 0

View File

@@ -2,6 +2,6 @@ def bob::bob() { }
def bob::fred(e) : e < 10 { assert_equal(true, e<10) }
def bob::fred(e) { assert_equal(true, e >= 10) }
var b = bob()
auto b = bob()
b.fred(3)
b.fred(12)

View File

@@ -1,8 +1,8 @@
def Bob::`+`(y) { this.x + y.x }
def Bob::Bob() { }
attr Bob::x
var b = Bob()
var c = Bob()
auto b = Bob()
auto c = Bob()
b.x = 4
c.x = 5

View File

@@ -1,8 +1,8 @@
def Bob::Bob() { }
attr Bob::x
def `-`(a, b) : is_type(a, "Bob") && is_type(b, "Bob") { a.x - b.x }
var b = Bob()
var c = Bob()
auto b = Bob()
auto c = Bob()
b.x = 4
c.x = 5

View File

@@ -1,6 +1,6 @@
var i = 1.0;
var j = 2.0;
var k = 3.0;
auto i = 1.0;
auto j = 2.0;
auto k = 3.0;
assert_equal(3, i + j)
assert_equal(1.0, +i)

View File

@@ -1,6 +1,6 @@
var i = 1;
var j = 2;
var k = 3;
auto i = 1;
auto j = 2;
auto k = 3;
assert_equal(3, i + j);
assert_equal(1, +i);

View File

@@ -1,4 +1,4 @@
var p = Pair("Hello", "World")
auto p = Pair("Hello", "World")
assert_equal(p.first, "Hello")
assert_equal(p.second, "World")

View File

@@ -1,8 +1,8 @@
load_module("test_module")
var i = 1;
var t0 = TestBaseType(i);
auto i = 1;
auto t0 = TestBaseType(i);
var t1 = TestBaseType(get_new_int())
auto t1 = TestBaseType(get_new_int())

View File

@@ -1,3 +1,3 @@
var x = var y = 4
auto x = auto y = 4
assert_equal(4, x);
assert_equal(4, y);

View File

@@ -1,4 +1,4 @@
var x = [1, 2, 3, 4]
var r = range(x)
auto x = [1, 2, 3, 4]
auto r = range(x)
r.pop_front()
assert_equal(2, r.front());

View File

@@ -1,4 +1,4 @@
var x = [1, 2, 3, 4]
var r = range(x)
auto x = [1, 2, 3, 4]
auto r = range(x)
r.pop_back()
assert_equal(3, r.back())

View File

@@ -1,4 +1,4 @@
var v = [1,2,"hi", "world", 5.5]
auto v = [1,2,"hi", "world", 5.5]
assert_equal(true, v.contains(5.5))
assert_equal(false, v.contains(0))
assert_equal(false, v.contains(1, lt))

View File

@@ -1,6 +1,6 @@
var v = [2, 1, "Hi", 5.5]
var r = v.find("Hi");
auto v = [2, 1, "Hi", 5.5]
auto r = v.find("Hi");
assert_equal("Hi", r.front())
var r2 = v.find(2, `<`);
auto r2 = v.find(2, `<`);
assert_equal(1, r2.front());

View File

@@ -1,5 +1,5 @@
var i = 3
var j := i
auto i = 3
auto j := i
j = 4
assert_equal(4, i)

View File

@@ -1,14 +1,14 @@
load_module("reflection")
var parser := ChaiScript_Parser()
var parse_success = parser.parse("3 + 4", "INPUT")
var a := parser.ast()
auto parser := ChaiScript_Parser()
auto parse_success = parser.parse("3 + 4", "INPUT")
auto a := parser.ast()
assert_equal(eval(a), 7)
var childs := a.children.front().children
var node := childs[0]
auto childs := a.children.front().children
auto node := childs[0]
var parser2 := ChaiScript_Parser()
auto parser2 := ChaiScript_Parser()
parser2.parse("9", "INPUT")
@@ -30,7 +30,7 @@ assert_equal(false, `+`.has_parse_tree());
assert_throws("Function does not have a parse tree", fun() { `+`.get_parse_tree(); } );
var parsetree := my_fun.get_parse_tree();
auto parsetree := my_fun.get_parse_tree();
assert_equal(1, eval(parsetree));

View File

@@ -1,4 +1,4 @@
var x = [1, 2, 3, 4]
var r = retro(range(x))
auto x = [1, 2, 3, 4]
auto r = retro(range(x))
r.pop_front()
assert_equal(3, r.front())

View File

@@ -1,7 +1,7 @@
var x = [1, 2, 3, 4]
var r = retro(range(x))
auto x = [1, 2, 3, 4]
auto r = retro(range(x))
r.pop_back()
var r2 = retro(r)
auto r2 = retro(r)
r2.pop_front()
assert_equal(2, r.back())
assert_equal(3, r2.front())

View File

@@ -1,4 +1,4 @@
var caught = false
auto caught = false
try {
throw(runtime_error("error"))

View File

@@ -35,9 +35,9 @@ int main()
chaiscript::ChaiScript chai;
chai.add(m);
if (chai.eval<std::string>("var t = Test(); t.function2(); ") == "Function2"
&& chai.eval<std::string>("var t = Test(); t.functionOverload(1); ") == "int"
&& chai.eval<std::string>("var t = Test(); t.functionOverload(1.1); ") == "double")
if (chai.eval<std::string>("auto t = Test(); t.function2(); ") == "Function2"
&& chai.eval<std::string>("auto t = Test(); t.functionOverload(1); ") == "int"
&& chai.eval<std::string>("auto t = Test(); t.functionOverload(1.1); ") == "double")
{
chai.eval("t = Test();");
return EXIT_SUCCESS;

View File

@@ -1,2 +1,2 @@
var x = [1, 2, 3]
auto x = [1, 2, 3]
assert_equal(3, x[2])

View File

@@ -1,3 +1,3 @@
var x = [1, 2, 3]
auto x = [1, 2, 3]
x.erase_at(1)
assert_equal([1,3], x);

View File

@@ -1,2 +1,2 @@
var x = [1, 2, 3]
auto x = [1, 2, 3]
assert_equal(3, x.size())

View File

@@ -1,3 +1,3 @@
var x = [1, 2, 3]
auto x = [1, 2, 3]
x.insert_at(1, 6)
assert_equal([1,6,2,3], x);

View File

@@ -1,2 +1,2 @@
var x = [1]
auto x = [1]
assert_equal(1, x[0])

View File

@@ -1,4 +1,4 @@
var x = [1, 2]
auto x = [1, 2]
x.push_back(3)
assert_equal(3, x.size())
assert_equal(3, x.back())

View File

@@ -1,4 +1,4 @@
var bob = []
auto bob = []
bob.push_back(3)
assert_equal(1, bob.size())
assert_equal(3, bob.front())

View File

@@ -1,4 +1,4 @@
var z = zip([1, 2, 3], [4, 5, 6])
auto z = zip([1, 2, 3], [4, 5, 6])
assert_equal([1,4], z[0])
assert_equal([2,5], z[1])

View File

@@ -1,3 +1,3 @@
var z = zip_with(`+`, [1, 2, 3], [4, 5, 6])
auto z = zip_with(`+`, [1, 2, 3], [4, 5, 6])
assert_equal([5,7,9], z)