Permalink
Browse files

Bring code up to date

  • Loading branch information...
1 parent 75dff82 commit 48a4bff9d0835bd98446b3fb8ad685e783a097fc @xrl committed Apr 13, 2012
Showing with 24 additions and 25 deletions.
  1. +1 −1 test/exp_test.rb
  2. +7 −10 test/functioncall_test.rb
  3. +4 −2 test/helper_methods.rb
  4. +10 −10 test/name_test.rb
  5. +2 −2 test/prefixexp_test.rb
View
@@ -15,7 +15,7 @@ def test_parse
parse :exp, "true", [:lit, true]
end
assert_nothing_raised do
- parse :exp, "1", [:integer, 1]
+ parse :exp, "1", [:number, 1.0]
end
assert_nothing_raised do
parse :exp, %Q{"kitties"}, [:string, "kitties"]
View
@@ -6,28 +6,25 @@ class FunctioncallTest < Test::Unit::TestCase
def test_parse
assert_nothing_raised do
- parse "invokeme()", :functioncall
+ parse :functioncall, "invokeme()", [:functioncall, :invokeme, []]
end
assert_nothing_raised do
- parse "so_true(false)", :functioncall
+ parse :functioncall, "so_true(false)", [:functioncall, :so_true,[false]]
end
assert_nothing_raised do
- parse "set_bank_balance(nil)", :functioncall
+ parse :functioncall, "set_bank_balance(nil)", [:functioncall, :set_bank_balance, [nil]]
end
assert_nothing_raised do
- parse "evaluate_expression(100)", :functioncall
+ parse :functioncall, "evaluate_expression(100)", [:functioncall, :evalute_expression, [100]]
end
assert_nothing_raised do
- parse "evaluate_expression(\"yessir\")", :functioncall
+ parse :functioncall, "evaluate_expression(\"yessir\")", [:functioncall, :evalute_expression, ["yessir"]]
end
assert_nothing_raised do
- parse "evaluate_expression(...)", :functioncall
+ parse :functioncall, "evaluate_expression(...)", [:functioncall,:evaluate_expression,[:ellipsis]]
end
assert_nothing_raised do
- parse "evaluate_expression(somevar)", :functioncall
- end
- assert_nothing_raised do
- # parse "evaluate_expression(somevar())", :functioncall
+ parse :functioncall, "evaluate_expression(somevar)", [:functioncall,:evaluate_expression,[:var,:somevar]]
end
end
View
@@ -4,7 +4,9 @@ module TestHelperMethods
def parse (rule, input, sexp)
parser = Lupin::Parser.new(input)
# Is the string at least partially acceptable?
- assert parser.parse(rule.to_s)
- raise RuntimeError, "Expected #{sexp} but got #{parser.result}" unless sexp == parser.result
+ assert parser.parse(rule.to_s), "Could not apply #{rule.inspect} to `#{input}'"
+ if sexp != parser.result
+ raise RuntimeError, "Expected #{sexp.inspect} but got #{parser.result.inspect}"
+ end
end
end
View
@@ -6,29 +6,29 @@ class NameTest < Test::Unit::TestCase
def test_names
assert_nothing_raised do
- parse "someName", :name
- parse "HITHERE", :name
- parse "_Leading", :name
- parse "_LEADING", :name
- parse "Has3Numbers94", :name
+ parse :name, "someName", [:name,:someName]
+ parse :name, "HITHERE", [:name, :HITHERE]
+ parse :name, "_Leading", [:name, :_Leading]
+ parse :name, "_LEADING", [:name, :_LEADING]
+ parse :name, "Has3Numbers94", [:name, :Has3Numbers94]
end
end
def test_bad_names
assert_raise RuntimeError do
- parse "0", :name
+ parse :name, "0", nil
end
assert_raise RuntimeError do
- parse "$", :name
+ parse :name, "$", nil
end
assert_raise RuntimeError do
- parse "0badname", :name
+ parse :name, "0badname", nil
end
assert_raise RuntimeError do
- parse "no spaces allowed", :name
+ parse :name, "no spaces allowed", nil
end
assert_raise RuntimeError do
- parse " leading_spaces_bad", :name
+ parse :name, " leading_spaces_bad", nil
end
end
end
View
@@ -6,10 +6,10 @@ class PrefixexpTest < Test::Unit::TestCase
def test_parse
assert_nothing_raised do
- parse "(nil)", :prefixexp
+ parse :prefixexp, "(nil)", [:prefixexp, [:lit,nil]]
end
assert_nothing_raised do
- parse "some_var", :prefixexp
+ parse :prefixexp, "some_var", [:prefixexp, [:name,:some_var]]
end
assert_nothing_raised do
# parse "hey()", :prefixexp

0 comments on commit 48a4bff

Please sign in to comment.