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

Commits on Jun 16, 2015

  1. Add spec for next in a method

    eregon committed Jun 16, 2015
    Copy the full SHA
    d446d83 View commit details
  2. Add spec for redo in a method

    eregon committed Jun 16, 2015
    Copy the full SHA
    5f0f809 View commit details
  3. Add tags for failing specs

    eregon committed Jun 16, 2015
    Copy the full SHA
    dcb41d0 View commit details
  4. Copy the full SHA
    8136d9c View commit details
12 changes: 11 additions & 1 deletion spec/ruby/language/next_spec.rb
Original file line number Diff line number Diff line change
@@ -106,6 +106,16 @@ def self.enclosing_method
end
end

describe "The next statement" do
describe "in a method" do
it "is invalid and raises a SyntaxError" do
lambda {
eval("def m; next; end")
}.should raise_error(SyntaxError)
end
end
end

describe "The next statement" do
before :each do
ScratchPad.record []
@@ -309,7 +319,7 @@ def self.enclosing_method

ScratchPad.recorded.should == [:begin, :ensure, :begin, :ensure]
end
end
end
end

describe "Assignment via next" do
8 changes: 8 additions & 0 deletions spec/ruby/language/redo_spec.rb
Original file line number Diff line number Diff line change
@@ -55,4 +55,12 @@
end
list.should == [1,10,100,1,10,100,2,20,200,3,30,300]
end

describe "in a method" do
it "is invalid and raises a SyntaxError" do
lambda {
eval("def m; redo; end")
}.should raise_error(SyntaxError)
end
end
end
1 change: 1 addition & 0 deletions spec/tags/ruby/language/next_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:The next statement in a method is invalid and raises a SyntaxError
1 change: 1 addition & 0 deletions spec/tags/ruby/language/redo_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:The redo statement in a method is invalid and raises a SyntaxError
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;

import org.joni.NameEntry;
import org.joni.Regex;
import org.joni.Syntax;
@@ -67,6 +68,7 @@
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.array.ArrayUtils;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.CoreLibrary;
import org.jruby.truffle.runtime.core.RubyEncoding;
import org.jruby.truffle.runtime.core.RubyRegexp;
@@ -2213,7 +2215,11 @@ public RubyNode visitNewlineNode(org.jruby.ast.NewlineNode node) {
public RubyNode visitNextNode(org.jruby.ast.NextNode node) {
final SourceSection sourceSection = translate(node.getPosition());

RubyNode resultNode;
if (!environment.isBlock() && !translatingWhile) {
throw new RaiseException(context.getCoreLibrary().syntaxError("Invalid next", currentNode));
}

final RubyNode resultNode;

final boolean t = translatingNextExpression;
translatingNextExpression = true;
@@ -2458,6 +2464,10 @@ private RubyNode translateRationalComplex(SourceSection sourceSection, String na

@Override
public RubyNode visitRedoNode(org.jruby.ast.RedoNode node) {
if (!environment.isBlock() && !translatingWhile) {
throw new RaiseException(context.getCoreLibrary().syntaxError("Invalid redo", currentNode));
}

return new RedoNode(context, translate(node.getPosition()));
}