Skip to content
Permalink
Browse files

switch to ==> asserts

  • Loading branch information...
francisdb committed Mar 1, 2019
1 parent 61e2dc5 commit a16ca732704b914514f393419242ca605d87e03f
@@ -25,19 +25,19 @@ object CsvParserSpec extends TestSuite {

"The CsvParser" - {
"correctly parse simple CSV test input" - {
assert(CsvParser {
CsvParser {
""""first_name","last_name","company_name","address","city","county","state","zip","phone1","phone2","email","web"
|"James","Butt", "Benton, John B Jr","6649 N Blue Gum St","New Orleans","Orleans","LA",70116,"504-621-8927","504-845-1427","jbutt@gmail.com","http://www.bentonjohnbjr.com"
|"Josephine","Darakjy","Chanay, Jeffrey A Esq","4 B Blue Ridge Blvd","Brighton","Livingston","MI",48116,"810-292-9388","810-374-9840","josephine_darakjy@darakjy.org","http://www.chanayjeffreyaesq.com"
|Art,"Venere","Chemel, James L Cpa","8 W Cerritos Ave #54","Bridgeport","Gloucester","NJ",08014 ,"856-636-8749","856-264-4130","art@venere.org","http://www.chemeljameslcpa.com"
|"Lenna","Paprocki","Feltz ""Printing"" Service", 639 Main St,"Anchorage","Anchorage","AK",99501,"907-385-4412","907-921-2010","lpaprocki@hotmail.com","http://www.feltzprintingservice.com"
|""".stripMargin
} == file(
} ==> file(
record("first_name","last_name","company_name","address","city","county","state","zip","phone1","phone2","email","web"),
record("James","Butt", "Benton, John B Jr","6649 N Blue Gum St","New Orleans","Orleans","LA","70116","504-621-8927","504-845-1427","jbutt@gmail.com","http://www.bentonjohnbjr.com"),
record("Josephine","Darakjy","Chanay, Jeffrey A Esq","4 B Blue Ridge Blvd","Brighton","Livingston","MI","48116","810-292-9388","810-374-9840","josephine_darakjy@darakjy.org","http://www.chanayjeffreyaesq.com"),
record("Art","Venere","Chemel, James L Cpa","8 W Cerritos Ave #54","Bridgeport","Gloucester","NJ","08014 ","856-636-8749","856-264-4130","art@venere.org","http://www.chemeljameslcpa.com"),
record("Lenna","Paprocki","Feltz \"Printing\" Service"," 639 Main St","Anchorage","Anchorage","AK","99501","907-385-4412","907-921-2010","lpaprocki@hotmail.com","http://www.feltzprintingservice.com")))
record("Lenna","Paprocki","Feltz \"Printing\" Service"," 639 Main St","Anchorage","Anchorage","AK","99501","907-385-4412","907-921-2010","lpaprocki@hotmail.com","http://www.feltzprintingservice.com"))
}
}
}
@@ -27,41 +27,41 @@ object JsonParserSpec extends TestSuite {

"The JsonParser" - {
"parse 'null' to JsNull" - {
assert(parse("null") == JsNull)
parse("null") ==> JsNull
}
"parse 'true' to JsTrue" - {
assert(parse("true") == JsTrue)
parse("true") ==> JsTrue
}
"parse 'false' to JsFalse" - {
assert(parse("false") == JsFalse)
parse("false") ==> JsFalse
}
"parse '0' to JsNumber" - {
assert(parse("0") == JsNumber(0))
parse("0") ==> JsNumber(0)
}
"parse '1.23' to JsNumber" - {
assert(parse("1.23") == JsNumber(1.23))
parse("1.23") ==> JsNumber(1.23)
}
"parse '-1E10' to JsNumber" - {
assert(parse("-1E10") == JsNumber("-1E+10"))
parse("-1E10") ==> JsNumber("-1E+10")
}
"parse '12.34e-10' to JsNumber" - {
assert(parse("12.34e-10") == JsNumber("1.234E-9"))
parse("12.34e-10") ==> JsNumber("1.234E-9")
}
"parse \"xyz\" to JsString" - {
assert(parse("\"xyz\"") == JsString("xyz"))
parse("\"xyz\"") ==> JsString("xyz")
}
"parse escapes in a JsString" - {
assert(parse(""""\"\\/\b\f\n\r\t"""") == JsString("\"\\/\b\f\n\r\t"))
assert(parse("\"L\\" + "u00e4nder\"") == JsString("Länder"))
parse(""""\"\\/\b\f\n\r\t"""") ==> JsString("\"\\/\b\f\n\r\t")
parse("\"L\\" + "u00e4nder\"") ==> JsString("Länder")
}
"properly parse a simple JsObject" - (
assert(parse(""" { "key" :42, "key2": "value" }""") ==
parse(""" { "key" :42, "key2": "value" }""") ==>
JsObject("key" -> JsNumber(42), "key2" -> JsString("value"))
))
)
"properly parse a simple JsArray" - (
assert(parse("""[null, 1.23 ,{"key":true } ] """) ==
parse("""[null, 1.23 ,{"key":true } ] """) ==>
JsArray(JsNull, JsNumber(1.23), JsObject("key" -> JsTrue))
))
)
}
}

