Sha256: 3b7a7037a4de313070557c089411332067f90136fd0eef3abffa545fec9371c3

Contents?: true

Size: 618 Bytes

Versions: 51

Compression:

Stored size: 618 Bytes

Contents

require 'spec_helper'

$OPAL_TOP_LEVEL_OBJECT = self

def self.some_main_method
  3.142
end

def some_top_level_method_is_defined
  42
end

describe "Defining normal methods at the top level" do
  it "should define them on Object, not main" do
    Object.new.some_top_level_method_is_defined.should == 42
  end
end

describe "Defining singleton methods on main" do
  it "should define it on main directly" do
    $OPAL_TOP_LEVEL_OBJECT.some_main_method.should == 3.142
  end

  it "should not define the method for all Objects" do
    lambda { Object.new.some_main_method }.should raise_error(NoMethodError)
  end
end

Version data entries

51 entries across 51 versions & 3 rubygems

Version Path
opal-0.10.6 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.6.beta spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.5 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.4 spec/opal/core/runtime/main_methods_spec.rb
opal-0.11.0.rc1 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.3 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.2 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.1 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.0 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.0.rc2 spec/opal/core/runtime/main_methods_spec.rb
opal-0.9.4 spec/opal/core/runtime/main_methods_spec.rb
opal-0.9.3 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.0.rc1 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.0.beta5 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.0.beta4 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.0.beta3 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.0.beta2 spec/opal/core/runtime/main_methods_spec.rb
opal-0.10.0.beta1 spec/opal/core/runtime/main_methods_spec.rb
opal-0.9.2 spec/opal/core/runtime/main_methods_spec.rb
opal-0.9.0 spec/opal/core/runtime/main_methods_spec.rb