Record
Background
Section titled “Background”Given a file named “pen.json” with:
{ "type": "library", "dependencies": {}}Create a record with a field
Section titled “Create a record with a field”Given a file named “Foo.pen” with:
type r { x number}
f = \() r { r{x: 42}}When I run pen build
Then the exit status should be 0.
Create a record with two fields
Section titled “Create a record with two fields”Given a file named “Foo.pen” with:
type r { x number y none}
f = \() r { r{x: 42, y: none}}When I run pen build
Then the exit status should be 0.
Create a record with no field
Section titled “Create a record with no field”Given a file named “Foo.pen” with:
type r {}
f = \() r { r{}}When I run pen build
Then the exit status should be 0.
Update a record
Section titled “Update a record”Given a file named “Foo.pen” with:
type r { x number y none}
f = \(x r) r { r{...x, y: none}}When I run pen build
Then the exit status should be 0.
Get a field in a record
Section titled “Get a field in a record”Given a file named “Foo.pen” with:
type r { x number}
f = \(x r) number { x.x}When I run pen build
Then the exit status should be 0.
Use an equal operator
Section titled “Use an equal operator”Given a file named “Foo.pen” with:
type r { x number}
f = \(x r, y r) boolean { x == y}When I run pen build
Then the exit status should be 0.
Use a not-equal operator
Section titled “Use a not-equal operator”Given a file named “Foo.pen” with:
type r { x number}
f = \(x r, y r) boolean { x == y}When I run pen build
Then the exit status should be 0.
Propagate openness of a record
Section titled “Propagate openness of a record”Given a file named “Foo.pen” with:
type Foo { X number}And a file named “Bar.pen” with:
import 'Foo
Bar = \() Foo'Foo { Foo'Foo{X: 42}}And a file named “Baz.pen” with:
import 'Bar
f = \() number { Bar'Bar().X}When I run pen build
Then the exit status should be 0.