Skip to content

Commit

Permalink
Run parser (sexp creation) specs in cli/ specs
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Nov 23, 2013
1 parent 8544814 commit 7aeae27
Show file tree
Hide file tree
Showing 49 changed files with 63 additions and 64 deletions.
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The alias keyword" do
describe "with fitem" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The and statement" do
it "should always return s(:and)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Arrays" do
it "should parse empty arrays as s(:array)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Attribute assignments" do
it "should return a s(:attrasgn) for simple assignments" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The begin keyword" do
it "should be removed when used without a resuce or enusre body" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Block statements" do
it "should return the direct expression if only one expresssion in block" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The break keyword" do
it "should return s(:break) when given no args" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Method calls" do
it "should use 'nil' for calls without a receiver" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The class keyword" do
it "returns an empty s(:block) when given an empty body" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Constants" do
it "should always become a s(:const)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Class variables" do
it "should always be returned as s(:cvar)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The def keyword" do
describe "for normal definitions" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The false keyword" do
it "should always return s(:false)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The __FILE__ keyword" do
it "should always return a s(:str) with given parser filename" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Global variables" do
it "should be returned as s(:gvar)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Hash literals" do
it "without any assocs should return an empty hash sexp" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Heredocs" do

Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Instance variable assignment" do
it "always returns an s(:iasgn)" do
Expand Down
2 changes: 1 addition & 1 deletion spec/opal/parser/if_spec.rb → spec/cli/parser/if_spec.rb
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The if keyword" do
it "should return an s(:if) with given truthy and falsy bodies" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Parsing integers" do
it "parses integers as a s(:int) sexp" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Iters" do
describe "Iter on a command" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Instance variables" do
it "always return an s(:ivar)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Lambda literals" do
it "should parse with either do/end construct or curly braces" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Local assignment" do
it "returns an s(:lasgn)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The __LINE__ keyword" do
it "should always return a literal number of the current line" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "An lvar" do
describe "in any scope" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Masgn" do
describe "with a single lhs splat" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The module keyword" do
it "returns an empty s(:block) when given an empty body" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The nil keyword" do
it "always returns s(:nil)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The not keyword" do
it "returns s(:not) with the single argument" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "$1..$9" do
it "parses as s(:nth_ref)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "op_asgn1" do
it "returns s(:op_asgn1)" do
Expand All @@ -14,7 +14,7 @@
end

it "only uses the operator, not with '=' appended" do
opal_parse("self[:foo] += 1")[3].should == :+
opal_parse("self[:foo] += 1")[3].should == '+'
end

it "uses a simple sexp, not an arglist" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "op_asgn2" do
it "returns s(:op_asgn2)" do
Expand Down
2 changes: 1 addition & 1 deletion spec/opal/parser/or_spec.rb → spec/cli/parser/or_spec.rb
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The or statement" do
it "should always return s(:or)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe Opal::Compiler do
it "parses operators before \n in command calls" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Regexps" do
it "parses a regexp as a s(:lit)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The return keyword" do
it "should return s(:return) when given no arguments" do
Expand Down
@@ -1,8 +1,8 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Singleton classes" do
it "returns an empty s(:scope) when given an empty body" do
opal_parse('class << A; end')[2].should == [:scope]
it "returns an empty s(:block) when given an empty body" do
opal_parse('class << A; end')[2].should == [:block]
end

it "does not place single expressions into an s(:block)" do
Expand All @@ -14,8 +14,8 @@
end

it "should accept any expressions for singleton part" do
opal_parse('class << A; end').should == [:sclass, [:const, :A], [:scope]]
opal_parse('class << self; end').should == [:sclass, [:self], [:scope]]
opal_parse('class << A; end').should == [:sclass, [:const, :A], [:block]]
opal_parse('class << self; end').should == [:sclass, [:self], [:block]]
end
end

@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The self keyword" do
it "always returns s(:self)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "Strings" do
it "parses empty strings" do
Expand Down
@@ -1,4 +1,4 @@
require "spec_helper"
require File.expand_path('../../spec_helper', __FILE__)

describe "Strings" do
it "parses %[] strings" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The super keyword" do
it "should return s(:super) for any arguments" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The true keyword" do
it "always returns s(:true)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The undef keyword" do
it "returns s(:undef) with the argument as an s(:lit)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The unless keyword" do
it "returns s(:if) with reversed true and false bodies" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The while keyword" do
it "returns an s(:while) with the given expr, body and true for head" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "x-strings" do
it "parses simple xstring as s(:xstr)" do
Expand Down
@@ -1,4 +1,4 @@
require 'spec_helper'
require File.expand_path('../../spec_helper', __FILE__)

describe "The yield keyword" do
it "should return s(:yield) when no arguments given" do
Expand Down
21 changes: 10 additions & 11 deletions spec/cli/spec_helper.rb
@@ -1,17 +1,16 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
require 'opal'

module OpalSpecHelpers
def opal_parse(str, file='(string)')
Opal::Parser.new.parse str, file
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

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = 'random'

config.include OpalSpecHelpers
end

0 comments on commit 7aeae27

Please sign in to comment.