Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0a3efa251cba
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4f18d9ec4b78
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Feb 28, 2015

  1. Module#const_get accepts a scoped constant name

    Fix issue #694
    vais committed Feb 28, 2015
    Copy the full SHA
    7a9ff2b View commit details
  2. Merge pull request #713 from vais/issue694

    Module#const_get accepts a scoped constant name
    meh committed Feb 28, 2015
    Copy the full SHA
    4f18d9e View commit details
Showing with 16 additions and 1 deletion.
  1. +2 −0 CHANGELOG.md
  2. +3 −1 opal/corelib/module.rb
  3. +10 −0 spec/filters/bugs/module.rb
  4. +1 −0 spec/rubyspecs
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@

* `Array#product` implementation fully compliant with rubyspec

* `Module#const_get` accepts a scoped constant name

## 0.7.1 2015-02-14

* CLI options `-d` and `-v` now set respectively `$DEBUG` and `$VERBOSE`
4 changes: 3 additions & 1 deletion opal/corelib/module.rb
Original file line number Diff line number Diff line change
@@ -208,8 +208,10 @@ def const_defined?(name, inherit = true)
end

def const_get(name, inherit = true)
if name['::'] && name != '::'
return name.split('::').inject(self){|o, c| o.const_get(c)}
end
raise NameError, "wrong constant name #{name}" unless name =~ /^[A-Z]\w*$/

%x{
var scopes = [self.$$scope];
10 changes: 10 additions & 0 deletions spec/filters/bugs/module.rb
Original file line number Diff line number Diff line change
@@ -11,6 +11,16 @@

fails "Module#const_defined? should not search parent scopes of classes and modules if inherit is false"
fails "Module#const_get should not search parent scopes of classes and modules if inherit is false"
fails "Module#const_get raises a NameError with the not found constant symbol"
fails "Module#const_get calls #to_str to convert the given name to a String"
fails "Module#const_get raises a TypeError if conversion to a String by calling #to_str fails"
fails "Module#const_get does not search the singleton class of a Class or Module"
fails "Module#const_get raises a NameError if the constant is defined in the receiver's supperclass and the inherit flag is false"
fails "Module#const_get accepts a toplevel scope qualifier"
fails "Module#const_get raises a NameError if a Symbol is a scoped constant name"
fails "Module#const_get with dynamically assigned constants searches a module included in the immediate class before the superclass"
fails "Module#const_get with dynamically assigned constants searches a module included in the superclass"
fails "Module#const_get with dynamically assigned constants searches the superclass chain"

fails "Module#class_variable_set sets the value of a class variable with the given name defined in an included module"
fails "Module#class_variable_get returns the value of a class variable with the given name defined in an included module"
1 change: 1 addition & 0 deletions spec/rubyspecs
Original file line number Diff line number Diff line change
@@ -72,6 +72,7 @@ corelib/core/matchdata/values_at_spec
corelib/core/module/class_variable_get_spec
corelib/core/module/class_variable_set_spec
corelib/core/module/module_function_spec
corelib/core/module/const_get_spec

corelib/core/range/begin_spec
corelib/core/range/case_compare_spec