Permalink
Browse files

You must have required sexp before requiring zipr for the extending t…

…o work. This means that we can't really properly test sexp_loaded (but at least it's a single line). We now always load sexp to test the extensions, so reflect this in the Gemfile.
  • Loading branch information...
1 parent d185bd3 commit 55a8432c07bf5448c335eeea6e86398faa7e66e5 @frankshearar committed Jun 12, 2012
Showing with 52 additions and 57 deletions.
  1. +1 −0 Gemfile
  2. +1 −7 lib/zipr.rb
  3. +48 −50 test/sexp-extensions_test.rb
  4. +1 −0 test/test_helper.rb
  5. +1 −0 zipr.gemspec
View
@@ -2,6 +2,7 @@ source "http://rubygems.org"
gem "rake", "~> 0.9.2", :group => :test
gem "rantly", "~> 0.3.1", :group => :test
gem "rspec", "~> 2.8.0", :group => :test
+gem "sexp_processor", "~> 3.1.0", :group => :test
if RUBY_VERSION =~ /1.8/ then
gem "rcov", "0.9.11", :group => :test
View
@@ -1,11 +1,5 @@
def sexp_loaded
- begin
- require 'sexp'
- true
- rescue LoadError
- # No sexp gem loaded. Oh well.
- false
- end
+ Kernel::const_defined?(:Sexp)
end
require 'zipr/either'
@@ -1,61 +1,59 @@
require_relative 'test_helper'
-if sexp_loaded then
- describe Sexp do
- describe "creating a zipper" do
- s().zipper.class.should == Zipr::Zipper
- s(s(s(3))).zipper.down.down.insert_child(4).root.should == s(s(s(4, 3)))
+describe Sexp do
+ describe "creating a zipper" do
+ s().zipper.class.should == Zipr::Zipper
+ s(s(s(3))).zipper.down.down.insert_child(4).root.should == s(s(s(4, 3)))
+ end
+
+ describe "branching" do
+ it "should return true for Enumerable things" do
+ z = s().zipper
+ z.branch?([]).should be_true
+ z.branch?(s()).should be_true
+ z.branch?({}).should be_true
+ end
+
+ it "should return false for everything else" do
+ z = s().zipper
+ z.branch?(1).should be_false
+ z.branch?("string").should be_false
+ z.branch?(:symbol).should be_false
+ end
+ end
+
+ describe "children" do
+ it "should return the Enumerable itself" do
+ z = s().zipper
+ z.children(s()).should == s()
+ z.children(s(1)).should == s(1)
+ z.children(s(1,2,3)).should == s(1,2,3)
+ end
+ end
+
+ describe "making new nodes" do
+ it "should retain change mutations in branch nodes" do
+ z = s(1, s(2, 3)).zipper
+ z = z.down.right.change{|a| a.map{|i |i + 1}}
+ z.root.should == s(1, s(3, 4))
end
- describe "branching" do
- it "should return true for Enumerable things" do
- z = s().zipper
- z.branch?([]).should be_true
- z.branch?(s()).should be_true
- z.branch?({}).should be_true
- end
-
- it "should return false for everything else" do
- z = s().zipper
- z.branch?(1).should be_false
- z.branch?("string").should be_false
- z.branch?(:symbol).should be_false
- end
+ it "should retain change mutations in leaf nodes" do
+ z = s(1, s(2, 3)).zipper
+ z = z.down.right.down.change{|i| i + 1}
+ z.root.should == s(1, s(3, 3))
end
- describe "children" do
- it "should return the Enumerable itself" do
- z = s().zipper
- z.children(s()).should == s()
- z.children(s(1)).should == s(1)
- z.children(s(1,2,3)).should == s(1,2,3)
- end
+ it "should retain replace mutations in branch nodes" do
+ z = s(1, s(2, 3)).zipper
+ z = z.down.right.replace(s(:a, :b))
+ z.root.should == s(1, s(:a, :b))
end
- describe "making new nodes" do
- it "should retain change mutations in branch nodes" do
- z = s(1, s(2, 3)).zipper
- z = z.down.right.change{|a| a.map{|i |i + 1}}
- z.root.should == s(1, s(3, 4))
- end
-
- it "should retain change mutations in leaf nodes" do
- z = s(1, s(2, 3)).zipper
- z = z.down.right.down.change{|i| i + 1}
- z.root.should == s(1, s(3, 3))
- end
-
- it "should retain replace mutations in branch nodes" do
- z = s(1, s(2, 3)).zipper
- z = z.down.right.replace(s(:a, :b))
- z.root.should == s(1, s(:a, :b))
- end
-
- it "should retain replace mutations in leaf nodes" do
- z = s(1, s(2, 3)).zipper
- z = z.down.right.down.replace(99)
- z.root.should == s(1, s(99, 3))
- end
+ it "should retain replace mutations in leaf nodes" do
+ z = s(1, s(2, 3)).zipper
+ z = z.down.right.down.replace(99)
+ z.root.should == s(1, s(99, 3))
end
end
end
View
@@ -7,6 +7,7 @@
require 'rantly/property'
require 'rspec'
+require 'sexp'
require 'zipr'
require 'zipr/rantly-extensions'
View
@@ -4,6 +4,7 @@ Gem::Specification.new do |s|
# These dependencies appear in the Gemfile.
s.add_development_dependency('rantly', '~> 0.3.1')
s.add_development_dependency('rspec', '~> 2.7.0')
+ s.add_development_dependency('sexp_processor', '~> 3.1.0')
s.platform = Gem::Platform::RUBY
s.summary = 'Huet-style zipper.'

0 comments on commit 55a8432

Please sign in to comment.