Commits

Pasberth Usbean committed b244822

Added tests

Comments (0)

Files changed (1)

spec/regparsers/regexp_parser_spec.rb

 
 describe RegParsec::Regparsers::RegexpParser do
   
-  subject { described_class.new.curry!(/(.*?);/) }
-
-  example { subject.parse("abc").should be_nil }
-  example { subject.regparse("abc").should be_is_a ::RegParsec::Result::Invalid }
-  example { subject.parse("abc;").should be_nil }
-  example { subject.regparse("abc;").should be_is_a ::RegParsec::Result::Accepted }
-  example { subject.parse("abc;def;")[0].should == "abc;" }
-  example { subject.parse("abc;def;")[1].should == "abc" }
-  example { subject.regparse("abc;def;").should be_is_a ::RegParsec::Result::Success }
+  context ' /(.*?);/ case ' do
+    subject { described_class.new.curry!(/(.*?);/) }
+
+    example { subject.parse("abc").should be_nil }
+    example { subject.regparse("abc").should be_is_a ::RegParsec::Result::Invalid }
+    example { subject.parse("abc;").should be_nil }
+    example { subject.regparse("abc;").should be_is_a ::RegParsec::Result::Accepted }
+    example { subject.parse("abc;def;")[0].should == "abc;" }
+    example { subject.parse("abc;def;")[1].should == "abc" }
+    example { subject.regparse("abc;def;").should be_is_a ::RegParsec::Result::Success }
+  end
+  
+  context ' /#(.*)\n/ case ' do
+    subject { described_class.new.curry!(/\#(.*?)\n/) }
+
+    example { subject.parse("abc").should be_nil }
+    example { subject.regparse("abc").should be_is_a ::RegParsec::Result::Invalid }
+
+    example { subject.parse("# abc\n").should be_nil }
+    example { subject.regparse("# abc\n").should be_is_a ::RegParsec::Result::Accepted }
+
+    example { subject.parse("# abc\n def")[0].should == "# abc\n" }
+    example { subject.parse("# abc\n def")[1].should == " abc" }
+    example { subject.regparse("# abc\n def").should be_is_a ::RegParsec::Result::Success }
+  end
+  
+  context ' /#(.*)\n+/ case ' do
+    subject { described_class.new.curry!(/\#(.*?)\n+/) }
+
+    example { subject.parse("abc").should be_nil }
+    example { subject.regparse("abc").should be_is_a ::RegParsec::Result::Invalid }
+
+    example { subject.parse("# abc\n").should be_nil }
+    example { subject.regparse("# abc\n").should be_is_a ::RegParsec::Result::Accepted }
+
+    example { subject.parse("# abc\n def")[0].should == "# abc\n" }
+    example { subject.parse("# abc\n def")[1].should == " abc" }
+    example { subject.regparse("# abc\n def").should be_is_a ::RegParsec::Result::Success }
+
+    example { subject.parse("# abc\n\n\n").should be_nil }
+    example { subject.regparse("# abc\n\n\n").should be_is_a ::RegParsec::Result::Accepted }
+
+    example { subject.parse("# abc\n\n\n def")[0].should == "# abc\n\n\n" }
+    example { subject.parse("# abc\n\n\n def")[1].should == " abc" }
+    example { subject.regparse("# abc\n\n\n def").should be_is_a ::RegParsec::Result::Success }
+  end
 end