Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix TypeError when using ? quantity on a literal #10

Merged
merged 4 commits into from Mar 1, 2012
Jump to file or symbol
Failed to load files and symbols.
+17 −9
Split
View
@@ -5,3 +5,5 @@ gbin
vendor
.bundle
Gemfile.lock
+.rvmrc
+
View
@@ -1,4 +1,4 @@
-source "http://gemcutter.org"
+source "http://rubygems.org"
group :test do
gem 'rspec', "=1.3.0"
View
@@ -23,7 +23,7 @@ def self.random(sexpish, quantity)
def self.literal(cell, quantity = nil)
case quantity
- when :'?' then ([''] + cell).pick * ''
+ when :'?' then ([''] + cell).pick
when :+, :'+?' then raise "Sorry, \"#{cell * ''}+\" is too vague, try setting a range: \"#{cell * ''}{1,3}\""
when :*, :'*?' then raise "Sorry, \"#{cell * ''}*\" is too vague, try setting a range: \"#{cell * ''}{0,3}\""
when Range then quantity.pick.of { cell * '' } * ''
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "#{'*' * 80}\nRegression Specs:" do
it "/abcd/ => 'abcd'" do
@@ -125,6 +125,12 @@
end
end
+ it "/abc?/ => ['ab', 'abc']" do
+ 100.times do
+ ['ab', 'abc'].should include(/abc?/.gen)
+ end
+ end
+
it "/(\\d{3}-)?\\d{3}-\\d{4}/ => /(\\d{3}-)?\\d{3}-\\d{4}/" do
100.times do
/(\d{3}-)?\d{3}-\d{4}/.gen.should =~ /(\d{3}-)?\d{3}-\d{4}/
@@ -160,7 +166,7 @@
/\$\d{2,3}\.\d{2}/.gen.should =~ /\$\d{2,3}\.\d{2}/
end
end
-
+
it "/[:first_name:]/ => /\\w+/" do
100.times do
/[:first_name:]/.gen.should =~ /\w+/
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe Regexp do
describe "#gen" do
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe Randexp::Parser do
describe ".parse" do
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe Randexp::Reducer do
describe ".reduce" do
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe Randexp do
describe "#initialize" do
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe Randgen do
describe ".bool" do