require 'test/unit' require 'rockit/assembler/llvm/instructions' include Rockit::Assembler::LLVM class UTestLLVMInstructions < Test::Unit::TestCase def test_01_NamedValue_valid nv1 = NamedValue.new("foo") assert_equal("%foo", nv1.to_llvm) nv2 = NamedValue.new("DivByZero") assert_equal("%DivByZero", nv2.to_llvm) nv3 = NamedValue.new("a.really.long.identifier") assert_equal("%a.really.long.identifier", nv3.to_llvm) end def test_02_NamedValue_invalid assert_raises(ArgumentError) {NamedValue.new("12")} assert_raises(ArgumentError) {NamedValue.new("%")} end def test_03_UnnamedValue_valid u1 = UnnamedValue.new(0) assert_equal("%0", u1.to_llvm) u2 = UnnamedValue.new(12) assert_equal("%12", u2.to_llvm) u3 = UnnamedValue.new(2) assert_equal("%2", u3.to_llvm) u4 = UnnamedValue.new(44) assert_equal("%44", u4.to_llvm) end def test_04_UnnamedValue_invalid assert_raises(ArgumentError) {UnnamedValue.new(-1)} assert_raises(ArgumentError) {UnnamedValue.new(-18743)} end end