Permalink
Browse files

Merge back test2

  • Loading branch information...
1 parent 2c25f13 commit 3320d057e9ec2c356092e8fc92731e7036ee4483 @sorear committed Jan 15, 2011
Showing with 98 additions and 108 deletions.
  1. +8 −0 t/fileops.t
  2. +90 −1 test.pl
  3. +0 −88 test2.pl
  4. +0 −19 test3.pl
View
@@ -0,0 +1,8 @@
+# This is separated out since it's inherently platform specific
+# and will only work properly on Unix
+
+use Test;
+
+is "/bin/..".IO.realpath, "/", "realpath chases ..";
+is "/bin".IO.append("sh"), "/bin/sh", "append adds /";
+is "/bin/".IO.append("sh"), "/bin/sh", "but only if needed";
View
91 test.pl
@@ -2,7 +2,7 @@
use Test;
-plan 709;
+plan 731;
ok 1, "one is true";
ok 2, "two is also true";
@@ -1503,3 +1503,92 @@
}
is $false_branch,0,"a branch of an if with a false condition doesn't get called";
}
+
+{
+ my $str;
+ INIT $str = '';
+ $str ~= 1;
+ INIT $str ~= 2;
+ $str ~= 3;
+ INIT $str ~= 4;
+ is $str, '2413', 'INIT blocks run in correct order';
+}
+
+{
+ my class X3 {
+ has $.a;
+ }
+ my $x = X3.new(a => 5);
+ is $x.a, 5, 'Attribute values can be passed in constructors';
+
+ sub foo($/) { $<a> }
+ is foo({ a => 5 }), 5, 'Can bind $/ in signature';
+
+ my class X4 {
+ method foo { 13 }
+ method !bar { 17 }
+ method sam($x) { self!"$x"() }
+ }
+
+ is X4."foo"(), 13, 'indirect method calls work'; #OK
+ is X4."{ "fo" ~ "o" }"(), 13, 'indirect calls work with interpolation';
+ is X4.sam("bar"), 17, "indirect private method calls work";
+}
+
+{
+ "foo" ~~ /oo/;
+ is $/.ast, 'oo', '.ast defaults to .Str';
+ "foo" ~~ /oo { make 15 }/;
+ is $/.ast, 15, 'make can change .ast';
+ "foo" ~~ /{make 30} oo/;
+ is $/.ast, 30, 'make works in the middle';
+
+ my grammar X5 {
+ proto token TOP {*}
+ token TOP:x { foo { make 45 } }
+ }
+ is X5.parse("foo").ast, 45, 'make works in multiregexes';
+}
+
+{
+ my grammar X6 {
+ token a { <?> }
+ proto token b {*}
+ token b:x { <?> }
+ proto token c {*}
+ token c:x { <?> }
+ }
+
+ my class A6 {
+ method a($/) { make 1 }
+ method b($/) { make 2 }
+ method c:x ($/) { make 3 }
+ }
+
+ is X6.parse("", :actions(A6), :rule<a>).ast, 1,
+ 'action methods work (simple rule)';
+ #is X6.parse("", :actions(A6), :rule<b>).ast, 2,
+ # 'action methods work (proto rule)';
+ is X6.parse("", :actions(A6), :rule<c>).ast, 3,
+ 'action methods work (candidate rule)';
+}
+
+{
+ my @foo = 1; #OK
+ my $tgt; #OK
+ my %into;
+ $tgt = %into<foo> = True;
+ ok %into<foo>, "2011-01-13 list assignment parsefail";
+}
+
+{
+ is +"12" - 5, 7, "Str.Numeric works";
+ is 6 +& 3, 2, "+& works";
+ is 6 +^ 3, 5, "+^ works";
+ is 6 +| 3, 7, "+| works";
+ is 6 +< 3, 48, "+< works";
+ is 6 +> 1, 3, "+> works";
+ is +^6, -7, "+^ works";
+ is ord('0'), 48, "ord works";
+ is chr(65), 'A', "chr works";
+}
View
@@ -2,94 +2,6 @@
use Test;
use MONKEY_TYPING;
-{
- my $str;
- INIT $str = '';
- $str ~= 1;
- INIT $str ~= 2;
- $str ~= 3;
- INIT $str ~= 4;
- is $str, '2413', 'INIT blocks run in correct order';
-}
-
-{
- my class X3 {
- has $.a;
- }
- my $x = X3.new(a => 5);
- is $x.a, 5, 'Attribute values can be passed in constructors';
-
- sub foo($/) { $<a> }
- is foo({ a => 5 }), 5, 'Can bind $/ in signature';
-
- my class X4 {
- method foo { 13 }
- method !bar { 17 }
- method sam($x) { self!"$x"() }
- }
-
- is X4."foo"(), 13, 'indirect method calls work'; #OK
- is X4."{ "fo" ~ "o" }"(), 13, 'indirect calls work with interpolation';
- is X4.sam("bar"), 17, "indirect private method calls work";
-}
-
-{
- "foo" ~~ /oo/;
- is $/.ast, 'oo', '.ast defaults to .Str';
- "foo" ~~ /oo { make 15 }/;
- is $/.ast, 15, 'make can change .ast';
- "foo" ~~ /{make 30} oo/;
- is $/.ast, 30, 'make works in the middle';
-
- my grammar X5 {
- proto token TOP {*}
- token TOP:x { foo { make 45 } }
- }
- is X5.parse("foo").ast, 45, 'make works in multiregexes';
-}
-
-{
- my grammar X6 {
- token a { <?> }
- proto token b {*}
- token b:x { <?> }
- proto token c {*}
- token c:x { <?> }
- }
-
- my class A6 {
- method a($/) { make 1 }
- method b($/) { make 2 }
- method c:x ($/) { make 3 }
- }
-
- is X6.parse("", :actions(A6), :rule<a>).ast, 1,
- 'action methods work (simple rule)';
- #is X6.parse("", :actions(A6), :rule<b>).ast, 2,
- # 'action methods work (proto rule)';
- is X6.parse("", :actions(A6), :rule<c>).ast, 3,
- 'action methods work (candidate rule)';
-}
-
-{
- my @foo = 1; #OK
- my $tgt; #OK
- my %into;
- $tgt = %into<foo> = True;
- ok %into<foo>, "2011-01-13 list assignment parsefail";
-}
-
-{
- is +"12" - 5, 7, "Str.Numeric works";
- is 6 +& 3, 2, "+& works";
- is 6 +^ 3, 5, "+^ works";
- is 6 +| 3, 7, "+| works";
- is 6 +< 3, 48, "+< works";
- is 6 +> 1, 3, "+> works";
- is +^6, -7, "+^ works";
- is ord('0'), 48, "ord works";
- is chr(65), 'A', "chr works";
-}
#is $?FILE, 'test.pl', '$?FILE works';
#is $?ORIG.substr(0,5), '# vim', '$?ORIG works';
View
@@ -1,19 +0,0 @@
-# vim: ft=perl6
-use MONKEY_TYPING;
-
-grammar G {
-token ws {
- [
- | \h+ <![\#\s\\]> { }
- | <?before \w> <?after \w> :::
- { }
- <.sorry: "Whitespace is required between alphanumeric tokens"> # must \s+ between words
- ]
- ||
- [
- | <.unsp>
- | <.vws> <.heredoc>
- | <.unv>
- ]*
-}
-}

0 comments on commit 3320d05

Please sign in to comment.