Modules
Background
Section titled “Background”Given a file named “pen.json” with:
{ "type": "library", "dependencies": {}}Import a function from a module
Section titled “Import a function from a module”Given a file named “Foo.pen” with:
Foo = \() number { 42}And a file named “Bar.pen” with:
import 'Foo
Bar = \() number { Foo'Foo()}When I run pen build
Then the exit status should be 0.
Import a type alias from a module
Section titled “Import a type alias from a module”Given a file named “Foo.pen” with:
type Foo = numberAnd a file named “Bar.pen” with:
import 'Foo
type Bar = Foo'FooWhen I run pen build
Then the exit status should be 0.
Import a function from a nested module
Section titled “Import a function from a nested module”Given a file named “Foo/Foo.pen” with:
Foo = \() number { 42}And a file named “Bar.pen” with:
import 'Foo'Foo
Bar = \() number { Foo'Foo()}When I run pen build
Then the exit status should be 0.
Import a module with a custom prefix
Section titled “Import a module with a custom prefix”Given a file named “Foo.pen” with:
Foo = \() number { 42}And a file named “Bar.pen” with:
import 'Foo as Bar
Bar = \() number { Bar'Foo()}When I run pen build
Then the exit status should be 0.
Import a type definition with no prefix
Section titled “Import a type definition with no prefix”Given a file named “Foo.pen” with:
type Foo {}And a file named “Bar.pen” with:
import 'Foo { Foo }
type Bar = FooWhen I run pen build
Then the exit status should be 0.
Import a type alias with no prefix
Section titled “Import a type alias with no prefix”Given a file named “Foo.pen” with:
type Foo = numberAnd a file named “Bar.pen” with:
import 'Foo { Foo }
type Bar = FooWhen I run pen build
Then the exit status should be 0.
Import a function with no prefix
Section titled “Import a function with no prefix”Given a file named “Foo.pen” with:
Foo = \() number { 42}And a file named “Bar.pen” with:
import 'Foo { Foo }
Bar = \() number { Foo()}When I run pen build
Then the exit status should be 0.