@@ -58,6 +58,16 @@ object ConcreteSpec {
5858 assert (results.count((e) => e.result.isUndefined) == 0 )
5959 outputString
6060 }
61+ def expectedError (filename : String , nFail : Int ): Unit = {
62+ try {
63+ expectedFails(filename, nFail)
64+ } catch {
65+ case e : Error =>
66+ println(s " Test passed: caught expected Error - ${e.getMessage}" )
67+ case _ : Throwable =>
68+ throw new AssertionError (" Expected an Error, but a different exception was thrown." )
69+ }
70+ }
6171}
6272class ConcreteSpec extends AnyFlatSpec {
6373 " concrete-0.ucl" should " fail one assertion." in {
@@ -66,31 +76,31 @@ class ConcreteSpec extends AnyFlatSpec {
6676 " concrete-1.ucl" should " pass." in {
6777 ConcreteSpec .expectedFails(" ./test/concrete/concrete-1.ucl" , 0 )
6878 }
69- " concrete-2.ucl" should " pass. " in {
70- ConcreteSpec .expectedFails (" ./test/concrete/concrete-2.ucl" , 0 )
79+ " concrete-2.ucl" should " catch runtime error " in {
80+ ConcreteSpec .expectedError (" ./test/concrete/concrete-2.ucl" , 0 )
7181 }
7282 " concrete-3.ucl" should " fail one assertion." in {
7383 ConcreteSpec .expectedFails(" ./test/concrete/concrete-3.ucl" , 1 )
7484 }
75- " concrete-4.ucl" should " pass ." in {
76- ConcreteSpec .expectedFails(" ./test/concrete/concrete-4.ucl" , 0 )
85+ " concrete-4.ucl" should " fail one assertion ." in {
86+ ConcreteSpec .expectedFails(" ./test/concrete/concrete-4.ucl" , 1 )
7787 }
7888 " concrete-5.ucl" should " pass." in {
7989 ConcreteSpec .expectedFails(" ./test/concrete/concrete-5.ucl" , 0 )
8090 }
8191 " concrete-6.ucl" should " fail one assertion." in {
8292 ConcreteSpec .expectedFails(" ./test/concrete/concrete-6.ucl" , 1 )
8393 }
84- " concrete-7.ucl" should " pass ." in {
85- ConcreteSpec .expectedFails(" ./test/concrete/concrete-7.ucl" , 0 )
94+ " concrete-7.ucl" should " fail two assertion ." in {
95+ ConcreteSpec .expectedFails(" ./test/concrete/concrete-7.ucl" , 2 )
8696 }
8797 " concrete-8.ucl" should " pass." in {
8898 ConcreteSpec .expectedFails(" ./test/concrete/concrete-8.ucl" , 1 )
8999 }
90100 " concrete-9.ucl" should " fail one assertion." in {
91101 ConcreteSpec .expectedFails(" ./test/concrete/concrete-9.ucl" , 1 )
92102 }
93- " concrete-10.ucl" should " fail one assertion ." in {
94- ConcreteSpec .expectedFails(" ./test/concrete/concrete-10.ucl" , 1 )
103+ " concrete-10.ucl" should " pass ." in {
104+ ConcreteSpec .expectedFails(" ./test/concrete/concrete-10.ucl" , 0 )
95105 }
96106}
0 commit comments