Sha256: 41a5af4609f6fc395f68817d9a6f86187a9d1b0104299cbe76e7d28dca06b65d
Contents?: true
Size: 1.37 KB
Versions: 19
Compression:
Stored size: 1.37 KB
Contents
require 'spec_helper' require 'native' describe Opal::Compiler do describe "irb parser option" do it "creates Opal.irb_vars if it does not exist" do $global["Opal"].irb_vars = nil eval_js compile("0;nil", :irb => true) ($global["Opal"].irb_vars == nil).should be_false end it "does not create Opal.irb_vars if :irb option not passed" do $global["Opal"].irb_vars = nil eval_js compile("0;nil") ($global["Opal"].irb_vars == nil).should be_true end it "sets each s(:lasgn) in the top level onto irb_vars" do eval_js compile("foo = 42", :irb => true) $global["Opal"].irb_vars.foo.should == 42 end it "gets each s(:lvar) in the top level from irb_vars" do eval_js compile("foo = 3.142; bar = foo", :irb => true) $global["Opal"].irb_vars.bar.should == 3.142 end it "persists local vars between parses" do eval_js compile("foo = 'hello world'", :irb => true) eval_js compile("bar = foo.upcase", :irb => true) $global["Opal"].irb_vars.bar.should == "HELLO WORLD" end it "can reference an outer variable" do eval_js("var a = 10;" + compile("a", :irb => true)).should == 10 end it "can still call top level methods" do eval_js(compile("to_s", :irb => true)).should == "main" end def compile *args Opal::Compiler.new(*args).compile end end end
Version data entries
19 entries across 19 versions & 1 rubygems