Permalink
Browse files

new style test cases

  • Loading branch information...
1 parent 9a263db commit e352ca32f364ef7ed15ae47e61974abb2aa238a3 @tokuhirom committed Apr 17, 2012
Showing with 380 additions and 213 deletions.
  1. +1 −1 SConstruct
  2. +1 −1 t/Util.pm
  3. +0 −15 t/array.t
  4. +0 −146 t/basic.t
  5. +1 −1 t/class.t
  6. +3 −3 t/comment.t
  7. +2 −2 t/conditional_expresion.t
  8. +1 −1 t/do.t
  9. +1 −1 t/end.t
  10. +2 −2 t/eval.t
  11. +5 −5 t/exception.t
  12. +6 −6 t/foreach.t
  13. +9 −9 t/func.t
  14. +2 −2 t/getenv.t
  15. +2 −2 t/hello.t
  16. +6 −6 t/if.t
  17. +1 −1 t/lineno.t
  18. +1 −1 t/printf.t
  19. +4 −4 t/semicolon.t
  20. +12 −0 t/spec/basic/array.tcc
  21. +222 −0 t/spec/basic/basic.tcc
  22. +1 −1 t/string.t
  23. +3 −3 t/vars.t
  24. +71 −0 util/TAP/Parser/SourceHandler/TCC.pm
  25. +23 −0 util/run_tcc
View
@@ -196,7 +196,7 @@ if os.name == 'nt':
else:
prove_command = prove_prefix + ' ' + prove_path
if 'test' in COMMAND_LINE_TARGETS:
- env.Command('test', programs, prove_command + ' --source Tora --source Executable -r tests/ t/tra/*.tra t/tra/*/*.tra --source Perl t')
+ env.Command('test', programs, prove_command + ' --source TCC --source Tora --source Executable -r tests/ t/tra/*.tra t/tra/*/*.tra t/spec/*/*.tcc --source Perl t')
env.Command('test.valgrind', ['bin/tora' + exe_suffix], 'perl misc/valgrind.pl');
View
@@ -12,7 +12,7 @@ sub import {
strict->import;
warnings->import;
no strict 'refs';
- *{caller(0) . "::run_is"} = sub {
+ *{caller(0) . "::run_tora_is"} = sub {
note("L: " . (caller(0))[2]);
my ($code, $out_expected, $err_expected, $exit_status) = @_;
$exit_status ||= 0;
View
@@ -1,15 +0,0 @@
-use strict;
-use warnings;
-use utf8;
-use Test::More;
-use t::Util;
-
-run_is(<<'...', "1\n2\n3\n");
-my ($a, $b, $c) = *[1,2,3];
-say($a);
-say($b);
-say($c);
-...
-
-done_testing;
-
View
146 t/basic.t
@@ -1,146 +0,0 @@
-use t::Util;
-
-run_is(<<'...', "3\n");
-say(1+2);
-...
-
-run_is(<<'...', "5\n");
-say(7-2);
-...
-
-run_is(<<'...', "HELLO\n");
-print("HELLO\n");
-...
-
-run_is(<<'...', 'HELLO\t\n');
-print('HELLO\t\n');
-...
-
-run_is(<<'...', "14\n");
-say(7*2);
-...
-
-run_is(<<'...', "2\n");
-say(4/2);
-...
-
-run_is(<<'...', "yo\nho\n");
-say("yo");
-say("ho");
-...
-
-run_is(<<'...', "true\nfalse\n");
-say(true);
-say(false);
-...
-
-run_is('', "");
-
-run_is(<<'...', "OK\nHERE\n");
-if (true) {
- say("OK");
-}
-say("HERE");
-...
-
-run_is(<<'...', "HERE\n");
-if (false) {
- say("NOT OK");
-}
-say("HERE");
-...
-
-run_is(<<'...', "true\nfalse\n");
-say(1==1);
-say(1==2);
-...
-
-my $src = <<'...';
-say(4<5);
-say(4<1);
-say(4<4);
-
-say(4>5);
-say(4>1);
-say(4>4);
-
-say(4>=5);
-say(4>=1);
-say(4>=4);
-
-say(4<=5);
-say(4<=1);
-say(4<=4);
-...
-run_is($src , join("\n", qw(
- true false false
- false true false
- false true true
- true false true
-)). "\n");
-
-run_is(<<'...', "5\n");
-my $x=5;
-say($x);
-...
-
-run_is(<<'...', "7\n");
-my $x=3;
-my $y=4;
-say($x+$y);
-...
-
-run_is(<<'...', "5\n");
-my $x=2;
-$x=$x+3;
-say($x);
-...
-
-run_is(<<'...', "0\n1\n2\n");
-my $i=0;
-while ($i<3) {
- say($i);
- $i = $i + 1;
-}
-...
-
-run_is(<<'...', "5\n");
-my $x = 10;
-$x/= 2;
-say($x);
-...
-
-run_is(<<'...', "0\n1\n2\n");
-my $i=0;
-while ($i<3) {
- say($i);
- ++$i;
-}
-...
-
-run_is(<<'...', "0..10\n");
-say(0..10);
-...
-
-run_is(<<'...', "1\n");
-my $a;
-$a = 1;
-say($a);
-...
-
-run_is(<<'...', "OK\nHERE\n");
-if (true) { say("OK"); }
-say("HERE");
-...
-
-run_is(<<'...', "Str\nHash\n");
-say(typeof("hoge"));
-say(typeof({}));
-...
-
-run_is(<<'...', "4\n");
-say(1+"3");
-...
-
-done_testing;
-
View
@@ -4,7 +4,7 @@ use utf8;
use Test::More;
use t::Util;
-run_is(<<'...', "Hello world!: HOGE\n");
+run_tora_is(<<'...', "Hello world!: HOGE\n");
class Hello {
sub new() {
self.bless(undef);
View
@@ -1,16 +1,16 @@
use t::Util;
-run_is(<<'...', "Hello, world\n");
+run_tora_is(<<'...', "Hello, world\n");
say("Hello, world");
...
-run_is(<<'...', "Hello, world\n");
+run_tora_is(<<'...', "Hello, world\n");
/* comment
comment2 */
say("Hello, world");
...
-run_is(<<'...', "Hello, world\n");
+run_tora_is(<<'...', "Hello, world\n");
#! comment
say("Hello, world");
...
@@ -4,8 +4,8 @@ use utf8;
use Test::More;
use t::Util;
-run_is('print(true ? 1 : 2);', "1");
-run_is('print(false ? 1 : 2);', "2");
+run_tora_is('print(true ? 1 : 2);', "1");
+run_tora_is('print(false ? 1 : 2);', "2");
done_testing;
View
2 t/do.t
@@ -4,7 +4,7 @@ use utf8;
use Test::More;
use t::Util;
-run_is('say(do("eg/3.tra"));', "3\n");
+run_tora_is('say(do("eg/3.tra"));', "3\n");
done_testing;
View
@@ -4,7 +4,7 @@ use utf8;
use Test::More;
use t::Util;
-run_is(<<'...', "hello\n");
+run_tora_is(<<'...', "hello\n");
say("hello");
__END__
say("YO");
View
@@ -4,8 +4,8 @@ use utf8;
use Test::More;
use t::Util;
-run_is(q{eval("say(3+2)");}, "5\n");
-run_is(q{say(eval("3+2"));}, "5\n");
+run_tora_is(q{eval("say(3+2)");}, "5\n");
+run_tora_is(q{say(eval("3+2"));}, "5\n");
done_testing;
View
@@ -1,18 +1,18 @@
use t::Util;
-run_is(<<'...', "undef\n3\n");
+run_tora_is(<<'...', "undef\n3\n");
my ($e, $x) = try { return 3; };
say($e);
say($x);
...
-run_is(<<'...', "4\nundef\n");
+run_tora_is(<<'...', "4\nundef\n");
my ($e, $x) = try { die 4; return 3; };
say($e);
say($x);
...
-run_is(<<'...', "REACH HERE\nOK!\nundef\n");
+run_tora_is(<<'...', "REACH HERE\nOK!\nundef\n");
sub foo() {
say("REACH HERE");
die "OK!";
@@ -26,12 +26,12 @@ say($e);
say($x);
...
-run_is(<<'...', '', qq{'hoge' is not numeric. You cannot divide. line 2\n}, 1);
+run_tora_is(<<'...', '', qq{'hoge' is not numeric. You cannot divide. line 2\n}, 1);
my $x = "hoge";
say($x/"fuga");
...
-run_is(<<'...', '', qq{Unknown function 'foo' line 2.\n}, 1);
+run_tora_is(<<'...', '', qq{Unknown function 'foo' line 2.\n}, 1);
foo();
...
View
@@ -4,21 +4,21 @@ use utf8;
use Test::More;
use t::Util;
-run_is(<<'...', "1\n3\nOK\n");
+run_tora_is(<<'...', "1\n3\nOK\n");
for [1,3] -> $i {
say($i);
}
say("OK");
...
-run_is('for [1,3] -> $k { say($k) }', "1\n3\n");
+run_tora_is('for [1,3] -> $k { say($k) }', "1\n3\n");
-run_is('for 1..3 -> $k { say($k) }', "1\n2\n3\n");
+run_tora_is('for 1..3 -> $k { say($k) }', "1\n2\n3\n");
-run_is('for 1..3 -> $k { }', "");
-run_is('for (my $i=0; $i<10; $i++) { }', "");
+run_tora_is('for 1..3 -> $k { }', "");
+run_tora_is('for (my $i=0; $i<10; $i++) { }', "");
-run_is('my $k; my $v; for {"A" => 3, "B" => 4} -> $k, $v { say($k); say($v); }', "A\n3\nB\n4\n");
+run_tora_is('my $k; my $v; for {"A" => 3, "B" => 4} -> $k, $v { say($k); say($v); }', "A\n3\nB\n4\n");
done_testing;
View
@@ -1,14 +1,14 @@
use t::Util;
-run_is(<<'...', "YO!\n");
+run_tora_is(<<'...', "YO!\n");
sub foo($n) {
say("YO!");
}
foo(3);
...
-run_is(<<'...', "3\n");
+run_tora_is(<<'...', "3\n");
sub foo($n) {
say($n);
}
@@ -17,7 +17,7 @@ foo(3);
...
# no args.
-run_is(<<'...', "a\n");
+run_tora_is(<<'...', "a\n");
sub foo() {
say("a");
}
@@ -26,7 +26,7 @@ foo();
...
# retval
-run_is(<<'...', "123\n");
+run_tora_is(<<'...', "123\n");
sub foo() {
return 123;
}
@@ -35,23 +35,23 @@ say(foo());
...
# retval(undef)
-run_is(<<'...', "undef\n");
+run_tora_is(<<'...', "undef\n");
sub foo() {
}
say(foo());
...
# retval(undef)
-run_is(<<'...', "undef\n");
+run_tora_is(<<'...', "undef\n");
sub foo($n) {
}
say(foo(5));
...
# return multiple
-run_is(<<'...', "1\n2\n3\n");
+run_tora_is(<<'...', "1\n2\n3\n");
sub foo() {
return 1,2,3;
}
@@ -60,7 +60,7 @@ say(foo());
...
# return multiple, and assign
-run_is(<<'...', "3\n2\n1\n");
+run_tora_is(<<'...', "3\n2\n1\n");
sub foo() {
return 1,2,3;
}
@@ -71,7 +71,7 @@ say($c, $b, $a);
...
# return multiple, and assign to array
-run_is(<<'...', "undef\n3\nundef\n1\n2\n");
+run_tora_is(<<'...', "undef\n3\nundef\n1\n2\n");
sub foo() {
return 1,2,3;
}
Oops, something went wrong.

0 comments on commit e352ca3

Please sign in to comment.