
class TestEntry {
    name: String
    file: String
    line: uint
    assert_count: uint (0)
    assert_passed: uint (0)
    failures: Array[String] (.new())
    passed: bool (false)

    static fn init(name: String, file: String, line: uint) TestEntry {
        return TestEntry {
            name: name
            file: file
            line: line
        }
    }

    static fn assert_panic(check: bool, code: String, file: String, line: uint) bool {
        if !check {
            let message = "assert(" + code + ") @ " + file + ":" + line
            panic("Assert failed: " + message)
        }
        return check
    }

    fn assert_test(check: bool, code: String, file: String, line: uint) bool {
        this.assert_count++
        if check {
            this.assert_passed++
        } else {
            let nr = (this.failures.length / 2) + 1
            let msg1 = "#" + nr + " [code] assert(" + code + ")"
            this.failures.append(msg1)
            let msg2 = "#" + nr + " [file] " + file + ":" + line
            this.failures.append(msg2)
        }
        return check
    }
}
