From 00778c58020aff02369579b3d86b1e05e9cd932e Mon Sep 17 00:00:00 2001 From: inglorion Date: Sun, 20 Mar 2011 12:48:03 +0100 Subject: [PATCH] Changed "toplevel" to "top_level" to align with existing code --- lib/voodoo/validator.rb | 2 +- test/test_validator.rb | 86 ++++++++++++++++++++++++------------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/voodoo/validator.rb b/lib/voodoo/validator.rb index 3f48c26..6e1c933 100644 --- a/lib/voodoo/validator.rb +++ b/lib/voodoo/validator.rb @@ -260,7 +260,7 @@ module Voodoo # Validates a top-level directive. # Returns true if the directive is valid. # Raises ValidationError if the directive is not valid. - def validate_toplevel code + def validate_top_level code begin case code[0] when :align diff --git a/test/test_validator.rb b/test/test_validator.rb index 9cc15c2..f94723a 100755 --- a/test/test_validator.rb +++ b/test/test_validator.rb @@ -25,19 +25,19 @@ def test_validator end expect_true("align_no_parameters") { - validate_toplevel [:align] + validate_top_level [:align] } expect_ValidationError("align_no_integer") { - validate_toplevel [:align, "wrong"] + validate_top_level [:align, "wrong"] } expect_true("align_with_parameter") { - validate_toplevel [:align, 16] + validate_top_level [:align, 16] } expect_ValidationError("align_too_many_parameters") { - validate_toplevel [:align, 16, "wrong"] + validate_top_level [:align, 16, "wrong"] } expect_true("at_number_expression") { @@ -61,15 +61,15 @@ def test_validator } expect_true("block_level") { - validate_toplevel [:block, [:call, :foo]] + validate_top_level [:block, [:call, :foo]] } - expect_true("byte_toplevel") { - validate_toplevel [:byte, 42] + expect_true("byte_top_level") { + validate_top_level [:byte, 42] } - expect_ValidationError("byte_toplevel_no_integer") { - validate_toplevel [:byte, "wrong"] + expect_ValidationError("byte_top_level_no_integer") { + validate_top_level [:byte, "wrong"] } [:call, :"tail-call"].each do |call| @@ -85,8 +85,8 @@ def test_validator validate_statement [call, :foo] } - expect_true("#{call}_toplevel") { - validate_toplevel [call, :foo] + expect_true("#{call}_top_level") { + validate_top_level [call, :foo] } expect_ValidationError("#{call}_without_parameters") { @@ -103,11 +103,11 @@ def test_validator } expect_ValidationError("function_missing_formals") { - validate_toplevel [:function] + validate_top_level [:function] } expect_true("function_ok") { - validate_toplevel [:function, [:x, :y], [:return, [:add, :x, :y]]] + validate_top_level [:function, [:x, :y], [:return, [:add, :x, :y]]] } [:byte, :word].each do |thing| @@ -172,8 +172,8 @@ def test_validator validate_statement [:goto, :foo, 42] } - expect_true("goto_toplevel") { - validate_toplevel [:goto, :foo] + expect_true("goto_top_level") { + validate_top_level [:goto, :foo] } [:ifeq, :ifge, :ifgt, :ifle, :iflt, :ifne].each do |cnd| @@ -189,8 +189,8 @@ def test_validator validate_statement [cnd, [:x, :y], [[:call, :foo]]] } - expect_true("#{cnd}_toplevel") { - validate_toplevel [cnd, [:x, :y], [[:call, :foo]]] + expect_true("#{cnd}_top_level") { + validate_top_level [cnd, [:x, :y], [[:call, :foo]]] } expect_ValidationError("let_inside_#{cnd}_statement") { @@ -203,16 +203,16 @@ def test_validator end [:export, :import].each do |directive| - expect_true("#{directive}_toplevel") { - validate_toplevel [directive, :foo] + expect_true("#{directive}_top_level") { + validate_top_level [directive, :foo] } - expect_true("#{directive}_toplevel_multiple_parameters") { - validate_toplevel [directive, :foo, :bar, :baz] + expect_true("#{directive}_top_level_multiple_parameters") { + validate_top_level [directive, :foo, :bar, :baz] } - expect_ValidationError("#{directive}_toplevel_no_parameters") { - validate_toplevel [directive] + expect_ValidationError("#{directive}_top_level_no_parameters") { + validate_top_level [directive] } expect_ValidationError("#{directive}_statement") { @@ -236,16 +236,16 @@ def test_validator validate_statement [:label, 18] } - expect_true("label_toplevel") { - validate_toplevel [:label, :foo] + expect_true("label_top_level") { + validate_top_level [:label, :foo] } expect_true("let_inside_block") { - validate_toplevel [:block, [:let, :foo, 42], [:call, :foo]] + validate_top_level [:block, [:let, :foo, 42], [:call, :foo]] } expect_true("let_inside_function") { - validate_toplevel [:function, [:n], + validate_top_level [:function, [:n], [:let, :foo, [:mul, :n, :n]], [:call, :foo]] } @@ -278,16 +278,16 @@ def test_validator validate_statement ["wrong"] } - expect_ValidationError("no_symbol_toplevel") { - validate_toplevel ["wrong"] + expect_ValidationError("no_symbol_top_level") { + validate_top_level ["wrong"] } expect_ValidationError("no_array_statement") { validate_statement :wrong } - expect_ValidationError("no_array_toplevel") { - validate_toplevel :wrong + expect_ValidationError("no_array_top_level") { + validate_top_level :wrong } expect_true("not_expression") { @@ -303,16 +303,16 @@ def test_validator } expect_ValidationError("section_missing_name") { - validate_toplevel [:section] + validate_top_level [:section] } expect_ValidationError("section_number") { - validate_toplevel [:section, 12] + validate_top_level [:section, 12] } - expect_true("section_string") { validate_toplevel [:section, :code] } + expect_true("section_string") { validate_top_level [:section, :code] } - expect_true("section_symbol") { validate_toplevel [:section, :code] } + expect_true("section_symbol") { validate_top_level [:section, :code] } expect_true("set_statement_int") { validate_statement [:set, :x, 12] @@ -330,23 +330,23 @@ def test_validator validate_statement [:set] } - expect_true("string_toplevel") { - validate_toplevel [:string, "test"] + expect_true("string_top_level") { + validate_top_level [:string, "test"] } - expect_ValidationError("string_toplevel_no_string") { - validate_toplevel [:string, 42] + expect_ValidationError("string_top_level_no_string") { + validate_top_level [:string, 42] } expect_true("symbol_is_expression") { validate_expression :foo } - expect_true("word_toplevel") { - validate_toplevel [:word, 42] + expect_true("word_top_level") { + validate_top_level [:word, 42] } - expect_ValidationError("word_toplevel_no_integer") { - validate_toplevel [:word, "wrong"] + expect_ValidationError("word_top_level_no_integer") { + validate_top_level [:word, "wrong"] } end -- 2.11.4.GIT