Testing packages

Background

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
}

Test a module

Given a file named "Foo.test.pen" with:

import Test'Assert
import 'Foo

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

When I run pen test

Then the exit status should be 0

And the stdout should contain "OK".

Fail to test a module

Given a file named "Foo.test.pen" with:

import Test'Assert
import 'Foo

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

When I run pen test

Then the exit status should not be 0

And the stdout should contain "FAIL".

Run no test

When I run pen test

Then the exit status should be 0.

Use a debug function in a test

Given a file named "Foo.test.pen" with:

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

And I append "1" to the environment variable "PEN_DEBUG"

When I run pen_test_on_linux.sh

Then the exit status should be 0.