Differences From Artifact [e43d60d2bdfc662b]:
- File
polemy/lex.d
- 2010-11-07 15:03:38 - part of checkin [820e7198cc] on branch trunk - Made helloworld work. (user: kinaba) [annotate]
To Artifact [783ee3b0fe58558e]:
- File
polemy/lex.d
- 2010-11-08 06:19:57 - part of checkin [61998c472a] on branch trunk - Introduced unittest helpers (assert_eq, assert_throw, etc). Mmigration to it is not done yet. (user: kinaba) [annotate]
27 27 }
28 28
29 29 unittest
30 30 {
31 31 auto p = new LexPosition("hello.cpp", 123, 45);
32 32 auto q = new LexPosition("hello.cpp", 123, 46);
33 33
34 - assert( p.filename == "hello.cpp" );
35 - assert( p.lineno == 123 );
36 - assert( p.column == 45 );
37 - assert( to!string(p) == "hello.cpp:123:45" );
38 - assert( p < q );
39 - assert( p != q );
34 + assert_eq( p.filename, "hello.cpp" );
35 + assert_eq( p.lineno, 123 );
36 + assert_eq( p.column, 45 );
37 + assert_eq( to!string(p), "hello.cpp:123:45" );
38 + assert_lt( p, q );
39 + assert_ne( p, q );
40 40
41 41 assert( !__traits(compiles, new LexPosition) );
42 42 assert( !__traits(compiles, p.filename="foo") );
43 43 assert( !__traits(compiles, p.lineno =789) );
44 44 assert( !__traits(compiles, p.column =222) );
45 45 }
46 46
................................................................................
63 63 }
64 64
65 65 unittest
66 66 {
67 67 auto p = new immutable(LexPosition)("hello.cpp", 123, 45);
68 68 auto t = new Token(p, "class", Token.Kind.identifier);
69 69
70 - assert( t.pos == p );
71 - assert( t.str == "class" );
72 - assert( t == new Token(p, "class", Token.Kind.identifier) );
73 - assert( t < new Token(p, "struct", Token.Kind.identifier) );
70 + assert_eq( t.pos, p );
71 + assert_eq( t.str, "class" );
72 + assert_eq( t, new Token(p, "class", Token.Kind.identifier) );
73 + assert_lt( t, new Token(p, "struct", Token.Kind.identifier) );
74 74
75 75 assert( !__traits(compiles, new Token) );
76 76 assert( !__traits(compiles, t.pos=p) );
77 77 assert( !__traits(compiles, t.str=789) );
78 78 }
79 79
80 80 /// Named Construtor for Lexer