Skip to content
Browse files

Reorganized specs, take 1.

  • Loading branch information...
1 parent a3eec50 commit 3fb11ebfe16077950cfd9c25c937ff5c0569ad3c @brixen committed Oct 23, 2010
Showing with 219 additions and 49 deletions.
  1. +9 −0 spec/ast/choice_spec.rb
  2. +9 −0 spec/ast/concatenation_spec.rb
  3. 0 spec/{ → ast}/difference_spec.rb
  4. 0 spec/{ → ast}/grammar_spec.rb
  5. +8 −0 spec/ast/if_spec.rb
  6. 0 spec/{ → ast}/pattern_spec.rb
  7. 0 spec/{ → ast}/product_spec.rb
  8. +8 −0 spec/ast/unless_spec.rb
  9. 0 spec/{ → ast}/variable_spec.rb
  10. +3 −0 spec/default.mspec
  11. +6 −0 spec/matching/evaluator/any_spec.rb
  12. +6 −0 spec/matching/evaluator/character_spec.rb
  13. +6 −0 spec/matching/evaluator/choice_spec.rb
  14. +6 −0 spec/matching/evaluator/concatenation_spec.rb
  15. +6 −0 spec/matching/evaluator/difference_spec.rb
  16. +6 −0 spec/matching/evaluator/if_spec.rb
  17. +6 −0 spec/matching/evaluator/product_spec.rb
  18. +4 −0 spec/matching/evaluator/setup.rb
  19. +6 −0 spec/matching/evaluator/unless_spec.rb
  20. +6 −0 spec/matching/machine/any_spec.rb
  21. +6 −0 spec/matching/machine/character_spec.rb
  22. +6 −0 spec/matching/machine/choice_spec.rb
  23. +6 −0 spec/matching/machine/concatenation_spec.rb
  24. +6 −0 spec/matching/machine/difference_spec.rb
  25. +6 −0 spec/matching/machine/if_spec.rb
  26. +6 −0 spec/matching/machine/product_spec.rb
  27. +4 −0 spec/matching/machine/setup.rb
  28. +6 −0 spec/matching/machine/unless_spec.rb
  29. +8 −0 spec/matching/rubinius/any_spec.rb
  30. +8 −0 spec/matching/rubinius/character_spec.rb
  31. +8 −0 spec/matching/rubinius/choice_spec.rb
  32. +8 −0 spec/matching/rubinius/concatenation_spec.rb
  33. +8 −0 spec/matching/rubinius/difference_spec.rb
  34. +8 −0 spec/matching/rubinius/if_spec.rb
  35. +8 −0 spec/matching/rubinius/product_spec.rb
  36. +4 −0 spec/matching/rubinius/setup.rb
  37. +8 −0 spec/matching/rubinius/unless_spec.rb
  38. +1 −3 spec/{any_spec.rb → matching/shared/any.rb}
  39. +1 −3 spec/{character_spec.rb → matching/shared/character.rb}
  40. +1 −11 spec/{choice_spec.rb → matching/shared/choice.rb}
  41. +1 −11 spec/{concatenation_spec.rb → matching/shared/concatenation.rb}
  42. +2 −0 spec/matching/shared/difference.rb
  43. +1 −10 spec/{if_spec.rb → matching/shared/if.rb}
  44. +2 −0 spec/matching/shared/product.rb
  45. +1 −11 spec/{unless_spec.rb → matching/shared/unless.rb}
