test/test_parse.rb in cast-0.0.1 vs test/test_parse.rb in cast-0.1.0

- old
+ new

@@ -4,12 +4,10 @@ ### Tests for the parse methods. ### ### ################################################################## ### -require 'common' - class MatchTest < Test::Unit::TestCase def setup C.default_parser = C::Parser.new end def test_node_matches @@ -77,11 +75,10 @@ assert_same(true, t.match?(['T'])) end end class ParseTests < Test::Unit::TestCase - include CheckAst def check klass, s check_ast(s){|inp| klass.parse(inp)} end def test_translation_unit @@ -106,11 +103,11 @@ - Parameter type: Pointer type: Void name: "f" EOS - assert_raise(ParseError){C::TranslationUnit.parse('')} + assert_raise(C::ParseError){C::TranslationUnit.parse('')} end def test_declaration check C::Declaration, <<EOS int i; @@ -130,13 +127,13 @@ - Declarator name: "i" - Declarator name: "j" EOS - assert_raise(ParseError){C::Declaration.parse('int i; int j;')} - assert_raise(ParseError){C::Declaration.parse('int f() {}')} - assert_raise(ParseError){C::Declaration.parse('')} + assert_raise(C::ParseError){C::Declaration.parse('int i; int j;')} + assert_raise(C::ParseError){C::Declaration.parse('int f() {}')} + assert_raise(C::ParseError){C::Declaration.parse('')} end def test_parameter check C::Parameter, <<EOS int i @@ -161,16 +158,16 @@ void ---- Parameter type: Void EOS - assert_raise(ParseError){C::Parameter.parse('...')} - assert_raise(ParseError){C::Parameter.parse(') {} void (')} - assert_raise(ParseError){C::Parameter.parse('); void(')} - assert_raise(ParseError){C::Parameter.parse('i,j')} - assert_raise(ParseError){C::Parameter.parse('int,float')} - assert_raise(ParseError){C::Parameter.parse('')} + assert_raise(C::ParseError){C::Parameter.parse('...')} + assert_raise(C::ParseError){C::Parameter.parse(') {} void (')} + assert_raise(C::ParseError){C::Parameter.parse('); void(')} + assert_raise(C::ParseError){C::Parameter.parse('i,j')} + assert_raise(C::ParseError){C::Parameter.parse('int,float')} + assert_raise(C::ParseError){C::Parameter.parse('')} end def test_declarator check C::Declarator, <<EOS x @@ -209,14 +206,14 @@ type: Pointer type: Char name: "argv" name: "x" EOS - assert_raise(ParseError){C::Declarator.parse('f; int f;')} - assert_raise(ParseError){C::Declarator.parse('i,j')} - assert_raise(ParseError){C::Declarator.parse(';')} - assert_raise(ParseError){C::Declarator.parse('')} + assert_raise(C::ParseError){C::Declarator.parse('f; int f;')} + assert_raise(C::ParseError){C::Declarator.parse('i,j')} + assert_raise(C::ParseError){C::Declarator.parse(';')} + assert_raise(C::ParseError){C::Declarator.parse('')} end def test_function_def check C::FunctionDef, <<EOS int f() {} @@ -237,15 +234,15 @@ - Parameter type: Pointer type: Void name: "f" EOS - assert_raise(ParseError){C::FunctionDef.parse('void f(); void g();')} - assert_raise(ParseError){C::FunctionDef.parse('int i;')} - assert_raise(ParseError){C::FunctionDef.parse('void f();')} - assert_raise(ParseError){C::FunctionDef.parse(';')} - assert_raise(ParseError){C::FunctionDef.parse('')} + assert_raise(C::ParseError){C::FunctionDef.parse('void f(); void g();')} + assert_raise(C::ParseError){C::FunctionDef.parse('int i;')} + assert_raise(C::ParseError){C::FunctionDef.parse('void f();')} + assert_raise(C::ParseError){C::FunctionDef.parse(';')} + assert_raise(C::ParseError){C::FunctionDef.parse('')} end def test_enumerator check C::Enumerator, <<EOS X @@ -259,14 +256,14 @@ Enumerator name: "X" val: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Enumerator.parse('} enum {')} - assert_raise(ParseError){C::Enumerator.parse('} f() {')} - assert_raise(ParseError){C::Enumerator.parse('X, Y')} - assert_raise(ParseError){C::Enumerator.parse('')} + assert_raise(C::ParseError){C::Enumerator.parse('} enum {')} + assert_raise(C::ParseError){C::Enumerator.parse('} f() {')} + assert_raise(C::ParseError){C::Enumerator.parse('X, Y')} + assert_raise(C::ParseError){C::Enumerator.parse('')} end def test_member_initializer check C::MemberInit, <<EOS 1 @@ -309,16 +306,16 @@ - IntLiteral val: 5 init: FloatLiteral val: 10.0 EOS - assert_raise(ParseError){C::MemberInit.parse('} int f() {')} - assert_raise(ParseError){C::MemberInit.parse('}} f() {{')} - assert_raise(ParseError){C::MemberInit.parse('1}; x = {1')} - assert_raise(ParseError){C::MemberInit.parse('1}, y')} - assert_raise(ParseError){C::MemberInit.parse('1, 2')} - assert_raise(ParseError){C::MemberInit.parse('')} + assert_raise(C::ParseError){C::MemberInit.parse('} int f() {')} + assert_raise(C::ParseError){C::MemberInit.parse('}} f() {{')} + assert_raise(C::ParseError){C::MemberInit.parse('1}; x = {1')} + assert_raise(C::ParseError){C::MemberInit.parse('1}, y')} + assert_raise(C::ParseError){C::MemberInit.parse('1, 2')} + assert_raise(C::ParseError){C::MemberInit.parse('')} end def test_block check C::Block, <<EOS {} @@ -330,15 +327,15 @@ ---- Block stmts: - Block EOS - assert_raise(ParseError){C::Block.parse('} void f() {')} - assert_raise(ParseError){C::Block.parse(';;')} - assert_raise(ParseError){C::Block.parse('int i;')} - assert_raise(ParseError){C::Block.parse(';')} - assert_raise(ParseError){C::Block.parse('')} + assert_raise(C::ParseError){C::Block.parse('} void f() {')} + assert_raise(C::ParseError){C::Block.parse(';;')} + assert_raise(C::ParseError){C::Block.parse('int i;')} + assert_raise(C::ParseError){C::Block.parse(';')} + assert_raise(C::ParseError){C::Block.parse('')} end def test_if check C::If, <<EOS if (1) 10; @@ -361,15 +358,15 @@ val: 10 else: ExpressionStatement expr: IntLiteral val: 20 EOS - assert_raise(ParseError){C::If.parse('} void f() {')} - assert_raise(ParseError){C::If.parse(';;')} - assert_raise(ParseError){C::If.parse('int i;')} - assert_raise(ParseError){C::If.parse(';')} - assert_raise(ParseError){C::If.parse('')} + assert_raise(C::ParseError){C::If.parse('} void f() {')} + assert_raise(C::ParseError){C::If.parse(';;')} + assert_raise(C::ParseError){C::If.parse('int i;')} + assert_raise(C::ParseError){C::If.parse(';')} + assert_raise(C::ParseError){C::If.parse('')} end def test_switch check C::Switch, <<EOS switch (x); @@ -377,15 +374,15 @@ Switch cond: Variable name: "x" stmt: ExpressionStatement EOS - assert_raise(ParseError){C::Switch.parse('} void f() {')} - assert_raise(ParseError){C::Switch.parse(';;')} - assert_raise(ParseError){C::Switch.parse('int i;')} - assert_raise(ParseError){C::Switch.parse(';')} - assert_raise(ParseError){C::Switch.parse('')} + assert_raise(C::ParseError){C::Switch.parse('} void f() {')} + assert_raise(C::ParseError){C::Switch.parse(';;')} + assert_raise(C::ParseError){C::Switch.parse('int i;')} + assert_raise(C::ParseError){C::Switch.parse(';')} + assert_raise(C::ParseError){C::Switch.parse('')} end def test_while check C::While, <<EOS while (1); @@ -401,15 +398,15 @@ While (do) cond: IntLiteral val: 1 stmt: ExpressionStatement EOS - assert_raise(ParseError){C::While.parse('} void f() {')} - assert_raise(ParseError){C::While.parse(';;')} - assert_raise(ParseError){C::While.parse('int i;')} - assert_raise(ParseError){C::While.parse(';')} - assert_raise(ParseError){C::While.parse('')} + assert_raise(C::ParseError){C::While.parse('} void f() {')} + assert_raise(C::ParseError){C::While.parse(';;')} + assert_raise(C::ParseError){C::While.parse('int i;')} + assert_raise(C::ParseError){C::While.parse(';')} + assert_raise(C::ParseError){C::While.parse('')} end def test_for check C::For, <<EOS for (;;); @@ -426,55 +423,55 @@ declarators: - Declarator name: "i" stmt: ExpressionStatement EOS - assert_raise(ParseError){C::For.parse('} void f() {')} - assert_raise(ParseError){C::For.parse(';;')} - assert_raise(ParseError){C::For.parse('int i;')} - assert_raise(ParseError){C::For.parse(';')} - assert_raise(ParseError){C::For.parse('')} + assert_raise(C::ParseError){C::For.parse('} void f() {')} + assert_raise(C::ParseError){C::For.parse(';;')} + assert_raise(C::ParseError){C::For.parse('int i;')} + assert_raise(C::ParseError){C::For.parse(';')} + assert_raise(C::ParseError){C::For.parse('')} end def test_goto check C::Goto, <<EOS goto x; ---- Goto target: "x" EOS - assert_raise(ParseError){C::Goto.parse('} void f() {')} - assert_raise(ParseError){C::Goto.parse(';;')} - assert_raise(ParseError){C::Goto.parse('int i;')} - assert_raise(ParseError){C::Goto.parse(';')} - assert_raise(ParseError){C::Goto.parse('')} + assert_raise(C::ParseError){C::Goto.parse('} void f() {')} + assert_raise(C::ParseError){C::Goto.parse(';;')} + assert_raise(C::ParseError){C::Goto.parse('int i;')} + assert_raise(C::ParseError){C::Goto.parse(';')} + assert_raise(C::ParseError){C::Goto.parse('')} end def test_continue check C::Continue, <<EOS continue; ---- Continue EOS - assert_raise(ParseError){C::Continue.parse('} void f() {')} - assert_raise(ParseError){C::Continue.parse(';;')} - assert_raise(ParseError){C::Continue.parse('int i;')} - assert_raise(ParseError){C::Continue.parse(';')} - assert_raise(ParseError){C::Continue.parse('')} + assert_raise(C::ParseError){C::Continue.parse('} void f() {')} + assert_raise(C::ParseError){C::Continue.parse(';;')} + assert_raise(C::ParseError){C::Continue.parse('int i;')} + assert_raise(C::ParseError){C::Continue.parse(';')} + assert_raise(C::ParseError){C::Continue.parse('')} end def test_break check C::Break, <<EOS break; ---- Break EOS - assert_raise(ParseError){C::Break.parse('} void f() {')} - assert_raise(ParseError){C::Break.parse(';;')} - assert_raise(ParseError){C::Break.parse('int i;')} - assert_raise(ParseError){C::Break.parse(';')} - assert_raise(ParseError){C::Break.parse('')} + assert_raise(C::ParseError){C::Break.parse('} void f() {')} + assert_raise(C::ParseError){C::Break.parse(';;')} + assert_raise(C::ParseError){C::Break.parse('int i;')} + assert_raise(C::ParseError){C::Break.parse(';')} + assert_raise(C::ParseError){C::Break.parse('')} end def test_return check C::Return, <<EOS return; @@ -486,15 +483,15 @@ ---- Return expr: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Return.parse('} void f() {')} - assert_raise(ParseError){C::Return.parse(';;')} - assert_raise(ParseError){C::Return.parse('int i;')} - assert_raise(ParseError){C::Return.parse(';')} - assert_raise(ParseError){C::Return.parse('')} + assert_raise(C::ParseError){C::Return.parse('} void f() {')} + assert_raise(C::ParseError){C::Return.parse(';;')} + assert_raise(C::ParseError){C::Return.parse('int i;')} + assert_raise(C::ParseError){C::Return.parse(';')} + assert_raise(C::ParseError){C::Return.parse('')} end def test_expression_statement check C::ExpressionStatement, <<EOS ; @@ -506,15 +503,15 @@ ---- ExpressionStatement expr: IntLiteral val: 10 EOS - assert_raise(ParseError){C::ExpressionStatement.parse('} void f() {')} - assert_raise(ParseError){C::ExpressionStatement.parse(';;')} - assert_raise(ParseError){C::ExpressionStatement.parse('int i;')} - assert_raise(ParseError){C::ExpressionStatement.parse('return;')} - assert_raise(ParseError){C::ExpressionStatement.parse('')} + assert_raise(C::ParseError){C::ExpressionStatement.parse('} void f() {')} + assert_raise(C::ParseError){C::ExpressionStatement.parse(';;')} + assert_raise(C::ParseError){C::ExpressionStatement.parse('int i;')} + assert_raise(C::ParseError){C::ExpressionStatement.parse('return;')} + assert_raise(C::ParseError){C::ExpressionStatement.parse('')} end def test_statement check C::Statement, <<EOS {} @@ -588,58 +585,58 @@ check C::Statement, <<EOS ; ---- ExpressionStatement EOS - assert_raise(ParseError){C::Statement.parse('} void f() {')} - assert_raise(ParseError){C::Statement.parse(';;')} - assert_raise(ParseError){C::Statement.parse('int i;')} - assert_raise(ParseError){C::Statement.parse('')} + assert_raise(C::ParseError){C::Statement.parse('} void f() {')} + assert_raise(C::ParseError){C::Statement.parse(';;')} + assert_raise(C::ParseError){C::Statement.parse('int i;')} + assert_raise(C::ParseError){C::Statement.parse('')} end def test_plain_label check C::PlainLabel, <<EOS x: ---- PlainLabel name: "x" EOS - assert_raise(ParseError){C::PlainLabel.parse('} void f() {')} - assert_raise(ParseError){C::PlainLabel.parse(';')} - assert_raise(ParseError){C::PlainLabel.parse('')} - assert_raise(ParseError){C::PlainLabel.parse('x')} - assert_raise(ParseError){C::PlainLabel.parse('case 1:')} - assert_raise(ParseError){C::PlainLabel.parse('default:')} + assert_raise(C::ParseError){C::PlainLabel.parse('} void f() {')} + assert_raise(C::ParseError){C::PlainLabel.parse(';')} + assert_raise(C::ParseError){C::PlainLabel.parse('')} + assert_raise(C::ParseError){C::PlainLabel.parse('x')} + assert_raise(C::ParseError){C::PlainLabel.parse('case 1:')} + assert_raise(C::ParseError){C::PlainLabel.parse('default:')} end def test_default check C::Default, <<EOS default: ---- Default EOS - assert_raise(ParseError){C::Default.parse('} void f() {')} - assert_raise(ParseError){C::Default.parse(';')} - assert_raise(ParseError){C::Default.parse('')} - assert_raise(ParseError){C::Default.parse('x')} - assert_raise(ParseError){C::Default.parse('x:')} - assert_raise(ParseError){C::Default.parse('case 1:')} + assert_raise(C::ParseError){C::Default.parse('} void f() {')} + assert_raise(C::ParseError){C::Default.parse(';')} + assert_raise(C::ParseError){C::Default.parse('')} + assert_raise(C::ParseError){C::Default.parse('x')} + assert_raise(C::ParseError){C::Default.parse('x:')} + assert_raise(C::ParseError){C::Default.parse('case 1:')} end def test_case check C::Case, <<EOS case 1: ---- Case expr: IntLiteral val: 1 EOS - assert_raise(ParseError){C::Case.parse('} void f() {')} - assert_raise(ParseError){C::Case.parse(';')} - assert_raise(ParseError){C::Case.parse('')} - assert_raise(ParseError){C::Case.parse('x:')} - assert_raise(ParseError){C::Case.parse('default:')} + assert_raise(C::ParseError){C::Case.parse('} void f() {')} + assert_raise(C::ParseError){C::Case.parse(';')} + assert_raise(C::ParseError){C::Case.parse('')} + assert_raise(C::ParseError){C::Case.parse('x:')} + assert_raise(C::ParseError){C::Case.parse('default:')} end def test_label check C::Label, <<EOS x: @@ -657,14 +654,14 @@ ---- Case expr: IntLiteral val: 1 EOS - assert_raise(ParseError){C::Label.parse('} void f() {')} - assert_raise(ParseError){C::Label.parse(';')} - assert_raise(ParseError){C::Label.parse('')} - assert_raise(ParseError){C::Label.parse('x')} + assert_raise(C::ParseError){C::Label.parse('} void f() {')} + assert_raise(C::ParseError){C::Label.parse(';')} + assert_raise(C::ParseError){C::Label.parse('')} + assert_raise(C::ParseError){C::Label.parse('x')} end def test_comma check C::Comma, <<EOS ++i, ++j @@ -688,19 +685,19 @@ name: "i" - PreInc expr: Variable name: "j" EOS - assert_raise(ParseError){C::Comma.parse('} void f() {')} - assert_raise(ParseError){C::Comma.parse(';')} - assert_raise(ParseError){C::Comma.parse('int i')} - assert_raise(ParseError){C::Comma.parse('int')} - assert_raise(ParseError){C::Comma.parse('if (0)')} - assert_raise(ParseError){C::Comma.parse('switch (0)')} - assert_raise(ParseError){C::Comma.parse('for (;;)')} - assert_raise(ParseError){C::Comma.parse('goto')} - assert_raise(ParseError){C::Comma.parse('return')} + assert_raise(C::ParseError){C::Comma.parse('} void f() {')} + assert_raise(C::ParseError){C::Comma.parse(';')} + assert_raise(C::ParseError){C::Comma.parse('int i')} + assert_raise(C::ParseError){C::Comma.parse('int')} + assert_raise(C::ParseError){C::Comma.parse('if (0)')} + assert_raise(C::ParseError){C::Comma.parse('switch (0)')} + assert_raise(C::ParseError){C::Comma.parse('for (;;)')} + assert_raise(C::ParseError){C::Comma.parse('goto')} + assert_raise(C::ParseError){C::Comma.parse('return')} end def test_conditional check C::Conditional, <<EOS 1 ? 10 : 20 @@ -711,19 +708,19 @@ then: IntLiteral val: 10 else: IntLiteral val: 20 EOS - assert_raise(ParseError){C::Conditional.parse('} void f() {')} - assert_raise(ParseError){C::Conditional.parse(';')} - assert_raise(ParseError){C::Conditional.parse('int i')} - assert_raise(ParseError){C::Conditional.parse('int')} - assert_raise(ParseError){C::Conditional.parse('if (0)')} - assert_raise(ParseError){C::Conditional.parse('switch (0)')} - assert_raise(ParseError){C::Conditional.parse('for (;;)')} - assert_raise(ParseError){C::Conditional.parse('goto')} - assert_raise(ParseError){C::Conditional.parse('return')} + assert_raise(C::ParseError){C::Conditional.parse('} void f() {')} + assert_raise(C::ParseError){C::Conditional.parse(';')} + assert_raise(C::ParseError){C::Conditional.parse('int i')} + assert_raise(C::ParseError){C::Conditional.parse('int')} + assert_raise(C::ParseError){C::Conditional.parse('if (0)')} + assert_raise(C::ParseError){C::Conditional.parse('switch (0)')} + assert_raise(C::ParseError){C::Conditional.parse('for (;;)')} + assert_raise(C::ParseError){C::Conditional.parse('goto')} + assert_raise(C::ParseError){C::Conditional.parse('return')} end def test_cast check C::Cast, <<EOS (int)10.0 @@ -731,57 +728,57 @@ Cast type: Int expr: FloatLiteral val: 10.0 EOS - assert_raise(ParseError){C::Cast.parse('} void f() {')} - assert_raise(ParseError){C::Cast.parse(';')} - assert_raise(ParseError){C::Cast.parse('int i')} - assert_raise(ParseError){C::Cast.parse('int')} - assert_raise(ParseError){C::Cast.parse('if (0)')} - assert_raise(ParseError){C::Cast.parse('switch (0)')} - assert_raise(ParseError){C::Cast.parse('for (;;)')} - assert_raise(ParseError){C::Cast.parse('goto')} - assert_raise(ParseError){C::Cast.parse('return')} + assert_raise(C::ParseError){C::Cast.parse('} void f() {')} + assert_raise(C::ParseError){C::Cast.parse(';')} + assert_raise(C::ParseError){C::Cast.parse('int i')} + assert_raise(C::ParseError){C::Cast.parse('int')} + assert_raise(C::ParseError){C::Cast.parse('if (0)')} + assert_raise(C::ParseError){C::Cast.parse('switch (0)')} + assert_raise(C::ParseError){C::Cast.parse('for (;;)')} + assert_raise(C::ParseError){C::Cast.parse('goto')} + assert_raise(C::ParseError){C::Cast.parse('return')} end def test_address check C::Address, <<EOS &x ---- Address expr: Variable name: "x" EOS - assert_raise(ParseError){C::Address.parse('} void f() {')} - assert_raise(ParseError){C::Address.parse(';')} - assert_raise(ParseError){C::Address.parse('int i')} - assert_raise(ParseError){C::Address.parse('int')} - assert_raise(ParseError){C::Address.parse('if (0)')} - assert_raise(ParseError){C::Address.parse('switch (0)')} - assert_raise(ParseError){C::Address.parse('for (;;)')} - assert_raise(ParseError){C::Address.parse('goto')} - assert_raise(ParseError){C::Address.parse('return')} + assert_raise(C::ParseError){C::Address.parse('} void f() {')} + assert_raise(C::ParseError){C::Address.parse(';')} + assert_raise(C::ParseError){C::Address.parse('int i')} + assert_raise(C::ParseError){C::Address.parse('int')} + assert_raise(C::ParseError){C::Address.parse('if (0)')} + assert_raise(C::ParseError){C::Address.parse('switch (0)')} + assert_raise(C::ParseError){C::Address.parse('for (;;)')} + assert_raise(C::ParseError){C::Address.parse('goto')} + assert_raise(C::ParseError){C::Address.parse('return')} end def test_dereference check C::Dereference, <<EOS *x ---- Dereference expr: Variable name: "x" EOS - assert_raise(ParseError){C::Dereference.parse('} void f() {')} - assert_raise(ParseError){C::Dereference.parse(';')} - assert_raise(ParseError){C::Dereference.parse('int i')} - assert_raise(ParseError){C::Dereference.parse('int')} - assert_raise(ParseError){C::Dereference.parse('if (0)')} - assert_raise(ParseError){C::Dereference.parse('switch (0)')} - assert_raise(ParseError){C::Dereference.parse('for (;;)')} - assert_raise(ParseError){C::Dereference.parse('goto')} - assert_raise(ParseError){C::Dereference.parse('return')} + assert_raise(C::ParseError){C::Dereference.parse('} void f() {')} + assert_raise(C::ParseError){C::Dereference.parse(';')} + assert_raise(C::ParseError){C::Dereference.parse('int i')} + assert_raise(C::ParseError){C::Dereference.parse('int')} + assert_raise(C::ParseError){C::Dereference.parse('if (0)')} + assert_raise(C::ParseError){C::Dereference.parse('switch (0)')} + assert_raise(C::ParseError){C::Dereference.parse('for (;;)')} + assert_raise(C::ParseError){C::Dereference.parse('goto')} + assert_raise(C::ParseError){C::Dereference.parse('return')} end def test_sizeof check C::Sizeof, <<EOS sizeof i @@ -794,19 +791,19 @@ sizeof(int) ---- Sizeof expr: Int EOS - assert_raise(ParseError){C::Sizeof.parse('} void f() {')} - assert_raise(ParseError){C::Sizeof.parse(';')} - assert_raise(ParseError){C::Sizeof.parse('int i')} - assert_raise(ParseError){C::Sizeof.parse('int')} - assert_raise(ParseError){C::Sizeof.parse('if (0)')} - assert_raise(ParseError){C::Sizeof.parse('switch (0)')} - assert_raise(ParseError){C::Sizeof.parse('for (;;)')} - assert_raise(ParseError){C::Sizeof.parse('goto')} - assert_raise(ParseError){C::Sizeof.parse('return')} + assert_raise(C::ParseError){C::Sizeof.parse('} void f() {')} + assert_raise(C::ParseError){C::Sizeof.parse(';')} + assert_raise(C::ParseError){C::Sizeof.parse('int i')} + assert_raise(C::ParseError){C::Sizeof.parse('int')} + assert_raise(C::ParseError){C::Sizeof.parse('if (0)')} + assert_raise(C::ParseError){C::Sizeof.parse('switch (0)')} + assert_raise(C::ParseError){C::Sizeof.parse('for (;;)')} + assert_raise(C::ParseError){C::Sizeof.parse('goto')} + assert_raise(C::ParseError){C::Sizeof.parse('return')} end def test_index check C::Index, <<EOS x[10][20] @@ -818,19 +815,19 @@ index: IntLiteral val: 10 index: IntLiteral val: 20 EOS - assert_raise(ParseError){C::Index.parse('} void f() {')} - assert_raise(ParseError){C::Index.parse(';')} - assert_raise(ParseError){C::Index.parse('int i')} - assert_raise(ParseError){C::Index.parse('int')} - assert_raise(ParseError){C::Index.parse('if (0)')} - assert_raise(ParseError){C::Index.parse('switch (0)')} - assert_raise(ParseError){C::Index.parse('for (;;)')} - assert_raise(ParseError){C::Index.parse('goto')} - assert_raise(ParseError){C::Index.parse('return')} + assert_raise(C::ParseError){C::Index.parse('} void f() {')} + assert_raise(C::ParseError){C::Index.parse(';')} + assert_raise(C::ParseError){C::Index.parse('int i')} + assert_raise(C::ParseError){C::Index.parse('int')} + assert_raise(C::ParseError){C::Index.parse('if (0)')} + assert_raise(C::ParseError){C::Index.parse('switch (0)')} + assert_raise(C::ParseError){C::Index.parse('for (;;)')} + assert_raise(C::ParseError){C::Index.parse('goto')} + assert_raise(C::ParseError){C::Index.parse('return')} end def test_call check C::Call, <<EOS x(10, 20)() @@ -843,19 +840,19 @@ - IntLiteral val: 10 - IntLiteral val: 20 EOS - assert_raise(ParseError){C::Call.parse('} void f() {')} - assert_raise(ParseError){C::Call.parse(';')} - assert_raise(ParseError){C::Call.parse('int i')} - assert_raise(ParseError){C::Call.parse('int')} - assert_raise(ParseError){C::Call.parse('if (0)')} - assert_raise(ParseError){C::Call.parse('switch (0)')} - assert_raise(ParseError){C::Call.parse('for (;;)')} - assert_raise(ParseError){C::Call.parse('goto')} - assert_raise(ParseError){C::Call.parse('return')} + assert_raise(C::ParseError){C::Call.parse('} void f() {')} + assert_raise(C::ParseError){C::Call.parse(';')} + assert_raise(C::ParseError){C::Call.parse('int i')} + assert_raise(C::ParseError){C::Call.parse('int')} + assert_raise(C::ParseError){C::Call.parse('if (0)')} + assert_raise(C::ParseError){C::Call.parse('switch (0)')} + assert_raise(C::ParseError){C::Call.parse('for (;;)')} + assert_raise(C::ParseError){C::Call.parse('goto')} + assert_raise(C::ParseError){C::Call.parse('return')} end def test_arrow check C::Arrow, <<EOS x->y @@ -864,19 +861,19 @@ expr: Variable name: "x" member: Member name: "y" EOS - assert_raise(ParseError){C::Arrow.parse('} void f() {')} - assert_raise(ParseError){C::Arrow.parse(';')} - assert_raise(ParseError){C::Arrow.parse('int i')} - assert_raise(ParseError){C::Arrow.parse('int')} - assert_raise(ParseError){C::Arrow.parse('if (0)')} - assert_raise(ParseError){C::Arrow.parse('switch (0)')} - assert_raise(ParseError){C::Arrow.parse('for (;;)')} - assert_raise(ParseError){C::Arrow.parse('goto')} - assert_raise(ParseError){C::Arrow.parse('return')} + assert_raise(C::ParseError){C::Arrow.parse('} void f() {')} + assert_raise(C::ParseError){C::Arrow.parse(';')} + assert_raise(C::ParseError){C::Arrow.parse('int i')} + assert_raise(C::ParseError){C::Arrow.parse('int')} + assert_raise(C::ParseError){C::Arrow.parse('if (0)')} + assert_raise(C::ParseError){C::Arrow.parse('switch (0)')} + assert_raise(C::ParseError){C::Arrow.parse('for (;;)')} + assert_raise(C::ParseError){C::Arrow.parse('goto')} + assert_raise(C::ParseError){C::Arrow.parse('return')} end def test_dot check C::Dot, <<EOS x.y @@ -885,57 +882,57 @@ expr: Variable name: "x" member: Member name: "y" EOS - assert_raise(ParseError){C::Dot.parse('} void f() {')} - assert_raise(ParseError){C::Dot.parse(';')} - assert_raise(ParseError){C::Dot.parse('int i')} - assert_raise(ParseError){C::Dot.parse('int')} - assert_raise(ParseError){C::Dot.parse('if (0)')} - assert_raise(ParseError){C::Dot.parse('switch (0)')} - assert_raise(ParseError){C::Dot.parse('for (;;)')} - assert_raise(ParseError){C::Dot.parse('goto')} - assert_raise(ParseError){C::Dot.parse('return')} + assert_raise(C::ParseError){C::Dot.parse('} void f() {')} + assert_raise(C::ParseError){C::Dot.parse(';')} + assert_raise(C::ParseError){C::Dot.parse('int i')} + assert_raise(C::ParseError){C::Dot.parse('int')} + assert_raise(C::ParseError){C::Dot.parse('if (0)')} + assert_raise(C::ParseError){C::Dot.parse('switch (0)')} + assert_raise(C::ParseError){C::Dot.parse('for (;;)')} + assert_raise(C::ParseError){C::Dot.parse('goto')} + assert_raise(C::ParseError){C::Dot.parse('return')} end def test_positive check C::Positive, <<EOS +1 ---- Positive expr: IntLiteral val: 1 EOS - assert_raise(ParseError){C::Positive.parse('} void f() {')} - assert_raise(ParseError){C::Positive.parse(';')} - assert_raise(ParseError){C::Positive.parse('int i')} - assert_raise(ParseError){C::Positive.parse('int')} - assert_raise(ParseError){C::Positive.parse('if (0)')} - assert_raise(ParseError){C::Positive.parse('switch (0)')} - assert_raise(ParseError){C::Positive.parse('for (;;)')} - assert_raise(ParseError){C::Positive.parse('goto')} - assert_raise(ParseError){C::Positive.parse('return')} + assert_raise(C::ParseError){C::Positive.parse('} void f() {')} + assert_raise(C::ParseError){C::Positive.parse(';')} + assert_raise(C::ParseError){C::Positive.parse('int i')} + assert_raise(C::ParseError){C::Positive.parse('int')} + assert_raise(C::ParseError){C::Positive.parse('if (0)')} + assert_raise(C::ParseError){C::Positive.parse('switch (0)')} + assert_raise(C::ParseError){C::Positive.parse('for (;;)')} + assert_raise(C::ParseError){C::Positive.parse('goto')} + assert_raise(C::ParseError){C::Positive.parse('return')} end def test_negative check C::Negative, <<EOS -1 ---- Negative expr: IntLiteral val: 1 EOS - assert_raise(ParseError){C::Negative.parse('} void f() {')} - assert_raise(ParseError){C::Negative.parse(';')} - assert_raise(ParseError){C::Negative.parse('int i')} - assert_raise(ParseError){C::Negative.parse('int')} - assert_raise(ParseError){C::Negative.parse('if (0)')} - assert_raise(ParseError){C::Negative.parse('switch (0)')} - assert_raise(ParseError){C::Negative.parse('for (;;)')} - assert_raise(ParseError){C::Negative.parse('goto')} - assert_raise(ParseError){C::Negative.parse('return')} + assert_raise(C::ParseError){C::Negative.parse('} void f() {')} + assert_raise(C::ParseError){C::Negative.parse(';')} + assert_raise(C::ParseError){C::Negative.parse('int i')} + assert_raise(C::ParseError){C::Negative.parse('int')} + assert_raise(C::ParseError){C::Negative.parse('if (0)')} + assert_raise(C::ParseError){C::Negative.parse('switch (0)')} + assert_raise(C::ParseError){C::Negative.parse('for (;;)')} + assert_raise(C::ParseError){C::Negative.parse('goto')} + assert_raise(C::ParseError){C::Negative.parse('return')} end def test_add check C::Add, <<EOS 1 + 10 @@ -944,19 +941,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Add.parse('} void f() {')} - assert_raise(ParseError){C::Add.parse(';')} - assert_raise(ParseError){C::Add.parse('int i')} - assert_raise(ParseError){C::Add.parse('int')} - assert_raise(ParseError){C::Add.parse('if (0)')} - assert_raise(ParseError){C::Add.parse('switch (0)')} - assert_raise(ParseError){C::Add.parse('for (;;)')} - assert_raise(ParseError){C::Add.parse('goto')} - assert_raise(ParseError){C::Add.parse('return')} + assert_raise(C::ParseError){C::Add.parse('} void f() {')} + assert_raise(C::ParseError){C::Add.parse(';')} + assert_raise(C::ParseError){C::Add.parse('int i')} + assert_raise(C::ParseError){C::Add.parse('int')} + assert_raise(C::ParseError){C::Add.parse('if (0)')} + assert_raise(C::ParseError){C::Add.parse('switch (0)')} + assert_raise(C::ParseError){C::Add.parse('for (;;)')} + assert_raise(C::ParseError){C::Add.parse('goto')} + assert_raise(C::ParseError){C::Add.parse('return')} end def test_subtract check C::Subtract, <<EOS 1 - 10 @@ -965,19 +962,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Subtract.parse('} void f() {')} - assert_raise(ParseError){C::Subtract.parse(';')} - assert_raise(ParseError){C::Subtract.parse('int i')} - assert_raise(ParseError){C::Subtract.parse('int')} - assert_raise(ParseError){C::Subtract.parse('if (0)')} - assert_raise(ParseError){C::Subtract.parse('switch (0)')} - assert_raise(ParseError){C::Subtract.parse('for (;;)')} - assert_raise(ParseError){C::Subtract.parse('goto')} - assert_raise(ParseError){C::Subtract.parse('return')} + assert_raise(C::ParseError){C::Subtract.parse('} void f() {')} + assert_raise(C::ParseError){C::Subtract.parse(';')} + assert_raise(C::ParseError){C::Subtract.parse('int i')} + assert_raise(C::ParseError){C::Subtract.parse('int')} + assert_raise(C::ParseError){C::Subtract.parse('if (0)')} + assert_raise(C::ParseError){C::Subtract.parse('switch (0)')} + assert_raise(C::ParseError){C::Subtract.parse('for (;;)')} + assert_raise(C::ParseError){C::Subtract.parse('goto')} + assert_raise(C::ParseError){C::Subtract.parse('return')} end def test_multiply check C::Multiply, <<EOS 1 * 10 @@ -986,19 +983,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Multiply.parse('} void f() {')} - assert_raise(ParseError){C::Multiply.parse(';')} - assert_raise(ParseError){C::Multiply.parse('int i')} - assert_raise(ParseError){C::Multiply.parse('int')} - assert_raise(ParseError){C::Multiply.parse('if (0)')} - assert_raise(ParseError){C::Multiply.parse('switch (0)')} - assert_raise(ParseError){C::Multiply.parse('for (;;)')} - assert_raise(ParseError){C::Multiply.parse('goto')} - assert_raise(ParseError){C::Multiply.parse('return')} + assert_raise(C::ParseError){C::Multiply.parse('} void f() {')} + assert_raise(C::ParseError){C::Multiply.parse(';')} + assert_raise(C::ParseError){C::Multiply.parse('int i')} + assert_raise(C::ParseError){C::Multiply.parse('int')} + assert_raise(C::ParseError){C::Multiply.parse('if (0)')} + assert_raise(C::ParseError){C::Multiply.parse('switch (0)')} + assert_raise(C::ParseError){C::Multiply.parse('for (;;)')} + assert_raise(C::ParseError){C::Multiply.parse('goto')} + assert_raise(C::ParseError){C::Multiply.parse('return')} end def test_divide check C::Divide, <<EOS 1 / 10 @@ -1007,19 +1004,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Divide.parse('} void f() {')} - assert_raise(ParseError){C::Divide.parse(';')} - assert_raise(ParseError){C::Divide.parse('int i')} - assert_raise(ParseError){C::Divide.parse('int')} - assert_raise(ParseError){C::Divide.parse('if (0)')} - assert_raise(ParseError){C::Divide.parse('switch (0)')} - assert_raise(ParseError){C::Divide.parse('for (;;)')} - assert_raise(ParseError){C::Divide.parse('goto')} - assert_raise(ParseError){C::Divide.parse('return')} + assert_raise(C::ParseError){C::Divide.parse('} void f() {')} + assert_raise(C::ParseError){C::Divide.parse(';')} + assert_raise(C::ParseError){C::Divide.parse('int i')} + assert_raise(C::ParseError){C::Divide.parse('int')} + assert_raise(C::ParseError){C::Divide.parse('if (0)')} + assert_raise(C::ParseError){C::Divide.parse('switch (0)')} + assert_raise(C::ParseError){C::Divide.parse('for (;;)')} + assert_raise(C::ParseError){C::Divide.parse('goto')} + assert_raise(C::ParseError){C::Divide.parse('return')} end def test_mod check C::Mod, <<EOS 1 % 10 @@ -1028,95 +1025,95 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Mod.parse('} void f() {')} - assert_raise(ParseError){C::Mod.parse(';')} - assert_raise(ParseError){C::Mod.parse('int i')} - assert_raise(ParseError){C::Mod.parse('int')} - assert_raise(ParseError){C::Mod.parse('if (0)')} - assert_raise(ParseError){C::Mod.parse('switch (0)')} - assert_raise(ParseError){C::Mod.parse('for (;;)')} - assert_raise(ParseError){C::Mod.parse('goto')} - assert_raise(ParseError){C::Mod.parse('return')} + assert_raise(C::ParseError){C::Mod.parse('} void f() {')} + assert_raise(C::ParseError){C::Mod.parse(';')} + assert_raise(C::ParseError){C::Mod.parse('int i')} + assert_raise(C::ParseError){C::Mod.parse('int')} + assert_raise(C::ParseError){C::Mod.parse('if (0)')} + assert_raise(C::ParseError){C::Mod.parse('switch (0)')} + assert_raise(C::ParseError){C::Mod.parse('for (;;)')} + assert_raise(C::ParseError){C::Mod.parse('goto')} + assert_raise(C::ParseError){C::Mod.parse('return')} end def test_pre_inc check C::PreInc, <<EOS ++i ---- PreInc expr: Variable name: "i" EOS - assert_raise(ParseError){C::PreInc.parse('} void f() {')} - assert_raise(ParseError){C::PreInc.parse(';')} - assert_raise(ParseError){C::PreInc.parse('int i')} - assert_raise(ParseError){C::PreInc.parse('int')} - assert_raise(ParseError){C::PreInc.parse('if (0)')} - assert_raise(ParseError){C::PreInc.parse('switch (0)')} - assert_raise(ParseError){C::PreInc.parse('for (;;)')} - assert_raise(ParseError){C::PreInc.parse('goto')} - assert_raise(ParseError){C::PreInc.parse('return')} + assert_raise(C::ParseError){C::PreInc.parse('} void f() {')} + assert_raise(C::ParseError){C::PreInc.parse(';')} + assert_raise(C::ParseError){C::PreInc.parse('int i')} + assert_raise(C::ParseError){C::PreInc.parse('int')} + assert_raise(C::ParseError){C::PreInc.parse('if (0)')} + assert_raise(C::ParseError){C::PreInc.parse('switch (0)')} + assert_raise(C::ParseError){C::PreInc.parse('for (;;)')} + assert_raise(C::ParseError){C::PreInc.parse('goto')} + assert_raise(C::ParseError){C::PreInc.parse('return')} end def test_post_inc check C::PostInc, <<EOS i++ ---- PostInc expr: Variable name: "i" EOS - assert_raise(ParseError){C::PostInc.parse('} void f() {')} - assert_raise(ParseError){C::PostInc.parse(';')} - assert_raise(ParseError){C::PostInc.parse('int i')} - assert_raise(ParseError){C::PostInc.parse('int')} - assert_raise(ParseError){C::PostInc.parse('if (0)')} - assert_raise(ParseError){C::PostInc.parse('switch (0)')} - assert_raise(ParseError){C::PostInc.parse('for (;;)')} - assert_raise(ParseError){C::PostInc.parse('goto')} - assert_raise(ParseError){C::PostInc.parse('return')} + assert_raise(C::ParseError){C::PostInc.parse('} void f() {')} + assert_raise(C::ParseError){C::PostInc.parse(';')} + assert_raise(C::ParseError){C::PostInc.parse('int i')} + assert_raise(C::ParseError){C::PostInc.parse('int')} + assert_raise(C::ParseError){C::PostInc.parse('if (0)')} + assert_raise(C::ParseError){C::PostInc.parse('switch (0)')} + assert_raise(C::ParseError){C::PostInc.parse('for (;;)')} + assert_raise(C::ParseError){C::PostInc.parse('goto')} + assert_raise(C::ParseError){C::PostInc.parse('return')} end def test_pre_dec check C::PreDec, <<EOS --i ---- PreDec expr: Variable name: "i" EOS - assert_raise(ParseError){C::PreDec.parse('} void f() {')} - assert_raise(ParseError){C::PreDec.parse(';')} - assert_raise(ParseError){C::PreDec.parse('int i')} - assert_raise(ParseError){C::PreDec.parse('int')} - assert_raise(ParseError){C::PreDec.parse('if (0)')} - assert_raise(ParseError){C::PreDec.parse('switch (0)')} - assert_raise(ParseError){C::PreDec.parse('for (;;)')} - assert_raise(ParseError){C::PreDec.parse('goto')} - assert_raise(ParseError){C::PreDec.parse('return')} + assert_raise(C::ParseError){C::PreDec.parse('} void f() {')} + assert_raise(C::ParseError){C::PreDec.parse(';')} + assert_raise(C::ParseError){C::PreDec.parse('int i')} + assert_raise(C::ParseError){C::PreDec.parse('int')} + assert_raise(C::ParseError){C::PreDec.parse('if (0)')} + assert_raise(C::ParseError){C::PreDec.parse('switch (0)')} + assert_raise(C::ParseError){C::PreDec.parse('for (;;)')} + assert_raise(C::ParseError){C::PreDec.parse('goto')} + assert_raise(C::ParseError){C::PreDec.parse('return')} end def test_post_dec check C::PostDec, <<EOS i-- ---- PostDec expr: Variable name: "i" EOS - assert_raise(ParseError){C::PostDec.parse('} void f() {')} - assert_raise(ParseError){C::PostDec.parse(';')} - assert_raise(ParseError){C::PostDec.parse('int i')} - assert_raise(ParseError){C::PostDec.parse('int')} - assert_raise(ParseError){C::PostDec.parse('if (0)')} - assert_raise(ParseError){C::PostDec.parse('switch (0)')} - assert_raise(ParseError){C::PostDec.parse('for (;;)')} - assert_raise(ParseError){C::PostDec.parse('goto')} - assert_raise(ParseError){C::PostDec.parse('return')} + assert_raise(C::ParseError){C::PostDec.parse('} void f() {')} + assert_raise(C::ParseError){C::PostDec.parse(';')} + assert_raise(C::ParseError){C::PostDec.parse('int i')} + assert_raise(C::ParseError){C::PostDec.parse('int')} + assert_raise(C::ParseError){C::PostDec.parse('if (0)')} + assert_raise(C::ParseError){C::PostDec.parse('switch (0)')} + assert_raise(C::ParseError){C::PostDec.parse('for (;;)')} + assert_raise(C::ParseError){C::PostDec.parse('goto')} + assert_raise(C::ParseError){C::PostDec.parse('return')} end def test_equal check C::Equal, <<EOS 1 == 10 @@ -1125,19 +1122,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Equal.parse('} void f() {')} - assert_raise(ParseError){C::Equal.parse(';')} - assert_raise(ParseError){C::Equal.parse('int i')} - assert_raise(ParseError){C::Equal.parse('int')} - assert_raise(ParseError){C::Equal.parse('if (0)')} - assert_raise(ParseError){C::Equal.parse('switch (0)')} - assert_raise(ParseError){C::Equal.parse('for (;;)')} - assert_raise(ParseError){C::Equal.parse('goto')} - assert_raise(ParseError){C::Equal.parse('return')} + assert_raise(C::ParseError){C::Equal.parse('} void f() {')} + assert_raise(C::ParseError){C::Equal.parse(';')} + assert_raise(C::ParseError){C::Equal.parse('int i')} + assert_raise(C::ParseError){C::Equal.parse('int')} + assert_raise(C::ParseError){C::Equal.parse('if (0)')} + assert_raise(C::ParseError){C::Equal.parse('switch (0)')} + assert_raise(C::ParseError){C::Equal.parse('for (;;)')} + assert_raise(C::ParseError){C::Equal.parse('goto')} + assert_raise(C::ParseError){C::Equal.parse('return')} end def test_not_equal check C::NotEqual, <<EOS 1 != 10 @@ -1146,19 +1143,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::NotEqual.parse('} void f() {')} - assert_raise(ParseError){C::NotEqual.parse(';')} - assert_raise(ParseError){C::NotEqual.parse('int i')} - assert_raise(ParseError){C::NotEqual.parse('int')} - assert_raise(ParseError){C::NotEqual.parse('if (0)')} - assert_raise(ParseError){C::NotEqual.parse('switch (0)')} - assert_raise(ParseError){C::NotEqual.parse('for (;;)')} - assert_raise(ParseError){C::NotEqual.parse('goto')} - assert_raise(ParseError){C::NotEqual.parse('return')} + assert_raise(C::ParseError){C::NotEqual.parse('} void f() {')} + assert_raise(C::ParseError){C::NotEqual.parse(';')} + assert_raise(C::ParseError){C::NotEqual.parse('int i')} + assert_raise(C::ParseError){C::NotEqual.parse('int')} + assert_raise(C::ParseError){C::NotEqual.parse('if (0)')} + assert_raise(C::ParseError){C::NotEqual.parse('switch (0)')} + assert_raise(C::ParseError){C::NotEqual.parse('for (;;)')} + assert_raise(C::ParseError){C::NotEqual.parse('goto')} + assert_raise(C::ParseError){C::NotEqual.parse('return')} end def test_less check C::Less, <<EOS 1 < 10 @@ -1167,19 +1164,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Less.parse('} void f() {')} - assert_raise(ParseError){C::Less.parse(';')} - assert_raise(ParseError){C::Less.parse('int i')} - assert_raise(ParseError){C::Less.parse('int')} - assert_raise(ParseError){C::Less.parse('if (0)')} - assert_raise(ParseError){C::Less.parse('switch (0)')} - assert_raise(ParseError){C::Less.parse('for (;;)')} - assert_raise(ParseError){C::Less.parse('goto')} - assert_raise(ParseError){C::Less.parse('return')} + assert_raise(C::ParseError){C::Less.parse('} void f() {')} + assert_raise(C::ParseError){C::Less.parse(';')} + assert_raise(C::ParseError){C::Less.parse('int i')} + assert_raise(C::ParseError){C::Less.parse('int')} + assert_raise(C::ParseError){C::Less.parse('if (0)')} + assert_raise(C::ParseError){C::Less.parse('switch (0)')} + assert_raise(C::ParseError){C::Less.parse('for (;;)')} + assert_raise(C::ParseError){C::Less.parse('goto')} + assert_raise(C::ParseError){C::Less.parse('return')} end def test_more check C::More, <<EOS 1 > 10 @@ -1188,19 +1185,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::More.parse('} void f() {')} - assert_raise(ParseError){C::More.parse(';')} - assert_raise(ParseError){C::More.parse('int i')} - assert_raise(ParseError){C::More.parse('int')} - assert_raise(ParseError){C::More.parse('if (0)')} - assert_raise(ParseError){C::More.parse('switch (0)')} - assert_raise(ParseError){C::More.parse('for (;;)')} - assert_raise(ParseError){C::More.parse('goto')} - assert_raise(ParseError){C::More.parse('return')} + assert_raise(C::ParseError){C::More.parse('} void f() {')} + assert_raise(C::ParseError){C::More.parse(';')} + assert_raise(C::ParseError){C::More.parse('int i')} + assert_raise(C::ParseError){C::More.parse('int')} + assert_raise(C::ParseError){C::More.parse('if (0)')} + assert_raise(C::ParseError){C::More.parse('switch (0)')} + assert_raise(C::ParseError){C::More.parse('for (;;)')} + assert_raise(C::ParseError){C::More.parse('goto')} + assert_raise(C::ParseError){C::More.parse('return')} end def test_less_or_equal check C::LessOrEqual, <<EOS 1 <= 10 @@ -1209,19 +1206,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::LessOrEqual.parse('} void f() {')} - assert_raise(ParseError){C::LessOrEqual.parse(';')} - assert_raise(ParseError){C::LessOrEqual.parse('int i')} - assert_raise(ParseError){C::LessOrEqual.parse('int')} - assert_raise(ParseError){C::LessOrEqual.parse('if (0)')} - assert_raise(ParseError){C::LessOrEqual.parse('switch (0)')} - assert_raise(ParseError){C::LessOrEqual.parse('for (;;)')} - assert_raise(ParseError){C::LessOrEqual.parse('goto')} - assert_raise(ParseError){C::LessOrEqual.parse('return')} + assert_raise(C::ParseError){C::LessOrEqual.parse('} void f() {')} + assert_raise(C::ParseError){C::LessOrEqual.parse(';')} + assert_raise(C::ParseError){C::LessOrEqual.parse('int i')} + assert_raise(C::ParseError){C::LessOrEqual.parse('int')} + assert_raise(C::ParseError){C::LessOrEqual.parse('if (0)')} + assert_raise(C::ParseError){C::LessOrEqual.parse('switch (0)')} + assert_raise(C::ParseError){C::LessOrEqual.parse('for (;;)')} + assert_raise(C::ParseError){C::LessOrEqual.parse('goto')} + assert_raise(C::ParseError){C::LessOrEqual.parse('return')} end def test_more_or_equal check C::MoreOrEqual, <<EOS 1 >= 10 @@ -1230,19 +1227,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::MoreOrEqual.parse('} void f() {')} - assert_raise(ParseError){C::MoreOrEqual.parse(';')} - assert_raise(ParseError){C::MoreOrEqual.parse('int i')} - assert_raise(ParseError){C::MoreOrEqual.parse('int')} - assert_raise(ParseError){C::MoreOrEqual.parse('if (0)')} - assert_raise(ParseError){C::MoreOrEqual.parse('switch (0)')} - assert_raise(ParseError){C::MoreOrEqual.parse('for (;;)')} - assert_raise(ParseError){C::MoreOrEqual.parse('goto')} - assert_raise(ParseError){C::MoreOrEqual.parse('return')} + assert_raise(C::ParseError){C::MoreOrEqual.parse('} void f() {')} + assert_raise(C::ParseError){C::MoreOrEqual.parse(';')} + assert_raise(C::ParseError){C::MoreOrEqual.parse('int i')} + assert_raise(C::ParseError){C::MoreOrEqual.parse('int')} + assert_raise(C::ParseError){C::MoreOrEqual.parse('if (0)')} + assert_raise(C::ParseError){C::MoreOrEqual.parse('switch (0)')} + assert_raise(C::ParseError){C::MoreOrEqual.parse('for (;;)')} + assert_raise(C::ParseError){C::MoreOrEqual.parse('goto')} + assert_raise(C::ParseError){C::MoreOrEqual.parse('return')} end def test_bit_and check C::BitAnd, <<EOS 1 & 10 @@ -1251,19 +1248,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::BitAnd.parse('} void f() {')} - assert_raise(ParseError){C::BitAnd.parse(';')} - assert_raise(ParseError){C::BitAnd.parse('int i')} - assert_raise(ParseError){C::BitAnd.parse('int')} - assert_raise(ParseError){C::BitAnd.parse('if (0)')} - assert_raise(ParseError){C::BitAnd.parse('switch (0)')} - assert_raise(ParseError){C::BitAnd.parse('for (;;)')} - assert_raise(ParseError){C::BitAnd.parse('goto')} - assert_raise(ParseError){C::BitAnd.parse('return')} + assert_raise(C::ParseError){C::BitAnd.parse('} void f() {')} + assert_raise(C::ParseError){C::BitAnd.parse(';')} + assert_raise(C::ParseError){C::BitAnd.parse('int i')} + assert_raise(C::ParseError){C::BitAnd.parse('int')} + assert_raise(C::ParseError){C::BitAnd.parse('if (0)')} + assert_raise(C::ParseError){C::BitAnd.parse('switch (0)')} + assert_raise(C::ParseError){C::BitAnd.parse('for (;;)')} + assert_raise(C::ParseError){C::BitAnd.parse('goto')} + assert_raise(C::ParseError){C::BitAnd.parse('return')} end def test_bit_or check C::BitOr, <<EOS 1 | 10 @@ -1272,19 +1269,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::BitOr.parse('} void f() {')} - assert_raise(ParseError){C::BitOr.parse(';')} - assert_raise(ParseError){C::BitOr.parse('int i')} - assert_raise(ParseError){C::BitOr.parse('int')} - assert_raise(ParseError){C::BitOr.parse('if (0)')} - assert_raise(ParseError){C::BitOr.parse('switch (0)')} - assert_raise(ParseError){C::BitOr.parse('for (;;)')} - assert_raise(ParseError){C::BitOr.parse('goto')} - assert_raise(ParseError){C::BitOr.parse('return')} + assert_raise(C::ParseError){C::BitOr.parse('} void f() {')} + assert_raise(C::ParseError){C::BitOr.parse(';')} + assert_raise(C::ParseError){C::BitOr.parse('int i')} + assert_raise(C::ParseError){C::BitOr.parse('int')} + assert_raise(C::ParseError){C::BitOr.parse('if (0)')} + assert_raise(C::ParseError){C::BitOr.parse('switch (0)')} + assert_raise(C::ParseError){C::BitOr.parse('for (;;)')} + assert_raise(C::ParseError){C::BitOr.parse('goto')} + assert_raise(C::ParseError){C::BitOr.parse('return')} end def test_bit_xor check C::BitXor, <<EOS 1 ^ 10 @@ -1293,38 +1290,38 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::BitXor.parse('} void f() {')} - assert_raise(ParseError){C::BitXor.parse(';')} - assert_raise(ParseError){C::BitXor.parse('int i')} - assert_raise(ParseError){C::BitXor.parse('int')} - assert_raise(ParseError){C::BitXor.parse('if (0)')} - assert_raise(ParseError){C::BitXor.parse('switch (0)')} - assert_raise(ParseError){C::BitXor.parse('for (;;)')} - assert_raise(ParseError){C::BitXor.parse('goto')} - assert_raise(ParseError){C::BitXor.parse('return')} + assert_raise(C::ParseError){C::BitXor.parse('} void f() {')} + assert_raise(C::ParseError){C::BitXor.parse(';')} + assert_raise(C::ParseError){C::BitXor.parse('int i')} + assert_raise(C::ParseError){C::BitXor.parse('int')} + assert_raise(C::ParseError){C::BitXor.parse('if (0)')} + assert_raise(C::ParseError){C::BitXor.parse('switch (0)')} + assert_raise(C::ParseError){C::BitXor.parse('for (;;)')} + assert_raise(C::ParseError){C::BitXor.parse('goto')} + assert_raise(C::ParseError){C::BitXor.parse('return')} end def test_bit_not check C::BitNot, <<EOS ~i ---- BitNot expr: Variable name: "i" EOS - assert_raise(ParseError){C::BitNot.parse('} void f() {')} - assert_raise(ParseError){C::BitNot.parse(';')} - assert_raise(ParseError){C::BitNot.parse('int i')} - assert_raise(ParseError){C::BitNot.parse('int')} - assert_raise(ParseError){C::BitNot.parse('if (0)')} - assert_raise(ParseError){C::BitNot.parse('switch (0)')} - assert_raise(ParseError){C::BitNot.parse('for (;;)')} - assert_raise(ParseError){C::BitNot.parse('goto')} - assert_raise(ParseError){C::BitNot.parse('return')} + assert_raise(C::ParseError){C::BitNot.parse('} void f() {')} + assert_raise(C::ParseError){C::BitNot.parse(';')} + assert_raise(C::ParseError){C::BitNot.parse('int i')} + assert_raise(C::ParseError){C::BitNot.parse('int')} + assert_raise(C::ParseError){C::BitNot.parse('if (0)')} + assert_raise(C::ParseError){C::BitNot.parse('switch (0)')} + assert_raise(C::ParseError){C::BitNot.parse('for (;;)')} + assert_raise(C::ParseError){C::BitNot.parse('goto')} + assert_raise(C::ParseError){C::BitNot.parse('return')} end def test_shift_left check C::ShiftLeft, <<EOS 1 << 10 @@ -1333,19 +1330,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::ShiftLeft.parse('} void f() {')} - assert_raise(ParseError){C::ShiftLeft.parse(';')} - assert_raise(ParseError){C::ShiftLeft.parse('int i')} - assert_raise(ParseError){C::ShiftLeft.parse('int')} - assert_raise(ParseError){C::ShiftLeft.parse('if (0)')} - assert_raise(ParseError){C::ShiftLeft.parse('switch (0)')} - assert_raise(ParseError){C::ShiftLeft.parse('for (;;)')} - assert_raise(ParseError){C::ShiftLeft.parse('goto')} - assert_raise(ParseError){C::ShiftLeft.parse('return')} + assert_raise(C::ParseError){C::ShiftLeft.parse('} void f() {')} + assert_raise(C::ParseError){C::ShiftLeft.parse(';')} + assert_raise(C::ParseError){C::ShiftLeft.parse('int i')} + assert_raise(C::ParseError){C::ShiftLeft.parse('int')} + assert_raise(C::ParseError){C::ShiftLeft.parse('if (0)')} + assert_raise(C::ParseError){C::ShiftLeft.parse('switch (0)')} + assert_raise(C::ParseError){C::ShiftLeft.parse('for (;;)')} + assert_raise(C::ParseError){C::ShiftLeft.parse('goto')} + assert_raise(C::ParseError){C::ShiftLeft.parse('return')} end def test_shift_right check C::ShiftRight, <<EOS 1 >> 10 @@ -1354,19 +1351,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::ShiftRight.parse('} void f() {')} - assert_raise(ParseError){C::ShiftRight.parse(';')} - assert_raise(ParseError){C::ShiftRight.parse('int i')} - assert_raise(ParseError){C::ShiftRight.parse('int')} - assert_raise(ParseError){C::ShiftRight.parse('if (0)')} - assert_raise(ParseError){C::ShiftRight.parse('switch (0)')} - assert_raise(ParseError){C::ShiftRight.parse('for (;;)')} - assert_raise(ParseError){C::ShiftRight.parse('goto')} - assert_raise(ParseError){C::ShiftRight.parse('return')} + assert_raise(C::ParseError){C::ShiftRight.parse('} void f() {')} + assert_raise(C::ParseError){C::ShiftRight.parse(';')} + assert_raise(C::ParseError){C::ShiftRight.parse('int i')} + assert_raise(C::ParseError){C::ShiftRight.parse('int')} + assert_raise(C::ParseError){C::ShiftRight.parse('if (0)')} + assert_raise(C::ParseError){C::ShiftRight.parse('switch (0)')} + assert_raise(C::ParseError){C::ShiftRight.parse('for (;;)')} + assert_raise(C::ParseError){C::ShiftRight.parse('goto')} + assert_raise(C::ParseError){C::ShiftRight.parse('return')} end def test_and check C::And, <<EOS 1 && 10 @@ -1375,19 +1372,19 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::And.parse('} void f() {')} - assert_raise(ParseError){C::And.parse(';')} - assert_raise(ParseError){C::And.parse('int i')} - assert_raise(ParseError){C::And.parse('int')} - assert_raise(ParseError){C::And.parse('if (0)')} - assert_raise(ParseError){C::And.parse('switch (0)')} - assert_raise(ParseError){C::And.parse('for (;;)')} - assert_raise(ParseError){C::And.parse('goto')} - assert_raise(ParseError){C::And.parse('return')} + assert_raise(C::ParseError){C::And.parse('} void f() {')} + assert_raise(C::ParseError){C::And.parse(';')} + assert_raise(C::ParseError){C::And.parse('int i')} + assert_raise(C::ParseError){C::And.parse('int')} + assert_raise(C::ParseError){C::And.parse('if (0)')} + assert_raise(C::ParseError){C::And.parse('switch (0)')} + assert_raise(C::ParseError){C::And.parse('for (;;)')} + assert_raise(C::ParseError){C::And.parse('goto')} + assert_raise(C::ParseError){C::And.parse('return')} end def test_or check C::Or, <<EOS 1 || 10 @@ -1396,38 +1393,38 @@ expr1: IntLiteral val: 1 expr2: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Or.parse('} void f() {')} - assert_raise(ParseError){C::Or.parse(';')} - assert_raise(ParseError){C::Or.parse('int i')} - assert_raise(ParseError){C::Or.parse('int')} - assert_raise(ParseError){C::Or.parse('if (0)')} - assert_raise(ParseError){C::Or.parse('switch (0)')} - assert_raise(ParseError){C::Or.parse('for (;;)')} - assert_raise(ParseError){C::Or.parse('goto')} - assert_raise(ParseError){C::Or.parse('return')} + assert_raise(C::ParseError){C::Or.parse('} void f() {')} + assert_raise(C::ParseError){C::Or.parse(';')} + assert_raise(C::ParseError){C::Or.parse('int i')} + assert_raise(C::ParseError){C::Or.parse('int')} + assert_raise(C::ParseError){C::Or.parse('if (0)')} + assert_raise(C::ParseError){C::Or.parse('switch (0)')} + assert_raise(C::ParseError){C::Or.parse('for (;;)')} + assert_raise(C::ParseError){C::Or.parse('goto')} + assert_raise(C::ParseError){C::Or.parse('return')} end def test_not check C::Not, <<EOS !i ---- Not expr: Variable name: "i" EOS - assert_raise(ParseError){C::Not.parse('} void f() {')} - assert_raise(ParseError){C::Not.parse(';')} - assert_raise(ParseError){C::Not.parse('int i')} - assert_raise(ParseError){C::Not.parse('int')} - assert_raise(ParseError){C::Not.parse('if (0)')} - assert_raise(ParseError){C::Not.parse('switch (0)')} - assert_raise(ParseError){C::Not.parse('for (;;)')} - assert_raise(ParseError){C::Not.parse('goto')} - assert_raise(ParseError){C::Not.parse('return')} + assert_raise(C::ParseError){C::Not.parse('} void f() {')} + assert_raise(C::ParseError){C::Not.parse(';')} + assert_raise(C::ParseError){C::Not.parse('int i')} + assert_raise(C::ParseError){C::Not.parse('int')} + assert_raise(C::ParseError){C::Not.parse('if (0)')} + assert_raise(C::ParseError){C::Not.parse('switch (0)')} + assert_raise(C::ParseError){C::Not.parse('for (;;)')} + assert_raise(C::ParseError){C::Not.parse('goto')} + assert_raise(C::ParseError){C::Not.parse('return')} end def test_assign check C::Assign, <<EOS x = 10 @@ -1436,19 +1433,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Assign.parse('} void f() {')} - assert_raise(ParseError){C::Assign.parse(';')} - assert_raise(ParseError){C::Assign.parse('int i')} - assert_raise(ParseError){C::Assign.parse('int')} - assert_raise(ParseError){C::Assign.parse('if (0)')} - assert_raise(ParseError){C::Assign.parse('switch (0)')} - assert_raise(ParseError){C::Assign.parse('for (;;)')} - assert_raise(ParseError){C::Assign.parse('goto')} - assert_raise(ParseError){C::Assign.parse('return')} + assert_raise(C::ParseError){C::Assign.parse('} void f() {')} + assert_raise(C::ParseError){C::Assign.parse(';')} + assert_raise(C::ParseError){C::Assign.parse('int i')} + assert_raise(C::ParseError){C::Assign.parse('int')} + assert_raise(C::ParseError){C::Assign.parse('if (0)')} + assert_raise(C::ParseError){C::Assign.parse('switch (0)')} + assert_raise(C::ParseError){C::Assign.parse('for (;;)')} + assert_raise(C::ParseError){C::Assign.parse('goto')} + assert_raise(C::ParseError){C::Assign.parse('return')} end def test_multiply_assign check C::MultiplyAssign, <<EOS x *= 10 @@ -1457,19 +1454,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::MultiplyAssign.parse('} void f() {')} - assert_raise(ParseError){C::MultiplyAssign.parse(';')} - assert_raise(ParseError){C::MultiplyAssign.parse('int i')} - assert_raise(ParseError){C::MultiplyAssign.parse('int')} - assert_raise(ParseError){C::MultiplyAssign.parse('if (0)')} - assert_raise(ParseError){C::MultiplyAssign.parse('switch (0)')} - assert_raise(ParseError){C::MultiplyAssign.parse('for (;;)')} - assert_raise(ParseError){C::MultiplyAssign.parse('goto')} - assert_raise(ParseError){C::MultiplyAssign.parse('return')} + assert_raise(C::ParseError){C::MultiplyAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::MultiplyAssign.parse(';')} + assert_raise(C::ParseError){C::MultiplyAssign.parse('int i')} + assert_raise(C::ParseError){C::MultiplyAssign.parse('int')} + assert_raise(C::ParseError){C::MultiplyAssign.parse('if (0)')} + assert_raise(C::ParseError){C::MultiplyAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::MultiplyAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::MultiplyAssign.parse('goto')} + assert_raise(C::ParseError){C::MultiplyAssign.parse('return')} end def test_divide_assign check C::DivideAssign, <<EOS x /= 10 @@ -1478,19 +1475,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::DivideAssign.parse('} void f() {')} - assert_raise(ParseError){C::DivideAssign.parse(';')} - assert_raise(ParseError){C::DivideAssign.parse('int i')} - assert_raise(ParseError){C::DivideAssign.parse('int')} - assert_raise(ParseError){C::DivideAssign.parse('if (0)')} - assert_raise(ParseError){C::DivideAssign.parse('switch (0)')} - assert_raise(ParseError){C::DivideAssign.parse('for (;;)')} - assert_raise(ParseError){C::DivideAssign.parse('goto')} - assert_raise(ParseError){C::DivideAssign.parse('return')} + assert_raise(C::ParseError){C::DivideAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::DivideAssign.parse(';')} + assert_raise(C::ParseError){C::DivideAssign.parse('int i')} + assert_raise(C::ParseError){C::DivideAssign.parse('int')} + assert_raise(C::ParseError){C::DivideAssign.parse('if (0)')} + assert_raise(C::ParseError){C::DivideAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::DivideAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::DivideAssign.parse('goto')} + assert_raise(C::ParseError){C::DivideAssign.parse('return')} end def test_mod_assign check C::ModAssign, <<EOS x %= 10 @@ -1499,19 +1496,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::ModAssign.parse('} void f() {')} - assert_raise(ParseError){C::ModAssign.parse(';')} - assert_raise(ParseError){C::ModAssign.parse('int i')} - assert_raise(ParseError){C::ModAssign.parse('int')} - assert_raise(ParseError){C::ModAssign.parse('if (0)')} - assert_raise(ParseError){C::ModAssign.parse('switch (0)')} - assert_raise(ParseError){C::ModAssign.parse('for (;;)')} - assert_raise(ParseError){C::ModAssign.parse('goto')} - assert_raise(ParseError){C::ModAssign.parse('return')} + assert_raise(C::ParseError){C::ModAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::ModAssign.parse(';')} + assert_raise(C::ParseError){C::ModAssign.parse('int i')} + assert_raise(C::ParseError){C::ModAssign.parse('int')} + assert_raise(C::ParseError){C::ModAssign.parse('if (0)')} + assert_raise(C::ParseError){C::ModAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::ModAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::ModAssign.parse('goto')} + assert_raise(C::ParseError){C::ModAssign.parse('return')} end def test_add_assign check C::AddAssign, <<EOS x += 10 @@ -1520,19 +1517,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::AddAssign.parse('} void f() {')} - assert_raise(ParseError){C::AddAssign.parse(';')} - assert_raise(ParseError){C::AddAssign.parse('int i')} - assert_raise(ParseError){C::AddAssign.parse('int')} - assert_raise(ParseError){C::AddAssign.parse('if (0)')} - assert_raise(ParseError){C::AddAssign.parse('switch (0)')} - assert_raise(ParseError){C::AddAssign.parse('for (;;)')} - assert_raise(ParseError){C::AddAssign.parse('goto')} - assert_raise(ParseError){C::AddAssign.parse('return')} + assert_raise(C::ParseError){C::AddAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::AddAssign.parse(';')} + assert_raise(C::ParseError){C::AddAssign.parse('int i')} + assert_raise(C::ParseError){C::AddAssign.parse('int')} + assert_raise(C::ParseError){C::AddAssign.parse('if (0)')} + assert_raise(C::ParseError){C::AddAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::AddAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::AddAssign.parse('goto')} + assert_raise(C::ParseError){C::AddAssign.parse('return')} end def test_subtract_assign check C::SubtractAssign, <<EOS x -= 10 @@ -1541,19 +1538,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::SubtractAssign.parse('} void f() {')} - assert_raise(ParseError){C::SubtractAssign.parse(';')} - assert_raise(ParseError){C::SubtractAssign.parse('int i')} - assert_raise(ParseError){C::SubtractAssign.parse('int')} - assert_raise(ParseError){C::SubtractAssign.parse('if (0)')} - assert_raise(ParseError){C::SubtractAssign.parse('switch (0)')} - assert_raise(ParseError){C::SubtractAssign.parse('for (;;)')} - assert_raise(ParseError){C::SubtractAssign.parse('goto')} - assert_raise(ParseError){C::SubtractAssign.parse('return')} + assert_raise(C::ParseError){C::SubtractAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::SubtractAssign.parse(';')} + assert_raise(C::ParseError){C::SubtractAssign.parse('int i')} + assert_raise(C::ParseError){C::SubtractAssign.parse('int')} + assert_raise(C::ParseError){C::SubtractAssign.parse('if (0)')} + assert_raise(C::ParseError){C::SubtractAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::SubtractAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::SubtractAssign.parse('goto')} + assert_raise(C::ParseError){C::SubtractAssign.parse('return')} end def test_shift_left_assign check C::ShiftLeftAssign, <<EOS x <<= 10 @@ -1562,19 +1559,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::ShiftLeftAssign.parse('} void f() {')} - assert_raise(ParseError){C::ShiftLeftAssign.parse(';')} - assert_raise(ParseError){C::ShiftLeftAssign.parse('int i')} - assert_raise(ParseError){C::ShiftLeftAssign.parse('int')} - assert_raise(ParseError){C::ShiftLeftAssign.parse('if (0)')} - assert_raise(ParseError){C::ShiftLeftAssign.parse('switch (0)')} - assert_raise(ParseError){C::ShiftLeftAssign.parse('for (;;)')} - assert_raise(ParseError){C::ShiftLeftAssign.parse('goto')} - assert_raise(ParseError){C::ShiftLeftAssign.parse('return')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse(';')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse('int i')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse('int')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse('if (0)')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse('goto')} + assert_raise(C::ParseError){C::ShiftLeftAssign.parse('return')} end def test_shift_right_assign check C::ShiftRightAssign, <<EOS x >>= 10 @@ -1583,19 +1580,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::ShiftRightAssign.parse('} void f() {')} - assert_raise(ParseError){C::ShiftRightAssign.parse(';')} - assert_raise(ParseError){C::ShiftRightAssign.parse('int i')} - assert_raise(ParseError){C::ShiftRightAssign.parse('int')} - assert_raise(ParseError){C::ShiftRightAssign.parse('if (0)')} - assert_raise(ParseError){C::ShiftRightAssign.parse('switch (0)')} - assert_raise(ParseError){C::ShiftRightAssign.parse('for (;;)')} - assert_raise(ParseError){C::ShiftRightAssign.parse('goto')} - assert_raise(ParseError){C::ShiftRightAssign.parse('return')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse(';')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse('int i')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse('int')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse('if (0)')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse('goto')} + assert_raise(C::ParseError){C::ShiftRightAssign.parse('return')} end def test_bit_and_assign check C::BitAndAssign, <<EOS x &= 10 @@ -1604,19 +1601,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::BitAndAssign.parse('} void f() {')} - assert_raise(ParseError){C::BitAndAssign.parse(';')} - assert_raise(ParseError){C::BitAndAssign.parse('int i')} - assert_raise(ParseError){C::BitAndAssign.parse('int')} - assert_raise(ParseError){C::BitAndAssign.parse('if (0)')} - assert_raise(ParseError){C::BitAndAssign.parse('switch (0)')} - assert_raise(ParseError){C::BitAndAssign.parse('for (;;)')} - assert_raise(ParseError){C::BitAndAssign.parse('goto')} - assert_raise(ParseError){C::BitAndAssign.parse('return')} + assert_raise(C::ParseError){C::BitAndAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::BitAndAssign.parse(';')} + assert_raise(C::ParseError){C::BitAndAssign.parse('int i')} + assert_raise(C::ParseError){C::BitAndAssign.parse('int')} + assert_raise(C::ParseError){C::BitAndAssign.parse('if (0)')} + assert_raise(C::ParseError){C::BitAndAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::BitAndAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::BitAndAssign.parse('goto')} + assert_raise(C::ParseError){C::BitAndAssign.parse('return')} end def test_bit_xor_assign check C::BitXorAssign, <<EOS x ^= 10 @@ -1625,19 +1622,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::BitXorAssign.parse('} void f() {')} - assert_raise(ParseError){C::BitXorAssign.parse(';')} - assert_raise(ParseError){C::BitXorAssign.parse('int i')} - assert_raise(ParseError){C::BitXorAssign.parse('int')} - assert_raise(ParseError){C::BitXorAssign.parse('if (0)')} - assert_raise(ParseError){C::BitXorAssign.parse('switch (0)')} - assert_raise(ParseError){C::BitXorAssign.parse('for (;;)')} - assert_raise(ParseError){C::BitXorAssign.parse('goto')} - assert_raise(ParseError){C::BitXorAssign.parse('return')} + assert_raise(C::ParseError){C::BitXorAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::BitXorAssign.parse(';')} + assert_raise(C::ParseError){C::BitXorAssign.parse('int i')} + assert_raise(C::ParseError){C::BitXorAssign.parse('int')} + assert_raise(C::ParseError){C::BitXorAssign.parse('if (0)')} + assert_raise(C::ParseError){C::BitXorAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::BitXorAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::BitXorAssign.parse('goto')} + assert_raise(C::ParseError){C::BitXorAssign.parse('return')} end def test_bit_or_assign check C::BitOrAssign, <<EOS x |= 10 @@ -1646,19 +1643,19 @@ lval: Variable name: "x" rval: IntLiteral val: 10 EOS - assert_raise(ParseError){C::BitOrAssign.parse('} void f() {')} - assert_raise(ParseError){C::BitOrAssign.parse(';')} - assert_raise(ParseError){C::BitOrAssign.parse('int i')} - assert_raise(ParseError){C::BitOrAssign.parse('int')} - assert_raise(ParseError){C::BitOrAssign.parse('if (0)')} - assert_raise(ParseError){C::BitOrAssign.parse('switch (0)')} - assert_raise(ParseError){C::BitOrAssign.parse('for (;;)')} - assert_raise(ParseError){C::BitOrAssign.parse('goto')} - assert_raise(ParseError){C::BitOrAssign.parse('return')} + assert_raise(C::ParseError){C::BitOrAssign.parse('} void f() {')} + assert_raise(C::ParseError){C::BitOrAssign.parse(';')} + assert_raise(C::ParseError){C::BitOrAssign.parse('int i')} + assert_raise(C::ParseError){C::BitOrAssign.parse('int')} + assert_raise(C::ParseError){C::BitOrAssign.parse('if (0)')} + assert_raise(C::ParseError){C::BitOrAssign.parse('switch (0)')} + assert_raise(C::ParseError){C::BitOrAssign.parse('for (;;)')} + assert_raise(C::ParseError){C::BitOrAssign.parse('goto')} + assert_raise(C::ParseError){C::BitOrAssign.parse('return')} end def test_pointer check C::Pointer, <<EOS int * @@ -1670,13 +1667,13 @@ const volatile unsigned int* ---- Pointer type: Int (const volatile unsigned) EOS - assert_raise(ParseError){C::Pointer.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Pointer.parse('1); (int')} - assert_raise(ParseError){C::Pointer.parse('void')} + assert_raise(C::ParseError){C::Pointer.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Pointer.parse('1); (int')} + assert_raise(C::ParseError){C::Pointer.parse('void')} end def test_array check C::Array, <<EOS int[] @@ -1690,13 +1687,13 @@ Array type: Int (const volatile unsigned) length: IntLiteral val: 10 EOS - assert_raise(ParseError){C::Array.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Array.parse('1); (int')} - assert_raise(ParseError){C::Array.parse('void')} + assert_raise(C::ParseError){C::Array.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Array.parse('1); (int')} + assert_raise(C::ParseError){C::Array.parse('void')} end def test_function check C::Function, <<EOS void() @@ -1715,13 +1712,13 @@ name: "x" - Parameter type: Int name: "y" EOS - assert_raise(ParseError){C::Function.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Function.parse('1); (int')} - assert_raise(ParseError){C::Function.parse('void')} + assert_raise(C::ParseError){C::Function.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Function.parse('1); (int')} + assert_raise(C::ParseError){C::Function.parse('void')} end def test_struct check C::Struct, <<EOS struct s @@ -1742,13 +1739,13 @@ - Declarator name: "j" num_bits: IntLiteral val: 4 EOS - assert_raise(ParseError){C::Struct.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Struct.parse('1); (int')} - assert_raise(ParseError){C::Struct.parse('void')} + assert_raise(C::ParseError){C::Struct.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Struct.parse('1); (int')} + assert_raise(C::ParseError){C::Struct.parse('void')} end def test_union check C::Union, <<EOS union s @@ -1769,13 +1766,13 @@ - Declarator name: "j" num_bits: IntLiteral val: 4 EOS - assert_raise(ParseError){C::Union.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Union.parse('1); (int')} - assert_raise(ParseError){C::Union.parse('void')} + assert_raise(C::ParseError){C::Union.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Union.parse('1); (int')} + assert_raise(C::ParseError){C::Union.parse('void')} end def test_enum check C::Enum, <<EOS enum s @@ -1795,132 +1792,132 @@ - Enumerator name: "Y" - Enumerator name: "Z" EOS - assert_raise(ParseError){C::Enum.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Enum.parse('1); (int')} - assert_raise(ParseError){C::Enum.parse('void')} + assert_raise(C::ParseError){C::Enum.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Enum.parse('1); (int')} + assert_raise(C::ParseError){C::Enum.parse('void')} end def test_custom_type - assert_raise(ParseError){C::CustomType.parse('1);} void f() {(int')} - assert_raise(ParseError){C::CustomType.parse('1); (int')} - assert_raise(ParseError){C::CustomType.parse('void')} + assert_raise(C::ParseError){C::CustomType.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::CustomType.parse('1); (int')} + assert_raise(C::ParseError){C::CustomType.parse('void')} end def test_void check C::Void, <<EOS const void ---- Void (const) EOS - assert_raise(ParseError){C::Void.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Void.parse('1); (int')} - assert_raise(ParseError){C::Void.parse('int')} + assert_raise(C::ParseError){C::Void.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Void.parse('1); (int')} + assert_raise(C::ParseError){C::Void.parse('int')} end def test_int check C::Int, <<EOS const int ---- Int (const) EOS - assert_raise(ParseError){C::Int.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Int.parse('1); (int')} - assert_raise(ParseError){C::Int.parse('void')} + assert_raise(C::ParseError){C::Int.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Int.parse('1); (int')} + assert_raise(C::ParseError){C::Int.parse('void')} end def test_float check C::Float, <<EOS const float ---- Float (const) EOS - assert_raise(ParseError){C::Float.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Float.parse('1); (int')} - assert_raise(ParseError){C::Float.parse('void')} + assert_raise(C::ParseError){C::Float.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Float.parse('1); (int')} + assert_raise(C::ParseError){C::Float.parse('void')} end def test_char check C::Char, <<EOS const char ---- Char (const) EOS - assert_raise(ParseError){C::Char.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Char.parse('1); (int')} - assert_raise(ParseError){C::Char.parse('void')} + assert_raise(C::ParseError){C::Char.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Char.parse('1); (int')} + assert_raise(C::ParseError){C::Char.parse('void')} end def test_bool check C::Bool, <<EOS const _Bool ---- Bool (const) EOS - assert_raise(ParseError){C::Bool.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Bool.parse('1); (int')} - assert_raise(ParseError){C::Bool.parse('void')} + assert_raise(C::ParseError){C::Bool.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Bool.parse('1); (int')} + assert_raise(C::ParseError){C::Bool.parse('void')} end def test_complex check C::Complex, <<EOS const _Complex float ---- Complex (const) EOS - assert_raise(ParseError){C::Complex.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Complex.parse('1); (int')} - assert_raise(ParseError){C::Complex.parse('void')} + assert_raise(C::ParseError){C::Complex.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Complex.parse('1); (int')} + assert_raise(C::ParseError){C::Complex.parse('void')} end def test_imaginary check C::Imaginary, <<EOS const _Imaginary float ---- Imaginary (const) EOS - assert_raise(ParseError){C::Imaginary.parse('1);} void f() {(int')} - assert_raise(ParseError){C::Imaginary.parse('1); (int')} - assert_raise(ParseError){C::Imaginary.parse('void')} + assert_raise(C::ParseError){C::Imaginary.parse('1);} void f() {(int')} + assert_raise(C::ParseError){C::Imaginary.parse('1); (int')} + assert_raise(C::ParseError){C::Imaginary.parse('void')} end def test_string_literal check C::StringLiteral, <<EOS "hello" ---- StringLiteral val: "hello" EOS - assert_raise(ParseError){C::StringLiteral.parse('} void f() {')} - assert_raise(ParseError){C::StringLiteral.parse(';')} - assert_raise(ParseError){C::StringLiteral.parse('int i')} - assert_raise(ParseError){C::StringLiteral.parse('int')} - assert_raise(ParseError){C::StringLiteral.parse('if (0)')} - assert_raise(ParseError){C::StringLiteral.parse('switch (0)')} - assert_raise(ParseError){C::StringLiteral.parse('for (;;)')} - assert_raise(ParseError){C::StringLiteral.parse('goto')} - assert_raise(ParseError){C::StringLiteral.parse('return')} + assert_raise(C::ParseError){C::StringLiteral.parse('} void f() {')} + assert_raise(C::ParseError){C::StringLiteral.parse(';')} + assert_raise(C::ParseError){C::StringLiteral.parse('int i')} + assert_raise(C::ParseError){C::StringLiteral.parse('int')} + assert_raise(C::ParseError){C::StringLiteral.parse('if (0)')} + assert_raise(C::ParseError){C::StringLiteral.parse('switch (0)')} + assert_raise(C::ParseError){C::StringLiteral.parse('for (;;)')} + assert_raise(C::ParseError){C::StringLiteral.parse('goto')} + assert_raise(C::ParseError){C::StringLiteral.parse('return')} end def test_char_literal check C::CharLiteral, <<EOS 'x' ---- CharLiteral val: "x" EOS - assert_raise(ParseError){C::CharLiteral.parse('} void f() {')} - assert_raise(ParseError){C::CharLiteral.parse(';')} - assert_raise(ParseError){C::CharLiteral.parse('int i')} - assert_raise(ParseError){C::CharLiteral.parse('int')} - assert_raise(ParseError){C::CharLiteral.parse('if (0)')} - assert_raise(ParseError){C::CharLiteral.parse('switch (0)')} - assert_raise(ParseError){C::CharLiteral.parse('for (;;)')} - assert_raise(ParseError){C::CharLiteral.parse('goto')} - assert_raise(ParseError){C::CharLiteral.parse('return')} + assert_raise(C::ParseError){C::CharLiteral.parse('} void f() {')} + assert_raise(C::ParseError){C::CharLiteral.parse(';')} + assert_raise(C::ParseError){C::CharLiteral.parse('int i')} + assert_raise(C::ParseError){C::CharLiteral.parse('int')} + assert_raise(C::ParseError){C::CharLiteral.parse('if (0)')} + assert_raise(C::ParseError){C::CharLiteral.parse('switch (0)')} + assert_raise(C::ParseError){C::CharLiteral.parse('for (;;)')} + assert_raise(C::ParseError){C::CharLiteral.parse('goto')} + assert_raise(C::ParseError){C::CharLiteral.parse('return')} end def test_compound_literal check C::CompoundLiteral, <<EOS (struct s){.x [0] = 10, .y = 20, 30} @@ -1945,70 +1942,70 @@ val: 20 - MemberInit init: IntLiteral val: 30 EOS - assert_raise(ParseError){C::CompoundLiteral.parse('} void f() {')} - assert_raise(ParseError){C::CompoundLiteral.parse(';')} - assert_raise(ParseError){C::CompoundLiteral.parse('int i')} - assert_raise(ParseError){C::CompoundLiteral.parse('int')} - assert_raise(ParseError){C::CompoundLiteral.parse('if (0)')} - assert_raise(ParseError){C::CompoundLiteral.parse('switch (0)')} - assert_raise(ParseError){C::CompoundLiteral.parse('for (;;)')} - assert_raise(ParseError){C::CompoundLiteral.parse('goto')} - assert_raise(ParseError){C::CompoundLiteral.parse('return')} + assert_raise(C::ParseError){C::CompoundLiteral.parse('} void f() {')} + assert_raise(C::ParseError){C::CompoundLiteral.parse(';')} + assert_raise(C::ParseError){C::CompoundLiteral.parse('int i')} + assert_raise(C::ParseError){C::CompoundLiteral.parse('int')} + assert_raise(C::ParseError){C::CompoundLiteral.parse('if (0)')} + assert_raise(C::ParseError){C::CompoundLiteral.parse('switch (0)')} + assert_raise(C::ParseError){C::CompoundLiteral.parse('for (;;)')} + assert_raise(C::ParseError){C::CompoundLiteral.parse('goto')} + assert_raise(C::ParseError){C::CompoundLiteral.parse('return')} end def test_int_literal check C::IntLiteral, <<EOS 1 ---- IntLiteral val: 1 EOS - assert_raise(ParseError){C::IntLiteral.parse('} void f() {')} - assert_raise(ParseError){C::IntLiteral.parse(';')} - assert_raise(ParseError){C::IntLiteral.parse('int i')} - assert_raise(ParseError){C::IntLiteral.parse('int')} - assert_raise(ParseError){C::IntLiteral.parse('if (0)')} - assert_raise(ParseError){C::IntLiteral.parse('switch (0)')} - assert_raise(ParseError){C::IntLiteral.parse('for (;;)')} - assert_raise(ParseError){C::IntLiteral.parse('goto')} - assert_raise(ParseError){C::IntLiteral.parse('return')} + assert_raise(C::ParseError){C::IntLiteral.parse('} void f() {')} + assert_raise(C::ParseError){C::IntLiteral.parse(';')} + assert_raise(C::ParseError){C::IntLiteral.parse('int i')} + assert_raise(C::ParseError){C::IntLiteral.parse('int')} + assert_raise(C::ParseError){C::IntLiteral.parse('if (0)')} + assert_raise(C::ParseError){C::IntLiteral.parse('switch (0)')} + assert_raise(C::ParseError){C::IntLiteral.parse('for (;;)')} + assert_raise(C::ParseError){C::IntLiteral.parse('goto')} + assert_raise(C::ParseError){C::IntLiteral.parse('return')} end def test_float_literal check C::FloatLiteral, <<EOS 1.0 ---- FloatLiteral val: 1.0 EOS - assert_raise(ParseError){C::FloatLiteral.parse('} void f() {')} - assert_raise(ParseError){C::FloatLiteral.parse(';')} - assert_raise(ParseError){C::FloatLiteral.parse('int i')} - assert_raise(ParseError){C::FloatLiteral.parse('int')} - assert_raise(ParseError){C::FloatLiteral.parse('if (0)')} - assert_raise(ParseError){C::FloatLiteral.parse('switch (0)')} - assert_raise(ParseError){C::FloatLiteral.parse('for (;;)')} - assert_raise(ParseError){C::FloatLiteral.parse('goto')} - assert_raise(ParseError){C::FloatLiteral.parse('return')} + assert_raise(C::ParseError){C::FloatLiteral.parse('} void f() {')} + assert_raise(C::ParseError){C::FloatLiteral.parse(';')} + assert_raise(C::ParseError){C::FloatLiteral.parse('int i')} + assert_raise(C::ParseError){C::FloatLiteral.parse('int')} + assert_raise(C::ParseError){C::FloatLiteral.parse('if (0)')} + assert_raise(C::ParseError){C::FloatLiteral.parse('switch (0)')} + assert_raise(C::ParseError){C::FloatLiteral.parse('for (;;)')} + assert_raise(C::ParseError){C::FloatLiteral.parse('goto')} + assert_raise(C::ParseError){C::FloatLiteral.parse('return')} end def test_variable check C::Variable, <<EOS x ---- Variable name: "x" EOS - assert_raise(ParseError){C::Variable.parse('} void f() {')} - assert_raise(ParseError){C::Variable.parse(';')} - assert_raise(ParseError){C::Variable.parse('int i')} - assert_raise(ParseError){C::Variable.parse('int')} - assert_raise(ParseError){C::Variable.parse('if (0)')} - assert_raise(ParseError){C::Variable.parse('switch (0)')} - assert_raise(ParseError){C::Variable.parse('for (;;)')} - assert_raise(ParseError){C::Variable.parse('goto')} - assert_raise(ParseError){C::Variable.parse('return')} + assert_raise(C::ParseError){C::Variable.parse('} void f() {')} + assert_raise(C::ParseError){C::Variable.parse(';')} + assert_raise(C::ParseError){C::Variable.parse('int i')} + assert_raise(C::ParseError){C::Variable.parse('int')} + assert_raise(C::ParseError){C::Variable.parse('if (0)')} + assert_raise(C::ParseError){C::Variable.parse('switch (0)')} + assert_raise(C::ParseError){C::Variable.parse('for (;;)')} + assert_raise(C::ParseError){C::Variable.parse('goto')} + assert_raise(C::ParseError){C::Variable.parse('return')} end end