1
0
Fork 0
mirror of https://github.com/rubyjs/mini_racer synced 2023-03-27 23:21:28 -04:00
mini_racer/test/mini_racer_test.rb
2016-05-04 16:54:51 +10:00

36 lines
819 B
Ruby

require 'test_helper'
class MiniRacerTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::MiniRacer::VERSION
end
def test_it_can_eval_int
context = MiniRacer::Context.new
assert_equal 2, context.eval('1+1')
end
def test_it_can_eval_string
context = MiniRacer::Context.new
assert_equal "1+1", context.eval('"1+1"')
end
def test_it_returns_useful_errors
context = MiniRacer::Context.new
assert_raises do
context.eval('var x=function(){boom;}; x()')
end
end
def test_floats
context = MiniRacer::Context.new
assert_equal 1.2, context.eval('1.2')
end
def test_it_remembers_stuff_in_context
context = MiniRacer::Context.new
context.eval('var x = function(){return 22;}')
assert_equal 22, context.eval('x()')
end
end