View
9 spec/ast/choice_spec.rb
@@ -0,0 +1,9 @@
+require 'spec/spec_helper'
+
+describe "Choice.new" do
+ it "converts both inputs to patterns" do
+ pattern = Pegarus::Choice.new 1, "a"
+ pattern.first.should be_an_instance_of(Pegarus::Any)
+ pattern.second.should be_an_instance_of(Pegarus::Character)
+ end
+end
View
9 spec/ast/concatenation_spec.rb
@@ -0,0 +1,9 @@
+require 'spec/spec_helper'
+
+describe "Concatenation.new" do
+ it "converts both inputs to patterns" do
+ pattern = Pegarus::Concatenation.new 1, "a"
+ pattern.first.should be_an_instance_of(Pegarus::Any)
+ pattern.second.should be_an_instance_of(Pegarus::Character)
+ end
+end
View
0 spec/difference_spec.rb → spec/ast/difference_spec.rb
File renamed without changes.
View
0 spec/grammar_spec.rb → spec/ast/grammar_spec.rb
File renamed without changes.
View
8 spec/ast/if_spec.rb
@@ -0,0 +1,8 @@
+require 'spec/spec_helper'
+
+describe "If.new" do
+ it "converts the input to a pattern" do
+ pattern = Pegarus::If.new "a"
+ pattern.pattern.should be_an_instance_of(Pegarus::Character)
+ end
+end
View
0 spec/pattern_spec.rb → spec/ast/pattern_spec.rb
File renamed without changes.
View
0 spec/product_spec.rb → spec/ast/product_spec.rb
File renamed without changes.
View
8 spec/ast/unless_spec.rb
@@ -0,0 +1,8 @@
+require 'spec/spec_helper'
+
+describe "Unless.new" do
+ it "converts the input to a pattern" do
+ pattern = Pegarus::Unless.new "a"
+ pattern.pattern.should be_an_instance_of(Pegarus::Character)
+ end
+end
View
0 spec/variable_spec.rb → spec/ast/variable_spec.rb
File renamed without changes.
View
3 spec/default.mspec
@@ -1,4 +1,7 @@
# vim: filetype=ruby
+
+require 'spec/custom/guards/engine'
+
class MSpecScript
set :target, 'rbx'
end
View
6 spec/matching/evaluator/any_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/evaluator/setup'
+require 'spec/matching/shared/any'
+
+describe "Any#match" do
+ it_should_behave_like :ast_any
+end
View
6 spec/matching/evaluator/character_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/evaluator/setup'
+require 'spec/matching/shared/character'
+
+describe "Character#match" do
+ it_should_behave_like :ast_character
+end
View
6 spec/matching/evaluator/choice_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/evaluator/setup'
+require 'spec/matching/shared/choice'
+
+describe "Choice#match" do
+ it_should_behave_like :ast_choice
+end
View
6 spec/matching/evaluator/concatenation_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/evaluator/setup'
+require 'spec/matching/shared/concatenation'
+
+describe "Concatenation#match" do
+ it_should_behave_like :ast_concatenation
+end
View
6 spec/matching/evaluator/difference_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/evaluator/setup'
+require 'spec/matching/shared/difference'
+
+describe "Difference#match" do
+ it_should_behave_like :ast_difference
+end
View
6 spec/matching/evaluator/if_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/evaluator/setup'
+require 'spec/matching/shared/if'
+
+describe "If#match" do
+ it_should_behave_like :ast_if
+end
View
6 spec/matching/evaluator/product_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/evaluator/setup'
+require 'spec/matching/shared/product'
+
+describe "Product#match" do
+ it_should_behave_like :ast_product
+end
View
4 spec/matching/evaluator/setup.rb
@@ -0,0 +1,4 @@
+require 'spec/spec_helper'
+require 'pegarus/evaluator'
+
+Pegarus::Pattern.select_engine Pegarus::Evaluator
View
6 spec/matching/evaluator/unless_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/evaluator/setup'
+require 'spec/matching/shared/unless'
+
+describe "Unless#match" do
+ it_should_behave_like :ast_unless
+end
View
6 spec/matching/machine/any_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/machine/setup'
+require 'spec/matching/shared/any'
+
+describe "Any#match" do
+ it_should_behave_like :ast_any
+end
View
6 spec/matching/machine/character_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/machine/setup'
+require 'spec/matching/shared/character'
+
+describe "Character#match" do
+ it_should_behave_like :ast_character
+end
View
6 spec/matching/machine/choice_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/machine/setup'
+require 'spec/matching/shared/choice'
+
+describe "Choice#match" do
+ it_should_behave_like :ast_choice
+end
View
6 spec/matching/machine/concatenation_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/machine/setup'
+require 'spec/matching/shared/concatenation'
+
+describe "Concatenation#match" do
+ it_should_behave_like :ast_concatenation
+end
View
6 spec/matching/machine/difference_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/machine/setup'
+require 'spec/matching/shared/difference'
+
+describe "Difference#match" do
+ it_should_behave_like :ast_difference
+end
View
6 spec/matching/machine/if_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/machine/setup'
+require 'spec/matching/shared/if'
+
+describe "If#match" do
+ it_should_behave_like :ast_if
+end
View
6 spec/matching/machine/product_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/machine/setup'
+require 'spec/matching/shared/product'
+
+describe "Product#match" do
+ it_should_behave_like :ast_product
+end
View
4 spec/matching/machine/setup.rb
@@ -0,0 +1,4 @@
+require 'spec/spec_helper'
+require 'pegarus/machine'
+
+Pegarus::Pattern.select_engine Pegarus::Machine
View
6 spec/matching/machine/unless_spec.rb
@@ -0,0 +1,6 @@
+require 'spec/matching/machine/setup'
+require 'spec/matching/shared/unless'
+
+describe "Unless#match" do
+ it_should_behave_like :ast_unless
+end
View
8 spec/matching/rubinius/any_spec.rb
@@ -0,0 +1,8 @@
+engine_is :rbx do
+ require 'spec/matching/rubinius/setup'
+ require 'spec/matching/shared/any'
+
+ describe "Any#match" do
+ it_should_behave_like :ast_any
+ end
+end
View
8 spec/matching/rubinius/character_spec.rb
@@ -0,0 +1,8 @@
+engine_is :rbx do
+ require 'spec/matching/rubinius/setup'
+ require 'spec/matching/shared/character'
+
+ describe "Character#match" do
+ it_should_behave_like :ast_character
+ end
+end
View
8 spec/matching/rubinius/choice_spec.rb
@@ -0,0 +1,8 @@
+engine_is :rbx do
+ require 'spec/matching/rubinius/setup'
+ require 'spec/matching/shared/choice'
+
+ describe "Choice#match" do
+ it_should_behave_like :ast_choice
+ end
+end
View
8 spec/matching/rubinius/concatenation_spec.rb
@@ -0,0 +1,8 @@
+engine_is :rbx do
+ require 'spec/matching/rubinius/setup'
+ require 'spec/matching/shared/concatenation'
+
+ describe "Concatenation#match" do
+ it_should_behave_like :ast_concatenation
+ end
+end
View
8 spec/matching/rubinius/difference_spec.rb
@@ -0,0 +1,8 @@
+engine_is :rbx do
+ require 'spec/matching/rubinius/setup'
+ require 'spec/matching/shared/difference'
+
+ describe "Difference#match" do
+ it_should_behave_like :ast_difference
+ end
+end
View
8 spec/matching/rubinius/if_spec.rb
@@ -0,0 +1,8 @@
+engine_is :rbx do
+ require 'spec/matching/rubinius/setup'
+ require 'spec/matching/shared/if'
+
+ describe "If#match" do
+ it_should_behave_like :ast_if
+ end
+end
View
8 spec/matching/rubinius/product_spec.rb
@@ -0,0 +1,8 @@
+engine_is :rbx do
+ require 'spec/matching/rubinius/setup'
+ require 'spec/matching/shared/product'
+
+ describe "Product#match" do
+ it_should_behave_like :ast_product
+ end
+end
View
4 spec/matching/rubinius/setup.rb
@@ -0,0 +1,4 @@
+require 'spec/spec_helper'
+require 'pegarus/rubinius'
+
+Pegarus::Pattern.select_engine Pegarus::Rubinius
View
8 spec/matching/rubinius/unless_spec.rb
@@ -0,0 +1,8 @@
+engine_is :rbx do
+ require 'spec/matching/rubinius/setup'
+ require 'spec/matching/shared/unless'
+
+ describe "Unless#match" do
+ it_should_behave_like :ast_unless
+ end
+end
View
4 spec/any_spec.rb → spec/matching/shared/any.rb
@@ -1,6 +1,4 @@
-require 'spec/spec_helper'
-
-describe "Any#match" do
+describe :ast_any, :shared => true do
it "returns nil when the subject is empty" do
Pegarus.pattern(1).match("").should be_nil
end
View
4 spec/character_spec.rb → spec/matching/shared/character.rb
@@ -1,6 +1,4 @@
-require 'spec/spec_helper'
-
-describe "Character#match" do
+describe :ast_character, :shared => true do
it "returns nil when the subject is empty" do
Pegarus.pattern("a").match("").should be_nil
end
View
12 spec/choice_spec.rb → spec/matching/shared/choice.rb 100755 → 100644
@@ -1,14 +1,4 @@
-require 'spec/spec_helper'
-
-describe "Choice.new" do
- it "converts both inputs to patterns" do
- pattern = Pegarus::Choice.new 1, "a"
- pattern.first.should be_an_instance_of(Pegarus::Any)
- pattern.second.should be_an_instance_of(Pegarus::Character)
- end
-end
-
-describe "Choice#match" do
+describe :ast_choice, :shared => true do
it "returns nil if none of the patterns match" do
pat = Pegarus.pattern("a") / Pegarus.pattern("b")
pat.match("c").should be_nil
View
12 spec/concatenation_spec.rb → spec/matching/shared/concatenation.rb
@@ -1,14 +1,4 @@
-require 'spec/spec_helper'
-
-describe "Concatenation.new" do
- it "converts both inputs to patterns" do
- pattern = Pegarus::Concatenation.new 1, "a"
- pattern.first.should be_an_instance_of(Pegarus::Any)
- pattern.second.should be_an_instance_of(Pegarus::Character)
- end
-end
-
-describe "Concatenation#match" do
+describe :ast_concatenation, :shared => true do
it "returns nil if the first pattern does not match" do
pat = Pegarus.pattern(1) + Pegarus.pattern("a")
pat.match("").should be_nil
View
2 spec/matching/shared/difference.rb
@@ -0,0 +1,2 @@
+describe :ast_difference, :shared => true do
+end
View
11 spec/if_spec.rb → spec/matching/shared/if.rb 100755 → 100644
@@ -1,13 +1,4 @@
-require 'spec/spec_helper'
-
-describe "If.new" do
- it "converts the input to a pattern" do
- pattern = Pegarus::If.new "a"
- pattern.pattern.should be_an_instance_of(Pegarus::Character)
- end
-end
-
-describe "If#match" do
+describe :ast_if, :shared => true do
it "returns nil if the first pattern does not match" do
pat = Pegarus.pattern(1) + +Pegarus.pattern("a")
pat.match("").should be_nil
View
2 spec/matching/shared/product.rb
@@ -0,0 +1,2 @@
+describe :ast_product, :shared => true do
+end
View
12 spec/unless_spec.rb → spec/matching/shared/unless.rb 100755 → 100644
@@ -1,13 +1,4 @@
-require 'spec/spec_helper'
-
-describe "Unless.new" do
- it "converts the input to a pattern" do
- pattern = Pegarus::Unless.new "a"
- pattern.pattern.should be_an_instance_of(Pegarus::Character)
- end
-end
-
-describe "Unless#match" do
+describe :ast_unless, :shared => true do
it "returns nil if the first pattern does not match" do
pat = Pegarus.pattern(1) + -Pegarus.pattern("a")
pat.match("").should be_nil
@@ -23,4 +14,3 @@
pat.match("aacbde").should == 1
end
end
-

0 comments on commit 3fb11eb

Please sign in to comment.
Something went wrong with that request. Please try again.