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: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d0bcfee08a82
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2c5017c394ba
Choose a head ref
  • 4 commits
  • 8 files changed
  • 1 contributor

Commits on Oct 14, 2015

  1. Copy the full SHA
    6a2d340 View commit details
  2. Copy the full SHA
    e429baf View commit details
  3. Copy the full SHA
    d49876e View commit details
  4. Copy the full SHA
    2c5017c View commit details
2 changes: 2 additions & 0 deletions spec/ruby/core/module/alias_method_spec.rb
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@

it "fails if origin method not found" do
lambda { @class.make_alias :ni, :san }.should raise_error(NameError)
# a NameError and not a NoMethodError
lambda { @class.make_alias :ni, :san }.should_not raise_error(NoMethodError)
end

it "raises RuntimeError if frozen" do
2 changes: 2 additions & 0 deletions spec/ruby/core/module/undef_method_spec.rb
Original file line number Diff line number Diff line change
@@ -50,6 +50,8 @@ class Descendant < Ancestor

it "raises a NameError when passed a missing name" do
lambda { @module.send :undef_method, :not_exist }.should raise_error(NameError)
# a NameError and not a NoMethodError
lambda { @module.send :undef_method, :not_exist }.should_not raise_error(NoMethodError)
end

describe "on frozen instance" do
6 changes: 6 additions & 0 deletions spec/ruby/language/alias_spec.rb
Original file line number Diff line number Diff line change
@@ -162,4 +162,10 @@ def test_with_check(*args)
# because it defines on the default definee / current module
ruby_exe("def foo; end; alias bla foo; print method(:bla).owner", escape: true).should == "Object"
end

it "raises a NameError when passed a missing name" do
lambda { @meta.class_eval { alias undef_method not_exist } }.should raise_error(NameError)
# a NameError and not a NoMethodError
lambda { @meta.class_eval { alias undef_method not_exist } }.should_not raise_error(NoMethodError)
end
end
6 changes: 6 additions & 0 deletions spec/ruby/language/undef_spec.rb
Original file line number Diff line number Diff line change
@@ -13,4 +13,10 @@ class ::UndefSpecClass
end
lambda { obj.meth 5 }.should raise_error(NoMethodError)
end

it "raises a NameError when passed a missing name" do
lambda { class ::UndefSpecClass; undef not_exist; end }.should raise_error(NameError)
# a NameError and not a NoMethodError
lambda { class ::UndefSpecClass; undef not_exist; end }.should_not raise_error(NoMethodError)
end
end
Original file line number Diff line number Diff line change
@@ -1881,15 +1881,8 @@ public DynamicObject undefMethods(VirtualFrame frame, DynamicObject module, Obje
private void undefMethod(VirtualFrame frame, DynamicObject module, String name) {
raiseIfFrozenNode.execute(frame);

final InternalMethod method = ModuleOperations.lookupMethod(module, name);

if (method != null) {
Layouts.MODULE.getFields(module).undefMethod(getContext(), this, method);
methodUndefinedNode.call(frame, module, "method_undefined", null, getSymbol(name));
} else {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().noMethodErrorOnModule(name, module, this));
}
Layouts.MODULE.getFields(module).undefMethod(getContext(), this, name);
methodUndefinedNode.call(frame, module, "method_undefined", null, getSymbol(name));
}

}
Original file line number Diff line number Diff line change
@@ -1128,12 +1128,6 @@ public DynamicObject noSuperMethodError(Node currentNode) {
return noMethodError;
}

public DynamicObject noMethodErrorOnModule(String name, DynamicObject module, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
assert RubyGuards.isRubyModule(module);
return noMethodError(String.format("undefined method `%s' for %s", name, Layouts.MODULE.getFields(module).getName()), name, currentNode);
}

public DynamicObject noMethodErrorOnReceiver(String name, Object receiver, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
DynamicObject logicalClass = getLogicalClass(receiver);
Original file line number Diff line number Diff line change
@@ -355,15 +355,10 @@ public void undefMethod(RubyContext context, Node currentNode, String methodName
if (method == null) {
throw new RaiseException(context.getCoreLibrary().nameErrorUndefinedMethod(methodName, rubyModuleObject, currentNode));
} else {
undefMethod(context, currentNode, method);
addMethod(context, currentNode, method.undefined());
}
}

@CompilerDirectives.TruffleBoundary
public void undefMethod(RubyContext context, Node currentNode, InternalMethod method) {
addMethod(context, currentNode, method.undefined());
}

/**
* Also searches on Object for modules.
* Used for alias_method, visibility changes, etc.
@@ -393,7 +388,7 @@ public void alias(RubyContext context, Node currentNode, String newName, String

if (method == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(context.getCoreLibrary().noMethodErrorOnModule(oldName, rubyModuleObject, currentNode));
throw new RaiseException(context.getCoreLibrary().nameErrorUndefinedMethod(oldName, rubyModuleObject, currentNode));
}

InternalMethod aliasMethod = method.withName(newName);
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ public RubyRootNode parse(RubyContext context, Source source, Encoding defaultEn
final DynamicScope dynamicScope = new ManyVarsDynamicScope(staticScope);

boolean isInlineSource = parserContext == ParserContext.SHELL;
boolean isEvalParse = parserContext == ParserContext.EVAL || parserContext == ParserContext.MODULE;
boolean isEvalParse = parserContext == ParserContext.EVAL || parserContext == ParserContext.INLINE || parserContext == ParserContext.MODULE;
final org.jruby.parser.ParserConfiguration parserConfiguration = new org.jruby.parser.ParserConfiguration(context.getRuntime(), 0, isInlineSource, !isEvalParse, true);
parserConfiguration.setDefaultEncoding(defaultEncoding);