Sha256: 7ef015128eb63db1e27b1f149e8965dbf3123d090ffb785d4074c9b4732d5b09

Contents?: true

Size: 734 Bytes

Versions: 22

Compression:

Stored size: 734 Bytes

Contents

%x{
  var BridgeClassProto = function() {
    this.foo = 200;
  };

  BridgeClassProto.prototype = {
    bar: 300,
    baz: 400
  };
}

class BridgeClassSpec < `BridgeClassProto`
  def get_foo
    `#{self}.foo`
  end

  def say_it
    "hello world"
  end
end

describe "Bridging native prototypes to a class" do
  it "should have a superclass of Object" do
    BridgeClassSpec.superclass.should == Object
  end

  it "should report instances as kind of bridged class" do
    obj = `new BridgeClassProto()`
    obj.class.should == BridgeClassSpec
  end

  it "should have defined instance methods present on prototype" do
    obj = `new BridgeClassProto()`
    obj.get_foo.should == 200
    obj.say_it.should == "hello world"
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
opal-0.3.44 spec/rubyspec/core/class/bridge_class_spec.rb
opal-0.3.43 spec/rubyspec/core/class/bridge_class_spec.rb
opal-0.3.42 spec/core/class/bridge_class_spec.rb
opal-0.3.41 spec/core/class/bridge_class_spec.rb
opal-0.3.40 spec/core/class/bridge_class_spec.rb
opal-0.3.39 spec/core/class/bridge_class_spec.rb
opal-0.3.38 spec/core/class/bridge_class_spec.rb
opal-0.3.37 spec/core/class/bridge_class_spec.rb
opal-0.3.36 spec/core/class/bridge_class_spec.rb
opal-0.3.35 spec/core/class/bridge_class_spec.rb
opal-0.3.34 spec/core/class/bridge_class_spec.rb
opal-0.3.33 spec/core/class/bridge_class_spec.rb
opal-0.3.32 spec/core/class/bridge_class_spec.rb
opal-0.3.31 spec/core/class/bridge_class_spec.rb
opal-0.3.30 spec/core/class/bridge_class_spec.rb
opal-0.3.29 spec/core/class/bridge_class_spec.rb
opal-0.3.28 spec/core/class/bridge_class_spec.rb
opal-0.3.27 spec/opal/class/bridge_class_spec.rb
opal-0.3.26 spec/opal/class/bridge_class_spec.rb
opal-0.3.25 spec/opal/class/bridge_class_spec.rb