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: 3846607e5ad0^
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 564b85d445c9
Choose a head ref
  • 4 commits
  • 35 files changed
  • 1 contributor

Commits on Apr 30, 2014

  1. Remove unused constant

    elia committed Apr 30, 2014
    Copy the full SHA
    3846607 View commit details
  2. Copy the full SHA
    1571320 View commit details
  3. Copy the full SHA
    cff587c View commit details
  4. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    564b85d View commit details
15 changes: 8 additions & 7 deletions lib/mspec/opal/rake_task.rb
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@ class Opal::Nodes::CallNode

module MSpec
module Opal
DEFAULT_PATTERN = 'spec/{corelib,opal,stdlib}/**/*_spec.rb'
DEFAULT_BASEDIR = 'spec'

require 'rake'
@@ -162,8 +161,9 @@ def files
@files ||= []
end

def add_files specs
puts "Adding #{specs.size} spec files..."
def add_files specs, tag = ''
tag = "[#{tag}] "
puts "#{tag}Adding #{specs.size} spec files..."
specs = specs.flatten.map do |path|
dirname = File.join([basedir, path])
if File.directory? dirname
@@ -197,18 +197,19 @@ def rubyspec_white_list

def files_to_run(pattern=nil)
# add any filters in spec/filters of specs we dont want to run
add_files paths_from_glob("#{basedir}/filters/**/*.rb")
add_files paths_from_glob("#{basedir}/filters/**/*.rb"), :filters

if pattern
# add custom opal specs from spec/
add_files paths_from_glob(pattern) & rubyspec_white_list
add_files paths_from_glob(pattern) & rubyspec_white_list, :custom_pattern

else
# add opal specific specs
add_files paths_from_glob("#{basedir}/{opal}/**/*_spec.rb")
add_files paths_from_glob("#{basedir}/opal/**/*_spec.rb"), 'opal/*'
add_files paths_from_glob("#{basedir}/cli/{lexer_spec.rb,parser/**/*_spec.rb}"), 'cli/{lexer,parser}'

# add any rubyspecs we want to run (defined in spec/rubyspecs)
add_files rubyspec_white_list
add_files rubyspec_white_list, :rubyspec_white_list
end
end

2 changes: 1 addition & 1 deletion spec/cli/lexer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'
require 'opal/parser'

describe Opal::Lexer do
2 changes: 1 addition & 1 deletion spec/cli/parser/alias_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The alias keyword" do
describe "with fitem" do
2 changes: 1 addition & 1 deletion spec/cli/parser/and_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The and statement" do
it "should always return s(:and)" do
2 changes: 1 addition & 1 deletion spec/cli/parser/attrasgn_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Attribute assignments" do
it "should return a s(:attrasgn) for simple assignments" do
2 changes: 1 addition & 1 deletion spec/cli/parser/begin_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The begin keyword" do
it "should be removed when used without a resuce or enusre body" do
2 changes: 1 addition & 1 deletion spec/cli/parser/block_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Block statements" do
it "should return the direct expression if only one expresssion in block" do
2 changes: 1 addition & 1 deletion spec/cli/parser/break_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The break keyword" do
it "should return s(:break) when given no args" do
2 changes: 1 addition & 1 deletion spec/cli/parser/call_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Method calls" do
it "should use 'nil' for calls without a receiver" do
2 changes: 1 addition & 1 deletion spec/cli/parser/class_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The class keyword" do
it "returns an empty s(:block) when given an empty body" do
2 changes: 1 addition & 1 deletion spec/cli/parser/comments_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Multiline comments" do
it "parses multiline comments and ignores them" do
2 changes: 1 addition & 1 deletion spec/cli/parser/def_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The def keyword" do
describe "for normal definitions" do
2 changes: 1 addition & 1 deletion spec/cli/parser/if_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The if keyword" do
it "should return an s(:if) with given truthy and falsy bodies" do
2 changes: 1 addition & 1 deletion spec/cli/parser/iter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Iters" do
describe "Iter on a command" do
2 changes: 1 addition & 1 deletion spec/cli/parser/lambda_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Lambda literals" do
it "should parse with either do/end construct or curly braces" do
2 changes: 1 addition & 1 deletion spec/cli/parser/literal_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe Opal::Parser do

