Skip to content

Commit

Permalink
Enable some more Class.new specs
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Oct 18, 2013
1 parent 2d28028 commit 8158bfb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions corelib/class.rb
@@ -1,6 +1,10 @@
class Class
def self.new(sup = Object, &block)
%x{
if (!sup._isClass || sup.__mod__) {
#{raise TypeError, "superclass must be a Class"};
}
function AnonClass(){};
var klass = Opal.boot(sup, AnonClass)
klass._name = nil;
Expand Down
1 change: 1 addition & 0 deletions corelib/module.rb
Expand Up @@ -7,6 +7,7 @@ def self.new(&block)
klass._scope = Module._scope;
klass._klass = Module;
klass.__dep__ = []
klass.__mod__ = true;
if (block !== nil) {
var block_self = block._s;
Expand Down
7 changes: 6 additions & 1 deletion corelib/runtime.js
Expand Up @@ -336,7 +336,12 @@
var scope = base_module._scope;

if (value._isClass && value._name === nil) {
value._name = base_module._name + '::' + name;
if (base_module === RubyObject) {
value._name = name;
}
else {
value._name = base_module._name + '::' + name;
}
}

scope.constants.push(name);
Expand Down
2 changes: 1 addition & 1 deletion lib/opal/parser.rb
Expand Up @@ -2043,7 +2043,7 @@ def process_colon3(exp, level)

def process_casgn3(sexp, level)
cid, rhs = sexp
[f("$opal.Object._scope.#{cid} = "), process(rhs)]
[f("$opal.casgn($opal.Object, '#{cid}', "), process(rhs), f(")")]
end

# super a, b, c
Expand Down
2 changes: 0 additions & 2 deletions spec/filters/bugs/class.rb
@@ -1,6 +1,4 @@
opal_filter "Class" do
fails "Class.new raises a TypeError if passed a metaclass"
fails "Class.new creates a class that can be given a name by assigning it to a constant"
fails "Class.new raises a TypeError when given a non-Class"
fails "Class#new passes the block to #initialize"
end

0 comments on commit 8158bfb

Please sign in to comment.