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: 91f868e2d56b
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cd225545c6bf
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Nov 28, 2014

  1. move spec docs to spec/

    adambeynon committed Nov 28, 2014
    Copy the full SHA
    a0aebc6 View commit details
  2. Copy the full SHA
    cd22554 View commit details
Showing with 43 additions and 11 deletions.
  1. +2 −0 CHANGELOG.md
  2. +0 −9 README.md
  3. +10 −2 lib/opal/nodes/rescue.rb
  4. +8 −0 spec/README.md
  5. +23 −0 spec/opal/core/language_spec.rb
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## edge (upcoming 0.7)

* Fix `begin`/`rescue` blocks to evaluate to last expression.

* Add support for `RUBY_ENGINE/RUBY_PLATFORM != "opal"` pre-processor directives.

if RUBY_ENGINE != "opal"
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -119,15 +119,6 @@ javascript.
Holds the stdlib that opal currently supports. This includes Observable,
StringScanner, Date, etc.

### spec

* **rubyspecs** (file) a whitelist of RubySpec files to be ran
* **corelib** RubySpec examples (submodule)
* **stdlib** `rubysl-*` examples (submodules)
* **filters** The list of MSpec/RubySpec examples that are either bugs or unsupported
* **opal** opal additions/special behaviour in the runtime/corelib
* **cli** specs for opal lib (parser, lexer, grammar, compiler etc)

## Browser support

* Internet Explorer 6+
12 changes: 10 additions & 2 deletions lib/opal/nodes/rescue.rb
Original file line number Diff line number Diff line change
@@ -80,7 +80,13 @@ def compile
end

def body_code
body.type == :resbody ? s(:nil) : body
body_code = (body.type == :resbody ? s(:nil) : body)

if !stmt?
compiler.returns body_code
else
body_code
end
end
end

@@ -128,7 +134,9 @@ def rescue_exprs
end

def rescue_body
body || s(:nil)
body_code = (body || s(:nil))
body_code = compiler.returns(body_code) if !stmt?
body_code
end
end
end
8 changes: 8 additions & 0 deletions spec/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Opal specs overview

* **rubyspecs** (file) a whitelist of RubySpec files to be ran
* **corelib** RubySpec examples (submodule)
* **stdlib** `rubysl-*` examples (submodules)
* **filters** The list of MSpec/RubySpec examples that are either bugs or unsupported
* **opal** opal additions/special behaviour in the runtime/corelib
* **lib** specs for opal lib (parser, lexer, grammar, compiler etc)
23 changes: 23 additions & 0 deletions spec/opal/core/language_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper'

describe "begin & rescue blocks" do
it "should evaluate to begin blocks last expression when no exception" do
result = begin
"a"
rescue
"b"
end

result.should == "a"
end

it "should evaluate to rescue blocks last expression when exception" do
result = begin
raise "foo"
rescue
"bar"
end

result.should == "bar"
end
end