Move to a more standardized unit testing design which relies less on OS support and can soon be moved to a ctest implementation
This commit is contained in:
@@ -252,8 +252,8 @@ namespace chaiscript
|
|||||||
push_back_name = "push_back";
|
push_back_name = "push_back";
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (ContainerType::*pushback)(const typename ContainerType::value_type &);
|
typedef void (ContainerType::*pushback)(const typename ContainerType::value_type &);
|
||||||
m->add(fun(static_cast<pushback>(&ContainerType::push_back)), push_back_name);
|
m->add(fun(static_cast<pushback>(&ContainerType::push_back)), push_back_name);
|
||||||
m->add(fun(&ContainerType::pop_back), "pop_back");
|
m->add(fun(&ContainerType::pop_back), "pop_back");
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,6 @@ namespace chaiscript
|
|||||||
ModulePtr front_insertion_sequence_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
|
ModulePtr front_insertion_sequence_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
|
||||||
{
|
{
|
||||||
typedef typename ContainerType::reference (ContainerType::*frontptr)();
|
typedef typename ContainerType::reference (ContainerType::*frontptr)();
|
||||||
|
|
||||||
m->add(fun(static_cast<frontptr>(&ContainerType::front)), "front");
|
m->add(fun(static_cast<frontptr>(&ContainerType::front)), "front");
|
||||||
|
|
||||||
std::string push_front_name;
|
std::string push_front_name;
|
||||||
@@ -334,7 +333,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
m->add(user_type<MapType>(), type);
|
m->add(user_type<MapType>(), type);
|
||||||
|
|
||||||
typedef typename MapType::mapped_type &(MapType::*elemaccess)(const typename MapType::key_type &);
|
typedef typename MapType::mapped_type &(MapType::*elemaccess)(const typename MapType::key_type &);
|
||||||
m->add(fun(static_cast<elemaccess>(&MapType::operator[])), "[]");
|
m->add(fun(static_cast<elemaccess>(&MapType::operator[])), "[]");
|
||||||
|
|
||||||
container_type<MapType>(type, m);
|
container_type<MapType>(type, m);
|
||||||
@@ -375,6 +374,10 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
m->add(user_type<VectorType>(), type);
|
m->add(user_type<VectorType>(), type);
|
||||||
|
|
||||||
|
typedef typename VectorType::reference (VectorType::*frontptr)();
|
||||||
|
m->add(fun(static_cast<frontptr>(&VectorType::front)), "front");
|
||||||
|
|
||||||
|
|
||||||
back_insertion_sequence_type<VectorType>(type, m);
|
back_insertion_sequence_type<VectorType>(type, m);
|
||||||
sequence_type<VectorType>(type, m);
|
sequence_type<VectorType>(type, m);
|
||||||
random_access_container_type<VectorType>(type, m);
|
random_access_container_type<VectorType>(type, m);
|
||||||
@@ -383,6 +386,27 @@ namespace chaiscript
|
|||||||
assignable_type<VectorType>(type, m);
|
assignable_type<VectorType>(type, m);
|
||||||
input_range_type<VectorType>(type, m);
|
input_range_type<VectorType>(type, m);
|
||||||
|
|
||||||
|
|
||||||
|
m->eval("def Vector::`==`(rhs) : type_match(rhs, this) { \
|
||||||
|
if ( rhs.size() != this.size() ) { \
|
||||||
|
return false; \
|
||||||
|
} else { \
|
||||||
|
var r1 = range(this); \
|
||||||
|
var r2 = range(rhs); \
|
||||||
|
while (!r1.empty()) \
|
||||||
|
{ \
|
||||||
|
if (!eq(r1.front(), r2.front())) \
|
||||||
|
{ \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
r1.pop_front(); \
|
||||||
|
r2.pop_front(); \
|
||||||
|
} \
|
||||||
|
return true; \
|
||||||
|
} \
|
||||||
|
}");
|
||||||
|
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,15 +8,13 @@ echo -n "Running unit tests"
|
|||||||
for file in unittests/*.chai
|
for file in unittests/*.chai
|
||||||
do
|
do
|
||||||
tstname=${file%.*}
|
tstname=${file%.*}
|
||||||
tst="$tstname.txt"
|
OUTPUT=`LD_LIBRARY_PATH=. ./chaiscript_eval unittests/unit_test.inc $file`
|
||||||
LD_LIBRARY_PATH=. ./chaiscript_eval $file > /tmp/tstout.txt
|
|
||||||
diff $tst /tmp/tstout.txt
|
|
||||||
if [ "$?" -eq "0" ]
|
if [ "$?" -eq "0" ]
|
||||||
then
|
then
|
||||||
echo -n "."
|
echo -n "."
|
||||||
successes=$((successes+1))
|
successes=$((successes+1))
|
||||||
else
|
else
|
||||||
echo "[from failed test $file]"
|
echo "[from failed test $file] $OUTPUT"
|
||||||
failures=$((failures+1))
|
failures=$((failures+1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
22
src/main.cpp
22
src/main.cpp
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <chaiscript/chaiscript.hpp>
|
#include <chaiscript/chaiscript.hpp>
|
||||||
|
|
||||||
|
|
||||||
void print_help() {
|
void print_help() {
|
||||||
std::cout << "ChaiScript evaluator. To evaluate an expression, type it and press <enter>." << std::endl;
|
std::cout << "ChaiScript evaluator. To evaluate an expression, type it and press <enter>." << std::endl;
|
||||||
std::cout << "Additionally, you can inspect the runtime system using:" << std::endl;
|
std::cout << "Additionally, you can inspect the runtime system using:" << std::endl;
|
||||||
@@ -22,6 +23,19 @@ void print_help() {
|
|||||||
std::cout << " dump_object(x) - dumps information about the given symbol" << std::endl;
|
std::cout << " dump_object(x) - dumps information about the given symbol" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool throws_exception(const chaiscript::Proxy_Function &f)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
chaiscript::functor<void ()>(f)();
|
||||||
|
} catch (...) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string get_next_command() {
|
std::string get_next_command() {
|
||||||
#ifdef READLINE_AVAILABLE
|
#ifdef READLINE_AVAILABLE
|
||||||
char *input_raw;
|
char *input_raw;
|
||||||
@@ -40,10 +54,10 @@ int main(int argc, char *argv[]) {
|
|||||||
std::string input;
|
std::string input;
|
||||||
chaiscript::ChaiScript chai;
|
chaiscript::ChaiScript chai;
|
||||||
|
|
||||||
|
chai.add(chaiscript::fun(&exit), "exit");
|
||||||
|
chai.add(chaiscript::fun(&throws_exception), "throws_exception");
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
//std::cout << "eval> ";
|
|
||||||
//std::getline(std::cin, input);
|
|
||||||
#ifdef READLINE_AVAILABLE
|
#ifdef READLINE_AVAILABLE
|
||||||
using_history();
|
using_history();
|
||||||
#endif
|
#endif
|
||||||
@@ -80,14 +94,16 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
std::string filename(argv[i]);
|
|
||||||
try {
|
try {
|
||||||
chaiscript::Boxed_Value val = chai.eval_file(argv[i]);
|
chaiscript::Boxed_Value val = chai.eval_file(argv[i]);
|
||||||
}
|
}
|
||||||
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_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
var prod = bind(foldl, _, `*`, 1.0)
|
var prod = bind(foldl, _, `*`, 1.0)
|
||||||
print(prod([3, 4, 5]))
|
assert_equal(60, prod([3, 4, 5]))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
60
|
|
@@ -1 +0,0 @@
|
|||||||
hello
|
|
@@ -1 +1 @@
|
|||||||
print(!true)
|
assert_equal(false, !true)
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
false
|
|
@@ -4,4 +4,4 @@ while (i < 10) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(i)
|
assert_equal(5, i);
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
5
|
|
@@ -1 +1 @@
|
|||||||
print('b')
|
assert_equal("b", to_string('b'))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
b
|
|
@@ -1,7 +1,7 @@
|
|||||||
print(1.is_var_const());
|
assert_equal(true, 1.is_var_const());
|
||||||
print(1.is_var_reference());
|
assert_equal(false, 1.is_var_reference());
|
||||||
print(1.is_var_pointer());
|
assert_equal(true, 1.is_var_pointer());
|
||||||
print(1.is_var_null());
|
assert_equal(false, 1.is_var_null());
|
||||||
print(1.is_var_undef());
|
assert_equal(false, 1.is_var_undef());
|
||||||
var i;
|
var i;
|
||||||
print(i.is_var_undef());
|
assert_equal(true, i.is_var_undef());
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
true
|
|
||||||
false
|
|
||||||
true
|
|
||||||
false
|
|
||||||
false
|
|
||||||
true
|
|
@@ -1 +1,3 @@
|
|||||||
print(collate(1, 2))
|
var v = collate(1, 2)
|
||||||
|
assert_equal(1, v[0])
|
||||||
|
assert_equal(2, v[1])
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[1, 2]
|
|
@@ -1 +1 @@
|
|||||||
print(1 > 2)
|
assert_equal(false, 1 > 2);
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
false
|
|
@@ -1 +1 @@
|
|||||||
print(1 < 2)
|
assert_equal(true, 1 < 2)
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
true
|
|
@@ -1 +1,5 @@
|
|||||||
print(concat([1, 2], [3, 4]))
|
var v = concat([1, 2], [3, 4]);
|
||||||
|
|
||||||
|
assert_equal(4, v.size());
|
||||||
|
assert_equal(1, v[0]);
|
||||||
|
assert_equal(4, v[3]);
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[1, 2, 3, 4]
|
|
@@ -1 +1 @@
|
|||||||
print(3.5.to_string() + "bob")
|
assert_equal("3.5bob", 3.5.to_string() + "bob");
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
3.5bob
|
|
@@ -1 +1 @@
|
|||||||
print(3.to_string + "bob")
|
assert_equal("3bob", 3.to_string + "bob")
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
3bob
|
|
@@ -1 +1 @@
|
|||||||
print("3.5".to_double() + 3.3)
|
assert_equal(6.8, "3.5".to_double() + 3.3)
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
6.7999999999999998
|
|
@@ -1 +1 @@
|
|||||||
print("4".to_int() + 4)
|
assert_equal(8, "4".to_int() + 4)
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
8
|
|
@@ -1 +1 @@
|
|||||||
print(drop([1, 2, 3, 4], 2))
|
assert_equal([3,4], drop([1, 2, 3, 4], 2))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[3, 4]
|
|
@@ -1 +1 @@
|
|||||||
print(drop_while([1, 2, 3], odd))
|
assert_equal([2, 3], drop_while([1, 2, 3], odd))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[2, 3]
|
|
@@ -1,4 +1,4 @@
|
|||||||
var x=.5
|
var x=.5
|
||||||
print(x)
|
assert_equal(.5, x)
|
||||||
var y=-.5
|
var y=-.5
|
||||||
print(y)
|
assert_equal(-.5, y)
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
0.5
|
|
||||||
-0.5
|
|
@@ -1 +1 @@
|
|||||||
print(eval("3 + 4"))
|
assert_equal(7, eval("3 + 4"))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
7
|
|
@@ -1 +1 @@
|
|||||||
print(even(4))
|
assert_equal(true, even(4))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
true
|
|
@@ -6,4 +6,4 @@ try {
|
|||||||
catch(e) {
|
catch(e) {
|
||||||
x = e + 3
|
x = e + 3
|
||||||
}
|
}
|
||||||
print(x)
|
assert_equal(4, x);
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
4
|
|
@@ -1,19 +1,32 @@
|
|||||||
|
var finallyone = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
throw(3)
|
throw(3)
|
||||||
}
|
}
|
||||||
catch(x) {
|
catch(x) {
|
||||||
print(x)
|
assert_equal(3, x)
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
print("Finally #1")
|
finallyone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_equal(true, finallyone);
|
||||||
|
|
||||||
|
var try2 = false;
|
||||||
|
var catch2 = false;
|
||||||
|
var finally2 = false;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
print("Safe")
|
try2 = true;
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
print("Caught")
|
catch2 = true;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
print("Finally #2")
|
finally2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_equal(true, try2);
|
||||||
|
assert_equal(false, catch2);
|
||||||
|
assert_equal(true, finally2);
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
3
|
|
||||||
Finally #1
|
|
||||||
Safe
|
|
||||||
Finally #2
|
|
@@ -1,18 +1,21 @@
|
|||||||
|
var results = [];
|
||||||
|
|
||||||
for (var i = 2; i < 6; ++i) {
|
for (var i = 2; i < 6; ++i) {
|
||||||
try {
|
try {
|
||||||
throw(i)
|
throw(i)
|
||||||
}
|
}
|
||||||
catch(e) : e < 2 {
|
catch(e) : e < 2 {
|
||||||
print("Catch 1: " + e.to_string())
|
results.push_back("c1: " + e.to_string());
|
||||||
}
|
}
|
||||||
catch(e) : e < 4 {
|
catch(e) : e < 4 {
|
||||||
print("Catch 2: " + e.to_string())
|
results.push_back("c2: " + e.to_string());
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
print("Catch 3: " + e.to_string())
|
results.push_back("c3: " + e.to_string());
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
print("This is never called")
|
// Should never get called
|
||||||
|
assert_equal(false, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,8 +24,11 @@ try {
|
|||||||
}
|
}
|
||||||
catch(e) : e < 3
|
catch(e) : e < 3
|
||||||
{
|
{
|
||||||
print("Caught less than 3")
|
// Should never get called
|
||||||
|
assert_equal(false, true);
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
print("Backup catch")
|
results.push_back("defaultcatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_equal(["c2: 2", "c2: 3", "c3: 4", "c3: 5", "defaultcatch"], results);
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
Catch 2: 2
|
|
||||||
Catch 2: 3
|
|
||||||
Catch 3: 4
|
|
||||||
Catch 3: 5
|
|
||||||
Backup catch
|
|
@@ -1 +1 @@
|
|||||||
print(filter([1, 2, 3, 4], odd))
|
assert_equal([1,3], filter([1, 2, 3, 4], odd))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[1, 3]
|
|
@@ -1,2 +1,7 @@
|
|||||||
print(1.2)
|
assert_equal(true, 1.2 < 2)
|
||||||
print(.5)
|
assert_equal(true, 1.2 > 1)
|
||||||
|
assert_equal(1.2, 1.2)
|
||||||
|
|
||||||
|
assert_equal(true, .5 > 0)
|
||||||
|
assert_equal(true, .5 < 1)
|
||||||
|
assert_equal(0.5, .5)
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
1.2
|
|
||||||
0.5
|
|
@@ -1 +1 @@
|
|||||||
print(foldl([1, 2, 3, 4], `+`, 0))
|
assert_equal(10, foldl([1, 2, 3, 4], `+`, 0))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
10
|
|
@@ -1,3 +1,7 @@
|
|||||||
|
var ret = []
|
||||||
|
|
||||||
for (var i = 0; i < 5; ++i) {
|
for (var i = 0; i < 5; ++i) {
|
||||||
print(i)
|
ret.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert_equal([0,1,2,3,4], ret);
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
0
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
@@ -1,3 +0,0 @@
|
|||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
@@ -1,3 +1,3 @@
|
|||||||
var v = [1,2,3];
|
var v = [1,2,3];
|
||||||
var r = range(v);
|
var r = range(v);
|
||||||
for_each(r, print)
|
for_each(r, fun(x) { assert_equal(true, x>0); } )
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
@@ -1,3 +1,4 @@
|
|||||||
|
// Don't bother checking the output from this one, just makes sure it executes
|
||||||
var v = [1,2,3];
|
var v = [1,2,3];
|
||||||
var r = retro(range(v));
|
var r = retro(range(v));
|
||||||
for_each(r, print)
|
for_each(r, print)
|
||||||
|
@@ -1,3 +0,0 @@
|
|||||||
3
|
|
||||||
2
|
|
||||||
1
|
|
@@ -1,3 +1,3 @@
|
|||||||
var x = `+`
|
var x = `+`
|
||||||
x = `-`
|
x = `-`
|
||||||
print(x(5,4))
|
assert_equal(1, x(5,4))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
1
|
|
@@ -1 +1 @@
|
|||||||
print(generate_range(1, 10))
|
assert_equal([1,2,3,4,5,6,7,8,9,10], generate_range(1, 10))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
|
|
@@ -1,4 +1,7 @@
|
|||||||
|
var t = false;
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
print("true")
|
t = true;
|
||||||
}
|
}
|
||||||
print("done")
|
|
||||||
|
assert_equal(true, t);
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
true
|
|
||||||
done
|
|
@@ -1,8 +1,13 @@
|
|||||||
var i = 3
|
var i = 3
|
||||||
|
var b1 = false;
|
||||||
|
var b2 = false;
|
||||||
|
|
||||||
if (i == 2) {
|
if (i == 2) {
|
||||||
print("2")
|
b1 = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("other")
|
b2 = true;
|
||||||
}
|
}
|
||||||
print("done")
|
|
||||||
|
assert_equal(false, b1);
|
||||||
|
assert_equal(true, b2);
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
other
|
|
||||||
done
|
|
@@ -1,12 +1,18 @@
|
|||||||
|
var b1 = false;
|
||||||
|
var b2 = false;
|
||||||
|
var b3 = false;
|
||||||
|
|
||||||
var i = 3
|
var i = 3
|
||||||
if (i == 2) {
|
if (i == 2) {
|
||||||
print("2")
|
b1 = true;
|
||||||
}
|
}
|
||||||
else if (i == 4) {
|
else if (i == 4) {
|
||||||
print("4")
|
b2 = true;
|
||||||
}
|
}
|
||||||
else if (i == 3) {
|
else if (i == 3) {
|
||||||
print("3")
|
b3 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
print("done")
|
assert_equal(false, b1);
|
||||||
|
assert_equal(false, b2);
|
||||||
|
assert_equal(true, b3);
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
3
|
|
||||||
done
|
|
@@ -1,12 +1,14 @@
|
|||||||
var i = 3
|
var i = 3
|
||||||
|
var b = false
|
||||||
if (i == 2) {
|
if (i == 2) {
|
||||||
print("2")
|
assert_equal(false, true)
|
||||||
}
|
}
|
||||||
else if (i == 4) {
|
else if (i == 4) {
|
||||||
print("4")
|
assert_equal(false, true)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("3")
|
assert_equal(true, true)
|
||||||
|
b = true
|
||||||
}
|
}
|
||||||
|
|
||||||
print("done")
|
assert_equal(true, b)
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
3
|
|
||||||
done
|
|
@@ -1,3 +1,3 @@
|
|||||||
var bob = 5.5
|
var bob = 5.5
|
||||||
print("${bob}")
|
assert_equal("5.5", "${bob}")
|
||||||
print("val: ${5.5 + 2.5} and ${bob + 2.5}")
|
assert_equal("val: 8 and 8", "val: ${5.5 + 2.5} and ${bob + 2.5}")
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
5.5
|
|
||||||
val: 8 and 8
|
|
@@ -1,4 +1,4 @@
|
|||||||
print("$ {4 + 5}")
|
assert_equal("\$ {4 + 5}", "$ {4 + 5}")
|
||||||
print("$${4+5}")
|
assert_equal("\$9", "$${4+5}")
|
||||||
print("Value: \${4 + 5}")
|
assert_equal("Value: \${4 + 5}", "Value: \${4 + 5}")
|
||||||
print("Value: \$${4 + 5}")
|
assert_equal("Value: \$9", "Value: \$${4 + 5}")
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
$ {4 + 5}
|
|
||||||
$9
|
|
||||||
Value: ${4 + 5}
|
|
||||||
Value: $9
|
|
@@ -1 +1 @@
|
|||||||
clone = `-`
|
assert_throws("Illegal const function assignment", fun() { clone = `-` } );
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
Error: "Mismatched types in equation, lhs is const." in 'unittests/invalid_function_assignment.chai' at (1, 7)
|
|
@@ -1,2 +1 @@
|
|||||||
var x = 5
|
assert_throws("Invalid function reassignment", fun() { var x = 5; x = `-`; } );
|
||||||
x = `-`
|
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
Error: "Mismatched types in equation." in 'unittests/invalid_function_reassignment.chai' at (2, 3)
|
|
@@ -1,4 +1,4 @@
|
|||||||
var i;
|
var i;
|
||||||
print(i.is_var_undef());
|
assert_equal(true, i.is_var_undef());
|
||||||
i = 5;
|
i = 5;
|
||||||
print(i.is_var_undef());
|
assert_equal(false, i.is_var_undef());
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
true
|
|
||||||
false
|
|
@@ -1 +1 @@
|
|||||||
print(join([1, 2, 3], "*"))
|
assert_equal("1*2*3", join([1, 2, 3], "*"))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
1*2*3
|
|
@@ -1,2 +1,2 @@
|
|||||||
var bob = fun(x) { x + 1 }
|
var bob = fun(x) { x + 1 }
|
||||||
print(bob(3))
|
assert_equal(4, bob(3));
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
4
|
|
@@ -3,4 +3,6 @@ load_module("stl_extra")
|
|||||||
var x = List()
|
var x = List()
|
||||||
x.push_back(3)
|
x.push_back(3)
|
||||||
x.push_back("A")
|
x.push_back("A")
|
||||||
print(x)
|
|
||||||
|
assert_equal(3, x.front());
|
||||||
|
assert_equal("A", x.back());
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[3, A]
|
|
@@ -3,4 +3,6 @@ load_module("stl_extra")
|
|||||||
var x = List()
|
var x = List()
|
||||||
x.push_front(3)
|
x.push_front(3)
|
||||||
x.push_front("A")
|
x.push_front("A")
|
||||||
print(x)
|
|
||||||
|
assert_equal("A", x.front());
|
||||||
|
assert_equal(3, x.back());
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[A, 3]
|
|
@@ -1,2 +1,2 @@
|
|||||||
load_module("test")
|
load_module("test")
|
||||||
print(hello_world())
|
assert_equal("Hello World", hello_world());
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
Hello World
|
|
@@ -6,5 +6,4 @@ for (var i = 0; i < 10; ++i) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print(total)
|
assert_equal(100, total);
|
||||||
|
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
100
|
|
@@ -1 +1 @@
|
|||||||
print(map([1, 2, 3], odd))
|
assert_equal([true, false, true], map([1,2,3], odd))
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[true, false, true]
|
|
@@ -1,2 +1,2 @@
|
|||||||
var x = ["bob":2, "fred":3]
|
var x = ["bob":2, "fred":3]
|
||||||
print(x["fred"])
|
assert_equal(3, x["fred"])
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
3
|
|
@@ -1,2 +1,3 @@
|
|||||||
var x = ["bob":1, "fred":2]
|
var x = ["bob":1, "fred":2]
|
||||||
print(x)
|
|
||||||
|
assert_equal(2, x.size());
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
[<bob, 1>, <fred, 2>]
|
|
@@ -1 +1 @@
|
|||||||
print(1 + 2)
|
assert_equal(3, (1 + 2))
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user