2 changes: 1 addition & 1 deletion spec/cli/parser/masgn_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Masgn" do
describe "with a single lhs splat" do
2 changes: 1 addition & 1 deletion spec/cli/parser/module_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The module keyword" do
it "returns an empty s(:block) when given an empty body" do
2 changes: 1 addition & 1 deletion spec/cli/parser/not_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The not keyword" do
it "returns a call sexp" do
2 changes: 1 addition & 1 deletion spec/cli/parser/op_asgn1_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "op_asgn1" do
it "returns s(:op_asgn1)" do
2 changes: 1 addition & 1 deletion spec/cli/parser/op_asgn2_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "op_asgn2" do
it "returns s(:op_asgn2)" do
2 changes: 1 addition & 1 deletion spec/cli/parser/or_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The or statement" do
it "should always return s(:or)" do
2 changes: 1 addition & 1 deletion spec/cli/parser/return_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The return keyword" do
it "should return s(:return) when given no arguments" do
2 changes: 1 addition & 1 deletion spec/cli/parser/sclass_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Singleton classes" do
it "returns an empty s(:block) when given an empty body" do
2 changes: 1 addition & 1 deletion spec/cli/parser/string_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "Strings" do
it "parses empty strings" do
2 changes: 1 addition & 1 deletion spec/cli/parser/super_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The super keyword" do
it "should return s(:super) for any arguments" do
2 changes: 1 addition & 1 deletion spec/cli/parser/undef_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The undef keyword" do
it "returns s(:undef) with the argument as an s(:lit)" do
2 changes: 1 addition & 1 deletion spec/cli/parser/unless_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The unless keyword" do
it "returns s(:if) with reversed true and false bodies" do
2 changes: 1 addition & 1 deletion spec/cli/parser/variables_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe Opal::Parser do
it "parses instance variables" do
2 changes: 1 addition & 1 deletion spec/cli/parser/while_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'cli/spec_helper'
require 'support/parser_helpers'

describe "The while keyword" do
it "returns an s(:while) with the given expr, body and true for head" do
2 changes: 1 addition & 1 deletion spec/cli/parser/yield_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.expand_path('../../spec_helper', __FILE__)
require 'support/parser_helpers'

describe "The yield keyword" do
it "should return s(:yield) when no arguments given" do
29 changes: 0 additions & 29 deletions spec/cli/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
require 'opal'

module OpalSpecHelpers
def parsed(source, file='(string)')
Opal::Parser.new.parse(source, file)
end

def expect_parsed(source)
expect(parsed(source))
end

def expect_parsed_string(source)
expect(parsed(source)[1])
end

def expect_lines(source)
expect(parsed_nodes(source).map { |sexp| sexp.line })
end

def expect_columns(source)
expect(parsed_nodes(source).map { |sexp| sexp.column })
end

def parsed_nodes(source)
parsed = Opal::Parser.new.parse(source)
parsed.type == :block ? parsed.children : [parsed]
end
end

RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = 'random'

config.include OpalSpecHelpers
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
require 'mspec'
require 'mspec/version'
require 'mspec/opal/mspec_fixes'
require 'support/mspec_rspec_adapter'
require 'mspec/opal/runner'

require 'math'
33 changes: 33 additions & 0 deletions spec/support/mspec_rspec_adapter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module MSpecRSpecAdapter
def expect(object)
MSpecRSpecAdapterShould.new(object)
end

def eq(expected)
MSpecRSpecAdapterEq.new(expected)
end

class MSpecRSpecAdapterEq < Struct.new(:object)
end

class MSpecRSpecAdapterShould < Struct.new(:object)
def to(expectation)
apply_expectation(:should, expectation)
end

def apply_expectation(type, expectation)
if MSpecRSpecAdapterEq === expectation
object.send(type) == expectation.object
else
object.send(type, expectation)
end
end

def not_to
apply_expectation(:should_not, expectation)
end
alias to_not not_to
end
end

include MSpecRSpecAdapter unless defined? RSpec
35 changes: 35 additions & 0 deletions spec/support/parser_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module ParserHelpers
def parsed(source, file='(string)')
Opal::Parser.new.parse(source, file)
end

def expect_parsed(source)
expect(parsed(source))
end

def expect_parsed_string(source)
expect(parsed(source)[1])
end

def expect_lines(source)
expect(parsed_nodes(source).map { |sexp| sexp.line })
end

def expect_columns(source)
expect(parsed_nodes(source).map { |sexp| sexp.column })
end

def parsed_nodes(source)
parsed = Opal::Parser.new.parse(source)
parsed.type == :block ? parsed.children : [parsed]
end
end

if defined? RSpec
RSpec.configure do |config|
config.include ParserHelpers
end
else
include ParserHelpers
end