Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 54 lines (41 sloc) 1.597 kb
84f6bd5 [t/spec] Tests for .parse and .parsefile on Grammar objects.
jnthn authored
1 use v6;
2 use Test;
3
d2482f4 replace plan *; with number of tests S03-S06
mberends authored
4 plan 11;
84f6bd5 [t/spec] Tests for .parse and .parsefile on Grammar objects.
jnthn authored
5
6 # tests .parse and .parsefile methods on a grammar
7
8 grammar Foo {
9 token TOP { \d+ };
10 };
11 grammar Bar {
12 token untop { \d+ }
13 }
14
0cff866 [t/spec] bring parse_and_parsefile.t up to date
bubaflub authored
15 nok(~Foo.parse("abc123xyz"), ".parse method invokes TOP rule, no match");
16 is(~Foo.parse("123"), "123", ".parse method invokes TOP rule, match");
84f6bd5 [t/spec] Tests for .parse and .parsefile on Grammar objects.
jnthn authored
17 dies_ok({ Bar.parse("abc123xyz") }, "dies if no TOP rule");
18
19 my $fh = open("parse_and_parsefile_test", :w);
20 $fh.say("abc\n123\nxyz");
21 $fh.close();
d69e5a8 @coke niecza fudging
coke authored
22 #?niecza skip 'Unable to resolve method parsefile in class Foo'
0cff866 [t/spec] bring parse_and_parsefile.t up to date
bubaflub authored
23 nok(~Foo.parsefile("parse_and_parsefile_test"), ".parsefile method invokes TOP rule, no match");
24 unlink("parse_and_parsefile_test");
25
26 $fh = open("parse_and_parsefile_test", :w);
27 $fh.say("123");
28 $fh.close();
d69e5a8 @coke niecza fudging
coke authored
29 #?niecza skip 'Unable to resolve method parsefile in class Foo'
0cff866 [t/spec] bring parse_and_parsefile.t up to date
bubaflub authored
30 is(~Foo.parsefile("parse_and_parsefile_test"), "123", ".parsefile method invokes TOP rule, match");
84f6bd5 [t/spec] Tests for .parse and .parsefile on Grammar objects.
jnthn authored
31 dies_ok({ Bar.parsefile("parse_and_parsefile_test") }, "dies if no TOP rule");
13cc9c4 [t/spec] 71 typos in 32 files.
Util authored
32 dies_ok({ Foo.parsefile("non_existent_file") }, "dies if file not found");
0cff866 [t/spec] bring parse_and_parsefile.t up to date
bubaflub authored
33
84f6bd5 [t/spec] Tests for .parse and .parsefile on Grammar objects.
jnthn authored
34 unlink("parse_and_parsefile_test");
2037ad6 [t/spec] Test for .parse on namespaced grammar.
jnthn authored
35
36 grammar A::B {
37 token TOP { \d+ }
38 }
0cff866 [t/spec] bring parse_and_parsefile.t up to date
bubaflub authored
39 nok(~A::B.parse("zzz42zzz"), ".parse works with namespaced grammars, no match");
40 is(~A::B.parse("42"), "42", ".parse works with namespaced grammars, match");
1224731 [t/spec] Test for RT #63460
kyle authored
41
22ba10f [t/spec] Adjust a couple todo tests that were passing
kyle authored
42 # TODO: Check for a good error message, not just the absence of a bad one.
84330f5 @moritz correct and unfudge parse_and_parsefile.t
moritz authored
43 eval_dies_ok '::No::Such::Grammar.parse()', '.parse on missing grammar dies';
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
44
4bebd53 [t/spec] Test for RT 71062: dies calling grammar named "Integer"
kyle authored
45 # RT #71062
46 {
47 grammar Integer { rule TOP { x } };
48 lives_ok { Integer.parse('x') }, 'can .parse grammar named "Integer"';
49 }
50
e76dd4c @moritz s/done_testing/done/ as per recent S24 changes
moritz authored
51 done;
4bebd53 [t/spec] Test for RT 71062: dies calling grammar named "Integer"
kyle authored
52
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
53 # vim: ft=perl6
Something went wrong with that request. Please try again.