diff --git a/src/print.c b/src/print.c index f26514a..0390516 100644 --- a/src/print.c +++ b/src/print.c @@ -29,7 +29,7 @@ void print( FILE* output, struct cons_pointer pointer) { } fputc( ')', output); } else if ( check_tag( pointer, INTEGERTAG)) { - fprintf( output, " %ld", cell.payload.integer.value); + fprintf( output, "%ld", cell.payload.integer.value); } else if ( check_tag( pointer, NILTAG)) { fprintf( output, "NIL"); } else if ( check_tag( pointer, REALTAG)) { diff --git a/unit-tests.sh b/unit-tests.sh index da99fa6..d631ddf 100755 --- a/unit-tests.sh +++ b/unit-tests.sh @@ -13,7 +13,7 @@ fail=0 for file in unit-tests/* do - echo ${file} + echo -n "${file} => " bash ${file} if [ $? -eq 0 ] diff --git a/unit-tests/empty-string.sh b/unit-tests/empty-string.sh index c8e947a..2eccbe3 100644 --- a/unit-tests/empty-string.sh +++ b/unit-tests/empty-string.sh @@ -8,6 +8,6 @@ then echo "OK" exit 0 else - echo "Expected '$expected', got '$actual'" + echo "Fail: expected '$expected', got '$actual'" exit 1 fi diff --git a/unit-tests/fred.sh b/unit-tests/fred.sh index 2be3096..5b3048c 100644 --- a/unit-tests/fred.sh +++ b/unit-tests/fred.sh @@ -1,13 +1,13 @@ #!/bin/bash expected=\"Fred\" -actual=`echo '"Fred"' | target/psse 2> /dev/null` +actual=`echo ${expected} | target/psse 2> /dev/null` -if [ "$expected" = "$actual" ] +if [ "${expected}" = "{$actual}" ] then echo "OK" exit 0 else - echo "Expected '$expected', got '$actual'" + echo "Fail: expected '$expected', got '$actual'" exit 1 fi diff --git a/unit-tests/integer-allocation.sh b/unit-tests/integer-allocation.sh new file mode 100644 index 0000000..cc811b8 --- /dev/null +++ b/unit-tests/integer-allocation.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +value=354 +expected="Integer cell: value ${value}" +echo ${value} | target/psse 2>&1 | grep "${expected}" > /dev/null + +if [ $? -eq 0 ] +then + echo "OK" + exit 0 +else + echo "Expected '${expected}', not found" + exit 1 +fi diff --git a/unit-tests/integer.sh b/unit-tests/integer.sh new file mode 100644 index 0000000..e2d41f1 --- /dev/null +++ b/unit-tests/integer.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +expected="354" +actual=`echo ${expected} | target/psse 2> /dev/null` + +if [ "${expected}" = "${actual}" ] +then + echo "OK" + exit 0 +else + echo "Expected '${expected}', got '${actual}'" + exit 1 +fi diff --git a/unit-tests/nil.sh b/unit-tests/nil.sh index 249c51b..0ecd516 100644 --- a/unit-tests/nil.sh +++ b/unit-tests/nil.sh @@ -8,6 +8,6 @@ then echo "OK" exit 0 else - echo "Expected '${expected}', got '${actual}'" + echo "Fail: expected '${expected}', got '${actual}'" exit 1 fi diff --git a/unit-tests/simple-list.sh b/unit-tests/simple-list.sh new file mode 100644 index 0000000..9ee9719 --- /dev/null +++ b/unit-tests/simple-list.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +expected="(1 2 3)" +actual=`echo '(1 2 3)' | target/psse 2> /dev/null` + +if [ "${expected}" = "${actual}" ] +then + echo "OK" + exit 0 +else + echo "Fail: expected '${expected}', got '${actual}'" + exit 1 +fi diff --git a/unit-tests/string-with-spaces.sh b/unit-tests/string-with-spaces.sh new file mode 100644 index 0000000..ee5612f --- /dev/null +++ b/unit-tests/string-with-spaces.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +expected="\"Strings should be able to include spaces (and other stuff)!\"" +actual=`echo ${expected} | target/psse 2> /dev/null` + +if [ "${expected}" = "{$actual}" ] +then + echo "OK" + exit 0 +else + echo "Fail: expected '$expected', got '$actual'" + exit 1 +fi