Skip to content

Commit

Permalink
Port send-only insns and write tests (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Aug 25, 2022
1 parent aea7e18 commit 9a59b9f
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 36 deletions.
120 changes: 120 additions & 0 deletions bootstraptest/test_yjit_new_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def foo(n)
end
foo(7)
}
assert_equal 'ab', %q{
def foo
"a" + "b"
end
foo
}

# setlocal, getlocal, opt_plus
assert_equal '10', %q{
Expand Down Expand Up @@ -125,6 +131,120 @@ def foo(n)
foo(777)
}

# opt_lt
assert_equal 'true', %q{1 < 2}
assert_equal 'false', %q{1 < 1}
assert_equal 'true', %q{"1" < "2"}
assert_equal 'false', %q{"1" < "1"}

# opt_le
assert_equal 'true', %q{1 <= 1}
assert_equal 'false', %q{1 <= 0}
assert_equal 'true', %q{"1" <= "1"}
assert_equal 'false', %q{"1" <= "0"}

# opt_ge
assert_equal 'true', %q{1 >= 1}
assert_equal 'false', %q{0 >= 1}
assert_equal 'true', %q{"1" >= "1"}
assert_equal 'false', %q{"0" >= "1"}

# opt_gt
assert_equal 'true', %q{2 > 1}
assert_equal 'false', %q{1 > 1}
assert_equal 'true', %q{"2" > "1"}
assert_equal 'false', %q{"1" > "1"}

# opt_mult
assert_equal '6', %q{
def foo
2 * 3
end
foo
}

# opt_div
assert_equal '3', %q{
def foo
6 / 2
end
foo
}

# opt_ltlt
assert_equal 'ab', %q{
def foo
"a" << "b"
end
foo
}

# opt_nil_p
assert_equal 'true', %q{
def foo
nil.nil?
end
foo
}

# opt_empty_p
assert_equal 'true', %q{
def foo
"".empty?
end
foo
}

# opt_succ
assert_equal '2', %q{
def foo
1.succ
end
foo
}

# opt_not
assert_equal 'false', %q{
def foo
!true
end
foo
}

# opt_size
assert_equal '2', %q{
def foo
[1, nil].size
end
foo
}

# opt_length
assert_equal '2', %q{
def foo
[1, nil].length
end
foo
}

# opt_regexpmatch2
assert_equal '0', %q{
def foo
/a/ =~ 'a'
end
foo
}

# opt_case_dispatch
assert_equal 'true', %q{
case 2
when 1
false
when 2
true
end
}

# branchunless
assert_equal '7', %q{
def foo(n)
Expand Down
Loading

0 comments on commit 9a59b9f

Please sign in to comment.