@@ -166,7 +166,7 @@ object ActionSpec extends TestParserSpec {
def testRule = rule { capture("x") ~> { x => captured = x.head; cursorChar } }
def targetRule = testRule
"xy" must beMatchedWith('y')
assert(captured == 'x')
captured ==> 'x'
}

"`~>` producing a Rule0" - new TestParser0 {
@@ -24,13 +24,10 @@ object CharPredicateSpec extends TestSuite {
"CharPredicates" - {

"correctly mask characters" - {

assert(
inspectMask(CharPredicate("4")) == "0010000000000000|0000000000000000",
inspectMask(CharPredicate("a")) == "0000000000000000|0000000200000000",
CharPredicate("&048z{~").toString == "CharPredicate.MaskBased(&048z{~)",
show(CharPredicate("&048z{~")) == "&048z{~"
)
inspectMask(CharPredicate("4")) ==> "0010000000000000|0000000000000000"
inspectMask(CharPredicate("a")) ==> "0000000000000000|0000000200000000"
CharPredicate("&048z{~").toString ==> "CharPredicate.MaskBased(&048z{~)"
show(CharPredicate("&048z{~")) ==> "&048z{~"
}

"support `testAny`" - {
@@ -41,10 +38,8 @@ object CharPredicateSpec extends TestSuite {
}

"support `indexOfFirstMatch`" - {
assert(
CharPredicate("abc").indexOfFirstMatch("0125!") == -1,
CharPredicate("abc").indexOfFirstMatch("012c5!") == 3
)
CharPredicate("abc").indexOfFirstMatch("0125!") ==> -1
CharPredicate("abc").indexOfFirstMatch("012c5!") ==> 3
}

"correctly support non-masked content" - {
@@ -58,18 +53,18 @@ object CharPredicateSpec extends TestSuite {
}

"be backed by a mask where possible" - {
assert(CharPredicate('1' to '9').toString == "CharPredicate.MaskBased(123456789)")
assert((CharPredicate('1' to '3') ++ CharPredicate('5' to '8')).toString == "CharPredicate.MaskBased(1235678)")
assert((CharPredicate('1' to '3') ++ "5678").toString == "CharPredicate.MaskBased(1235678)")
assert((CharPredicate('1' to '6') -- CharPredicate('2' to '4')).toString == "CharPredicate.MaskBased(156)")
assert((CharPredicate('1' to '6') -- "234").toString == "CharPredicate.MaskBased(156)")
CharPredicate('1' to '9').toString ==> "CharPredicate.MaskBased(123456789)"
(CharPredicate('1' to '3') ++ CharPredicate('5' to '8')).toString ==> "CharPredicate.MaskBased(1235678)"
(CharPredicate('1' to '3') ++ "5678").toString ==> "CharPredicate.MaskBased(1235678)"
(CharPredicate('1' to '6') -- CharPredicate('2' to '4')).toString ==> "CharPredicate.MaskBased(156)"
(CharPredicate('1' to '6') -- "234").toString ==> "CharPredicate.MaskBased(156)"
}
"be backed by an array where possible" - {
assert(CharPredicate("abcäüö").toString == "CharPredicate.ArrayBased(abcäöü)")
assert((CharPredicate("abcäüö") -- "äö").toString == "CharPredicate.ArrayBased(abcü)")
CharPredicate("abcäüö").toString ==> "CharPredicate.ArrayBased(abcäöü)"
(CharPredicate("abcäüö") -- "äö").toString ==> "CharPredicate.ArrayBased(abcü)"
}
"be backed by a range where possible" - {
assert(CharPredicate('1' to 'Ä').toString == "CharPredicate.RangeBased(start = 1, end = Ä, step = 1, inclusive = true)")
CharPredicate('1' to 'Ä').toString ==> "CharPredicate.RangeBased(start = 1, end = Ä, step = 1, inclusive = true)"
}
}

@@ -172,7 +172,7 @@ object CombinatorSpec extends TestParserSpec {
"`&` modifier" - new TestParser0 {
def targetRule = rule { &("a") }
"a" must beMatched
assert(cursor == 0)
cursor ==> 0
"b" must beMismatched
"" must beMismatched
}
@@ -31,7 +31,7 @@ object DefaultArgumentsSpec extends TestSuite {
val tests = Tests {
"The `push` action" - {
"properly handle default arguments" - {
assert(new Foo("foo").Foo.run() == Success(A(0, 2)))
new Foo("foo").Foo.run() ==> Success(A(0, 2))
}
}
}
@@ -37,10 +37,10 @@ object ReductionTypeSpec extends TestSuite {
val tests = Tests {

"Repeating combinators should properly compute their reduction result types" - {
"OneOrMore" - { assert(ruleTypeOf(_.OneOrMoreExpr) == classOf[Foo2]) }
"ZeroOrMore" - { assert(ruleTypeOf(_.ZeroOrMoreExpr) == classOf[Foo]) }
"Optional" - { assert(ruleTypeOf(_.OptionalExpr) == classOf[Foo]) }
"Times" - { assert(ruleTypeOf(_.TimesExpr) == classOf[Foo2]) }
"OneOrMore" - { ruleTypeOf(_.OneOrMoreExpr) ==> classOf[Foo2] }
"ZeroOrMore" - { ruleTypeOf(_.ZeroOrMoreExpr) ==> classOf[Foo] }
"Optional" - { ruleTypeOf(_.OptionalExpr) ==> classOf[Foo] }
"Times" - { ruleTypeOf(_.TimesExpr) ==> classOf[Foo2] }
}
}

@@ -34,23 +34,23 @@ object RunningSpec extends TestSuite {

"parser.rule.run()" - {
val p = new TestParser("abb")
assert(p.A.run() == Success(()))
p.A.run() ==> Success(())
}

"new Parser(...).rule.run()" - {
assert(new TestParser("abb").A.run() == Success(()))
new TestParser("abb").A.run() ==> Success(())
}

"parser.rule(args).run()" - {
val p = new TestParser("ccc")
assert(p.C(3).run() == Success(()))
p.C(3).run() ==> Success(())
}

"rule(B ~ EOI).run()" - {
val p = new TestParser("bb") {
override def go() = rule(B ~ EOI).run()
}
assert(p.go() == Success(()))
p.go() ==> Success(())
}
}

@@ -10,23 +10,23 @@ object ValueStackSpec extends TestSuite {
"The ValueStack should properly support" - {

"push, size, toList" - new TestStack(stackSize = 3) {
assert(size == 0)
size ==> 0
push(42)
assert(size == 1)
assert(toList == List(42))
size ==> 1
toList ==> List(42)
push("yes")
push(3.0)
assert(size == 3)
assert(toList == List(42, "yes", 3.0))
size ==> 3
toList ==> List(42, "yes", 3.0)
intercept[ValueStackOverflowException] {
push("overflow")
}
}

"pushAll, toHList" - new TestStack(stackSize = 3) {
pushAll(42 :: "yes" :: 4.5 :: HNil)
assert(size == 3)
assert(toHList[HList]() == 42 :: "yes" :: 4.5 :: HNil)
size ==> 3
toHList[HList]() ==> 42 :: "yes" :: 4.5 :: HNil
intercept[ValueStackOverflowException] {
pushAll("overflow" :: HNil)
}
@@ -41,7 +41,7 @@ object ValueStackSpec extends TestSuite {
"insert" - new TestStack(stackSize = 4) {
pushAll(1 :: 2 :: 3 :: HNil)
insert(2, 1.5)
assert(toList == List(1, 1.5, 2, 3))
toList ==> List(1, 1.5, 2, 3)
intercept[IllegalArgumentException] {
insert(-1, 0)
}
@@ -55,11 +55,11 @@ object ValueStackSpec extends TestSuite {

"pop" - new TestStack(stackSize = 8) {
pushAll(1 :: 2 :: 3 :: HNil)
assert(pop() == 3)
assert(toList == List(1, 2))
assert(pop() == 2)
assert(toList == List(1))
assert(pop() == 1)
pop() ==> 3
toList ==> List(1, 2)
pop() ==> 2
toList ==> List(1)
pop() ==> 1
assert(isEmpty)
intercept[ValueStackUnderflowException] {
pop()
@@ -68,10 +68,10 @@ object ValueStackSpec extends TestSuite {

"pullOut" - new TestStack(stackSize = 8) {
pushAll(1 :: 2 :: 3 :: 4 :: HNil)
assert(pullOut(1) == 3)
assert(toList == List(1, 2, 4))
assert(pullOut(2) == 1)
assert(toList == List(2, 4))
pullOut(1) ==> 3
toList ==> List(1, 2, 4)
pullOut(2) ==> 1
toList ==> List(2, 4)
intercept[ValueStackUnderflowException] {
pullOut(2)
}
@@ -82,9 +82,9 @@ object ValueStackSpec extends TestSuite {

"peek" - new TestStack(stackSize = 8) {
pushAll(1 :: 2 :: 3 :: HNil)
assert(peek == 3)
assert(peek(1) == 2)
assert(peek(2) == 1)
peek ==> 3
peek(1) ==> 2
peek(2) ==> 1
intercept[ValueStackUnderflowException] {
peek(3)
}
@@ -96,11 +96,11 @@ object ValueStackSpec extends TestSuite {
"poke" - new TestStack(stackSize = 8) {
pushAll(1 :: 2 :: 3 :: HNil)
poke(0, "3")
assert(toList == List(1, 2, "3"))
toList ==> List(1, 2, "3")
poke(1, "2")
assert(toList == List(1, "2", "3"))
toList ==> List(1, "2", "3")
poke(2, "1")
assert(toList == List("1", "2", "3"))
toList ==> List("1", "2", "3")
intercept[ValueStackUnderflowException] {
poke(3, 0)
}
@@ -112,7 +112,7 @@ object ValueStackSpec extends TestSuite {
"swap" - new TestStack(stackSize = 8) {
pushAll(1 :: 2 :: 3 :: HNil)
swap()
assert(toList == List(1, 3, 2))
toList ==> List(1, 3, 2)
pop()
pop()
intercept[ValueStackUnderflowException] {
@@ -123,7 +123,7 @@ object ValueStackSpec extends TestSuite {
"swap3" - new TestStack(stackSize = 8) {
pushAll(1 :: 2 :: 3 :: HNil)
swap3()
assert(toList == List(3, 2, 1))
toList ==> List(3, 2, 1)
pop()
intercept[ValueStackUnderflowException] {
swap3()
@@ -133,7 +133,7 @@ object ValueStackSpec extends TestSuite {
"swap4" - new TestStack(stackSize = 8) {
pushAll(1 :: 2 :: 3 :: 4 :: HNil)
swap4()
assert(toList == List(4, 3, 2, 1))
toList ==> List(4, 3, 2, 1)
pop()
intercept[ValueStackUnderflowException] {
swap4()
@@ -143,7 +143,7 @@ object ValueStackSpec extends TestSuite {
"swap5" - new TestStack(stackSize = 8) {
pushAll(1 :: 2 :: 3 :: 4 :: 5 :: HNil)
swap5()
assert(toList == List(5, 4, 3, 2, 1))
toList ==> List(5, 4, 3, 2, 1)
pop()
intercept[ValueStackUnderflowException] {
swap5()
@@ -34,7 +34,7 @@ object AlienPackageParserSpec extends TestSuite {
val tests = Tests {
"Parsers in files that dont explicitly import org.parboiled2._" - {
"compile" - {
assert(new FooParser("foo123").Go.run() == Success("foo123"))
new FooParser("foo123").Go.run() ==> Success("foo123")
}
}
}
@@ -56,6 +56,6 @@ object Base64ParsingSpec extends TestSuite {
def parseError(error: ParseError): Result = sys.error("unexpected parse error")
def failure(error: Throwable): Result = sys.error("unexpected parser exception")
}
assert(dispatch(parser, ruleName) == string)
dispatch(parser, ruleName) ==> string
}
}
Oops, something went wrong.

0 comments on commit a16ca73

Please sign in to comment.
You can’t perform that action at this time.