#test-files #file #testing #language #error #parser #whiley

whiley_test_file

An API for manipulating test files for the Whiley Programming Language

4 releases

0.6.2 Jul 25, 2022
0.6.1 Jul 25, 2022
0.6.0 Jul 25, 2022
0.5.0 Jul 25, 2022

#506 in Programming languages

Download history 2/week @ 2024-02-24 15/week @ 2024-03-30 1/week @ 2024-04-06 170/week @ 2024-04-20

186 downloads per month

MIT/Apache

145KB
340 lines

WhileyTestFile

A library for parsing Whiley test files according to RFC#110 which are used for testing the Whiley compiler. Each test describes a sequence of modifications to one of more Whiley files, along with the expected outcomes (e.g. errors, warnings, etc). An example test file is the following:

whiley.verify = false
boogie.timeout = 1000
================
>>> main.whiley
method main():
>>> other.whiley
import main
---
E101 main.whiley 1,2
E302 main.whiley 2,2:3
================
<<< other.whiley
>>> main.whiley 1:1
method main()
    skip
---

This is a test involving two files: main.whiley and other.whiley. The initial frame sets the contents of main.whiley to method main() and the contents of other.whiley to import main. Furthermore, compiling this frame is expected to produce two errors (E101 and E302). The second frame deletes file other.whiley and updates the contents of main.whiley. Furthermore, compiling the snapshot at this point is not expected to produce any errors.

Usage

use std::fs;
use whiley_test_file::WhileyTestFile;
//!
fn load(filename: &str) {
    // Read the test file
    let input = fs::read_to_string(filename).unwrap();
    // Parse test file
    let test_file = WhileyTestFile::new(&input).unwrap();
    // ...
}

This simply reads a file from disk and parses it as a WhileyTestFile, expecting this all to succeed.

No runtime deps