|
| 1 | +/* |
| 2 | + * UCLID5 Verification and Synthesis Engine |
| 3 | + * |
| 4 | + * Copyright (c) 2017. |
| 5 | + * Sanjit A. Seshia, Rohit Sinha and Pramod Subramanyan. |
| 6 | + * |
| 7 | + * All Rights Reserved. |
| 8 | + * Redistribution and use in source and binary forms, with or without |
| 9 | + * modification, are permitted provided that the following conditions are |
| 10 | + * met: |
| 11 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 12 | + * |
| 13 | + * this list of conditions and the following disclaimer. |
| 14 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | + * notice, this list of conditions and the following disclaimer in the |
| 16 | + * |
| 17 | + * documentation and/or other materials provided with the distribution. |
| 18 | + * 3. Neither the name of the copyright holder nor the names of its |
| 19 | + * contributors may be used to endorse or promote products derived from this |
| 20 | + * software without specific prior written permission. |
| 21 | + * |
| 22 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
| 23 | + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 24 | + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 25 | + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
| 26 | + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 27 | + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 28 | + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 29 | + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 30 | + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 31 | + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 32 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | + * |
| 34 | + * Author: Leiqi Ye |
| 35 | + * |
| 36 | + * UCLID concrte tests |
| 37 | + * |
| 38 | + */ |
| 39 | + |
| 40 | +package uclid |
| 41 | +package test |
| 42 | + |
| 43 | +import org.scalatest.flatspec.AnyFlatSpec |
| 44 | +import java.io.File |
| 45 | +import uclid.{lang => l} |
| 46 | + |
| 47 | +object ConcreteSpec { |
| 48 | + def expectedFails(filename: String, nFail : Int) : String = { |
| 49 | + UclidMain.enableStringOutput() |
| 50 | + UclidMain.clearStringOutput() |
| 51 | + val config = UclidMain.Config().copy(simulate=true) |
| 52 | + val modules = UclidMain.compile(ConfigCons.createConfig(filename), lang.Identifier("main"), true) |
| 53 | + val mainModule = UclidMain.instantiate(config, modules, l.Identifier("main")) |
| 54 | + assert (mainModule.isDefined) |
| 55 | + val results = UclidMain.execute(mainModule.get, config) |
| 56 | + val outputString = UclidMain.stringOutput.toString() |
| 57 | + assert (results.count((e) => e.result.isFalse) == nFail) |
| 58 | + assert (results.count((e) => e.result.isUndefined) == 0) |
| 59 | + outputString |
| 60 | + } |
| 61 | +} |
| 62 | +class ConcreteSpec extends AnyFlatSpec { |
| 63 | + "concrete-0.ucl" should "fail one assertion." in { |
| 64 | + ConcreteSpec.expectedFails("./test/concrete/concrete-0.ucl", 1) |
| 65 | + } |
| 66 | + "concrete-1.ucl" should "pass." in { |
| 67 | + ConcreteSpec.expectedFails("./test/concrete/concrete-1.ucl", 0) |
| 68 | + } |
| 69 | + "concrete-2.ucl" should "pass." in { |
| 70 | + ConcreteSpec.expectedFails("./test/concrete/concrete-2.ucl", 0) |
| 71 | + } |
| 72 | + "concrete-3.ucl" should "fail one assertion." in { |
| 73 | + ConcreteSpec.expectedFails("./test/concrete/concrete-3.ucl", 1) |
| 74 | + } |
| 75 | + "concrete-4.ucl" should "pass." in { |
| 76 | + ConcreteSpec.expectedFails("./test/concrete/concrete-4.ucl", 0) |
| 77 | + } |
| 78 | + "concrete-5.ucl" should "pass." in { |
| 79 | + ConcreteSpec.expectedFails("./test/concrete/concrete-5.ucl", 0) |
| 80 | + } |
| 81 | + "concrete-6.ucl" should "fail one assertion." in { |
| 82 | + ConcreteSpec.expectedFails("./test/concrete/concrete-6.ucl", 1) |
| 83 | + } |
| 84 | + "concrete-7.ucl" should "pass." in { |
| 85 | + ConcreteSpec.expectedFails("./test/concrete/concrete-7.ucl", 0) |
| 86 | + } |
| 87 | + "concrete-8.ucl" should "pass." in { |
| 88 | + ConcreteSpec.expectedFails("./test/concrete/concrete-8.ucl", 1) |
| 89 | + } |
| 90 | + "concrete-9.ucl" should "fail one assertion." in { |
| 91 | + ConcreteSpec.expectedFails("./test/concrete/concrete-9.ucl", 1) |
| 92 | + } |
| 93 | + "concrete-10.ucl" should "fail one assertion." in { |
| 94 | + ConcreteSpec.expectedFails("./test/concrete/concrete-10.ucl", 1) |
| 95 | + } |
| 96 | +} |
0 commit comments