1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
module demo.ShapesTest
# Run with `golo --test demos/shapes` — every *_test.golo in the directory —
# or pick this one file. The assertions come from the embedded testing module.
import gololang.Testing
struct Point = { x, y }
augment Point {
function describe = |this| -> "(" + this: x() + ", " + this: y() + ")"
}
function main = |args| {
let p = Point(1, 2)
assertEqual(p: describe(), "(1, 2)", "a point describes itself")
assertEqual(p: x() + p: y(), 3, "fields add up")
assertTrue(p: x() < p: y(), "x comes before y")
}
|