mirror of
https://github.com/rubyjs/mini_racer
synced 2023-03-27 23:21:28 -04:00
Implement #load (initial trivial implementation)
This commit is contained in:
parent
1adb2f9c6d
commit
d6c173f533
3 changed files with 14 additions and 0 deletions
|
@ -62,7 +62,11 @@ module MiniRacer
|
|||
if options
|
||||
@timeout = options[:timeout]
|
||||
end
|
||||
end
|
||||
|
||||
def load(filename)
|
||||
# TODO do this native cause no need to allocate VALUE here
|
||||
eval(File.read(filename))
|
||||
end
|
||||
|
||||
def eval(str)
|
||||
|
|
1
test/file.js
Normal file
1
test/file.js
Normal file
|
@ -0,0 +1 @@
|
|||
var hello = "world";
|
|
@ -139,4 +139,13 @@ raise FooError, "I like foos"
|
|||
end
|
||||
end
|
||||
|
||||
def test_load
|
||||
context = MiniRacer::Context.new
|
||||
context.load(File.dirname(__FILE__) + "/file.js")
|
||||
assert_equal "world", context.eval("hello")
|
||||
assert_raises do
|
||||
context.load(File.dirname(__FILE__) + "/missing.js")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue