Skip to content

Testing packages

Given a file named “pen.json” with:

{
"type": "library",
"dependencies": {
"Test": "pen:///test"
}
}

And a file named “Foo.pen” with:

Add = \(x number, y number) number {
x + y
}

Given a file named “Foo.test.pen” with:

import Test'Assert
import 'Foo
Add = \() none | error {
Assert'Equal(Foo'Add(41, 1), 42)
}

When I run pen test

Then the exit status should be 0

And the stdout should contain “OK”.

Given a file named “Foo.test.pen” with:

import Test'Assert
import 'Foo
Add = \() none | error {
Assert'Equal(Foo'Add(41, 0), 42)
}

When I run pen test

Then the exit status should not be 0

And the stdout should contain “FAIL”.

Given a file named “Foo.test.pen” with:

import Test'Assert
import 'Foo
Add = \() none | error {
Assert'Equal(Foo'Add(41, 1), 42)
}
AddMore = \() none | error {
Assert'Equal(Foo'Add(40, 2), 42)
}

When I successfully run pen test

Then the exit status should be 0.

When I run pen test

Then the exit status should be 0.

Given a file named “Foo.test.pen” with:

Foo = \() none | error {
debug("hello")
}

When I run pen test

Then the exit status should be 0.