diff --git a/features/commands/build.feature b/features/commands/build.feature index 455a48cadc..c4d18d8aae 100644 --- a/features/commands/build.feature +++ b/features/commands/build.feature @@ -1,60 +1,60 @@ Feature: Building packages Scenario: Build an application package Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os" + } } - } - """ + """ And a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - main = \(ctx context) none { - none - } - """ + main = \(ctx context) none { + none + } + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Build a library package Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ And a file named "Foo.pen" with: - """pen - f = \(x number) number { - x - } - """ + """pen + f = \(x number) number { + x + } + """ When I run `pen build` Then the exit status should be 0 Scenario Outline: Cross-build an application package Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os-sync" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os-sync" + } } - } - """ + """ And a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - main = \(ctx context) none { - none - } - """ + main = \(ctx context) none { + none + } + """ And I successfully run `rustup target add ` When I successfully run `pen build --target ` Then the exit status should be 0 @@ -68,18 +68,18 @@ Feature: Building packages Scenario Outline: Cross-build a library package Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ And a file named "Foo.pen" with: - """pen - f = \(x number) number { - x - } - """ + """pen + f = \(x number) number { + x + } + """ And I successfully run `rustup target add ` When I successfully run `pen build --target ` Then the exit status should be 0 @@ -93,36 +93,36 @@ Feature: Building packages Scenario: Build an application package again Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os" + } } - } - """ + """ And a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - main = \(ctx context) none { - none - } - """ + main = \(ctx context) none { + none + } + """ And I successfully run `pen build` And I successfully run `./app` And the stdout from "./app" should contain exactly "" When a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File + """pen + import Os'Context { Context } + import Os'File - main = \(ctx context) none { - _ = File'Write(ctx.Os, File'StdOut(), "hello") + main = \(ctx context) none { + _ = File'Write(ctx.Os, File'StdOut(), "hello") - none - } - """ + none + } + """ And I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should contain exactly "hello" diff --git a/features/commands/document.feature b/features/commands/document.feature index 12ef157e89..3508b90a3a 100644 --- a/features/commands/document.feature +++ b/features/commands/document.feature @@ -1,27 +1,27 @@ Feature: Generating documentation for a package Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Generate documentation for a package Given a file named "Foo.pen" with: - """pen - # Do something nice. - Foo = \() none { - none - } - """ + """pen + # Do something nice. + Foo = \() none { + none + } + """ When I run the following script: - """sh - pen document \ - --name Foo \ - --url https://github.com/foo/foo \ - --description "This package is cool." \ - > Foo.md - """ + """sh + pen document \ + --name Foo \ + --url https://github.com/foo/foo \ + --description "This package is cool." \ + > Foo.md + """ Then a file named "Foo.md" should contain "`Foo` package" diff --git a/features/commands/format.feature b/features/commands/format.feature index 2b1fbfe71f..edc6d80648 100644 --- a/features/commands/format.feature +++ b/features/commands/format.feature @@ -1,36 +1,36 @@ Feature: Formatting module files Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Format module files Given a file named "Foo.pen" with: - """pen - Foo = \() none { + """pen + Foo = \() none { - none - } - """ + none + } + """ When I successfully run `pen format` Then a file named "Foo.pen" should contain exactly: - """pen - Foo = \() none { - none - } - """ + """pen + Foo = \() none { + none + } + """ Scenario: Check if module files are formatted Given a file named "Foo.pen" with: - """pen - Foo = \() none { + """pen + Foo = \() none { - none - } - """ + none + } + """ When I run `pen format --checked` Then the exit status should not be 0 diff --git a/features/commands/test.feature b/features/commands/test.feature index c1766791cf..ced23833ba 100644 --- a/features/commands/test.feature +++ b/features/commands/test.feature @@ -1,63 +1,63 @@ Feature: Testing packages Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": { - "Test": "pen:///test" + """json + { + "type": "library", + "dependencies": { + "Test": "pen:///test" + } } - } - """ + """ And a file named "Foo.pen" with: - """pen - Add = \(x number, y number) number { - x + y - } - """ + """pen + Add = \(x number, y number) number { + x + y + } + """ Scenario: Test a module Given a file named "Foo.test.pen" with: - """pen - import Test'Assert - import 'Foo + """pen + import Test'Assert + import 'Foo - Add = \() none | error { - Assert'Equal(Foo'Add(41, 1), 42) - } - """ + 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" Scenario: Fail to test a module Given a file named "Foo.test.pen" with: - """pen - import Test'Assert - import 'Foo + """pen + import Test'Assert + import 'Foo - Add = \() none | error { - Assert'Equal(Foo'Add(41, 0), 42) - } - """ + 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" Scenario: Run multiple tests Given a file named "Foo.test.pen" with: - """pen - import Test'Assert - import 'Foo + """pen + import Test'Assert + import 'Foo - Add = \() none | error { - Assert'Equal(Foo'Add(41, 1), 42) - } + Add = \() none | error { + Assert'Equal(Foo'Add(41, 1), 42) + } - AddMore = \() none | error { - Assert'Equal(Foo'Add(40, 2), 42) - } - """ + AddMore = \() none | error { + Assert'Equal(Foo'Add(40, 2), 42) + } + """ When I successfully run `pen test` Then the exit status should be 0 @@ -67,10 +67,10 @@ Feature: Testing packages Scenario: Use a debug function in a test Given a file named "Foo.test.pen" with: - """pen - Foo = \() none | error { - debug("hello") - } - """ + """pen + Foo = \() none | error { + debug("hello") + } + """ When I run `pen test` Then the exit status should be 0 diff --git a/features/ffi.feature b/features/ffi.feature index 4ecd98794a..638cbf7783 100644 --- a/features/ffi.feature +++ b/features/ffi.feature @@ -1,53 +1,53 @@ Feature: FFI Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Import a foreign function of native calling convention Given a file named "Foo.pen" with: - """pen - import foreign g \(number) number + """pen + import foreign g \(number) number - f = \(x number) number { - g(x) - } - """ + f = \(x number) number { + g(x) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a foreign function of the C calling convention Given a file named "Foo.pen" with: - """pen - import foreign "c" g \(number) number + """pen + import foreign "c" g \(number) number - f = \(x number) number { - g(x) - } - """ + f = \(x number) number { + g(x) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Export a foreign function Given a file named "Foo.pen" with: - """pen - foreign f = \(x number) number { - x - } - """ + """pen + foreign f = \(x number) number { + x + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Export a foreign function of the C calling convention Given a file named "Foo.pen" with: - """pen - foreign "c" f = \(x number) number { - x - } - """ + """pen + foreign "c" f = \(x number) number { + x + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/module.feature b/features/module.feature index 263a5494e1..c359f0ebb7 100644 --- a/features/module.feature +++ b/features/module.feature @@ -1,123 +1,123 @@ Feature: Modules Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Import a function from a module Given a file named "Foo.pen" with: - """pen - Foo = \() number { - 42 - } - """ + """pen + Foo = \() number { + 42 + } + """ And a file named "Bar.pen" with: - """pen - import 'Foo + """pen + import 'Foo - Bar = \() number { - Foo'Foo() - } - """ + Bar = \() number { + Foo'Foo() + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a type alias from a module Given a file named "Foo.pen" with: - """pen - type Foo = number - """ + """pen + type Foo = number + """ And a file named "Bar.pen" with: - """pen - import 'Foo + """pen + import 'Foo - type Bar = Foo'Foo - """ + type Bar = Foo'Foo + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a function from a nested module Given a file named "Foo/Foo.pen" with: - """pen - Foo = \() number { - 42 - } - """ + """pen + Foo = \() number { + 42 + } + """ And a file named "Bar.pen" with: - """pen - import 'Foo'Foo + """pen + import 'Foo'Foo - Bar = \() number { - Foo'Foo() - } - """ + Bar = \() number { + Foo'Foo() + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a module with a custom prefix Given a file named "Foo.pen" with: - """pen - Foo = \() number { - 42 - } - """ + """pen + Foo = \() number { + 42 + } + """ And a file named "Bar.pen" with: - """pen - import 'Foo as Bar + """pen + import 'Foo as Bar - Bar = \() number { - Bar'Foo() - } - """ + Bar = \() number { + Bar'Foo() + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a type definition with no prefix Given a file named "Foo.pen" with: - """pen - type Foo {} - """ + """pen + type Foo {} + """ And a file named "Bar.pen" with: - """pen - import 'Foo { Foo } + """pen + import 'Foo { Foo } - type Bar = Foo - """ + type Bar = Foo + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a type alias with no prefix Given a file named "Foo.pen" with: - """pen - type Foo = number - """ + """pen + type Foo = number + """ And a file named "Bar.pen" with: - """pen - import 'Foo { Foo } + """pen + import 'Foo { Foo } - type Bar = Foo - """ + type Bar = Foo + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a function with no prefix Given a file named "Foo.pen" with: - """pen - Foo = \() number { - 42 - } - """ + """pen + Foo = \() number { + 42 + } + """ And a file named "Bar.pen" with: - """pen - import 'Foo { Foo } + """pen + import 'Foo { Foo } - Bar = \() number { - Foo() - } - """ + Bar = \() number { + Foo() + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/package.feature b/features/package.feature index 7a144ce14e..a86a4ecc5f 100644 --- a/features/package.feature +++ b/features/package.feature @@ -1,68 +1,68 @@ Feature: Packages Background: Given a file named "foo/pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ And a file named "foo/Foo.pen" with: - """pen - type Foo = number + """pen + type Foo = number - Foo = \() number { - 42 - } - """ + Foo = \() number { + 42 + } + """ And a file named "foo/Foo/Foo.pen" with: - """pen - Foo = \() number { - 42 - } - """ + """pen + Foo = \() number { + 42 + } + """ And a directory named "bar" And I cd to "bar" And a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": { - "Foo": "../foo" + """json + { + "type": "library", + "dependencies": { + "Foo": "../foo" + } } - } - """ + """ Scenario: Import a function from a module Given a file named "Bar.pen" with: - """pen - import Foo'Foo + """pen + import Foo'Foo - Bar = \() number { - Foo'Foo() - } - """ + Bar = \() number { + Foo'Foo() + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a type from a module Given a file named "Bar.pen" with: - """pen - import Foo'Foo + """pen + import Foo'Foo - type Bar = Foo'Foo - """ + type Bar = Foo'Foo + """ When I run `pen build` Then the exit status should be 0 Scenario: Import a function from a nested module Given a file named "Bar.pen" with: - """pen - import Foo'Foo'Foo + """pen + import Foo'Foo'Foo - Bar = \() number { - Foo'Foo() - } - """ + Bar = \() number { + Foo'Foo() + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/smoke/built-ins.feature b/features/smoke/built-ins.feature index 0ce19fa449..59cb5b1b76 100644 --- a/features/smoke/built-ins.feature +++ b/features/smoke/built-ins.feature @@ -1,33 +1,33 @@ Feature: Built-ins Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os" + } } - } - """ + """ Scenario Outline: Print a value with a debug function Given a file named "main.pen" with: - """pen - type foo {} + """pen + type foo {} - type bar { - x number - } + type bar { + x number + } - type baz { - x number - y string - } + type baz { + x number + y string + } - main = \(_ context) none { - debug() - } - """ + main = \(_ context) none { + debug() + } + """ When I successfully run `pen build` Then I successfully run `./app` And the stderr from "./app" should contain exactly '' @@ -46,4 +46,4 @@ Feature: Built-ins | [number 42, 42] | [number 42, 42] | | {string: number "foo": 1, "bar": 2} | {string: number "bar": 2, "foo": 1} | | error("foo") | error("foo") | - | \(x none) none { x } | | + | \\(x none) none { x } | | diff --git a/features/smoke/examples.feature b/features/smoke/examples.feature index dc20a14865..e109dd02f1 100644 --- a/features/smoke/examples.feature +++ b/features/smoke/examples.feature @@ -1,9 +1,9 @@ Feature: Examples Background: Given I run the following script: - """ - cp -r $PEN_ROOT/examples . - """ + """ + cp -r $PEN_ROOT/examples . + """ Scenario Outline: Build and test examples When I cd to "examples/" diff --git a/features/smoke/memory-leak/concurrency.feature b/features/smoke/memory-leak/concurrency.feature index 358efcd771..4819db920c 100644 --- a/features/smoke/memory-leak/concurrency.feature +++ b/features/smoke/memory-leak/concurrency.feature @@ -1,25 +1,25 @@ Feature: Concurrency Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Core": "pen:///core", - "Os": "pen:///os" + """json + { + "type": "application", + "dependencies": { + "Core": "pen:///core", + "Os": "pen:///os" + } } - } - """ + """ Scenario Outline: Use spawn function Given a file named "main.pen" with: - """pen - main = \(ctx context) none { - f = go(\() none { none }) + """pen + main = \(ctx context) none { + f = go(\() none { none }) - - } - """ + + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` @@ -30,24 +30,24 @@ Feature: Concurrency Scenario Outline: Use spawn function with a record Given a file named "main.pen" with: - """pen - type foo { - x number - y number - z number - } - - main = \(ctx context) none { - x = foo{x: 1, y: 2, z: 3} - - f = go(\() none { - _ = x - none - }) - - - } - """ + """pen + type foo { + x number + y number + z number + } + + main = \(ctx context) none { + x = foo{x: 1, y: 2, z: 3} + + f = go(\() none { + _ = x + none + }) + + + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` @@ -58,18 +58,18 @@ Feature: Concurrency Scenario Outline: Use spawn function with a closure Given a file named "main.pen" with: - """pen - main = \(ctx context) none { - x = \() none { none } - - f = go(\() none { - _ = x - none - }) - - - } - """ + """pen + main = \(ctx context) none { + x = \() none { none } + + f = go(\() none { + _ = x + none + }) + + + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` @@ -80,29 +80,29 @@ Feature: Concurrency Scenario Outline: Use spawn function with a closure with a record Given a file named "main.pen" with: - """pen - type foo { - x number - y number - z number - } - - main = \(ctx context) none { - x = foo{x: 1, y: 2, z: 3} - - y = \() none { - _ = x - none + """pen + type foo { + x number + y number + z number } - f = go(\() none { - _ = y - none - }) + main = \(ctx context) none { + x = foo{x: 1, y: 2, z: 3} + + y = \() none { + _ = x + none + } + + f = go(\() none { + _ = y + none + }) - - } - """ + + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` @@ -113,19 +113,19 @@ Feature: Concurrency Scenario Outline: Use race function Given a file named "main.pen" with: - """pen - import Os'Process + """pen + import Os'Process - main = \(ctx context) none { - xs = race([[none] [none none]]) + main = \(ctx context) none { + xs = race([[none] [none none]]) - if [x, ...xs] = xs { - - } else { - Process'Exit(ctx.Os, 1) + if [x, ...xs] = xs { + + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` @@ -136,26 +136,26 @@ Feature: Concurrency Scenario Outline: Use race function with a record Given a file named "main.pen" with: - """pen - import Os'Process + """pen + import Os'Process - type foo { - x number - y number - } + type foo { + x number + y number + } - main = \(ctx context) none { - xs = race([[foo] [foo foo{x: 0, y: 0}]]) + main = \(ctx context) none { + xs = race([[foo] [foo foo{x: 0, y: 0}]]) - if [x, ...xs] = xs { - _ = + if [x, ...xs] = xs { + _ = - none - } else { - Process'Exit(ctx.Os, 1) + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` diff --git a/features/smoke/memory-leak/language.feature b/features/smoke/memory-leak/language.feature index 4c7ea6a97e..8057f4573f 100644 --- a/features/smoke/memory-leak/language.feature +++ b/features/smoke/memory-leak/language.feature @@ -1,347 +1,347 @@ Feature: Language Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Core": "pen:///core", - "Os": "pen:///os-sync" + """json + { + "type": "application", + "dependencies": { + "Core": "pen:///core", + "Os": "pen:///os-sync" + } } - } - """ + """ Scenario: Run hello world Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File + """pen + import Os'Context { Context } + import Os'File - main = \(ctx context) none { - _ = File'Write(ctx.Os, File'StdOut(), "Hello, world!\n") + main = \(ctx context) none { + _ = File'Write(ctx.Os, File'StdOut(), "Hello, world!\n") - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Create a record Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - type foo { - x number - } + type foo { + x number + } - main = \(ctx context) none { - _ = foo{x: 42} + main = \(ctx context) none { + _ = foo{x: 42} - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Deconstruct a record Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - type foo { - x number - } + type foo { + x number + } - main = \(ctx context) none { - _ = foo{x: 42}.x + main = \(ctx context) none { + _ = foo{x: 42}.x - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Put a string into a value of any type Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - f = \(x any) any { - x - } + f = \(x any) any { + x + } - main = \(ctx context) none { - f("") + main = \(ctx context) none { + f("") - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Shadow a variable in a block Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - type foo { - x number - } + type foo { + x number + } - main = \(ctx context) none { - x = foo{x: 42} - x = x.x + main = \(ctx context) none { + x = foo{x: 42} + x = x.x - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Define a function in a let expression with a free variable Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - type foo { - x number - } + type foo { + x number + } - main = \(ctx context) none { - x = foo{x: 42} - _ = \() number { x.x } + main = \(ctx context) none { + x = foo{x: 42} + _ = \() number { x.x } - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Convert a number to a string Given a file named "main.pen" with: - """pen - import Core'Number - import Os'Context { Context } + """pen + import Core'Number + import Os'Context { Context } - main = \(ctx context) none { - Number'String(42) + main = \(ctx context) none { + Number'String(42) - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Join strings Given a file named "main.pen" with: - """pen - import Core'String - import Os'Context { Context } + """pen + import Core'String + import Os'Context { Context } - main = \(ctx context) none { - String'Join([string "hello", "world"], " ") + main = \(ctx context) none { + String'Join([string "hello", "world"], " ") - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Drop an unforced list Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - type foo { - x number - } + type foo { + x number + } - main = \(ctx context) none { - x = foo{x: 42} - _ = [foo x] + main = \(ctx context) none { + x = foo{x: 42} + _ = [foo x] - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Drop a forced list Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } + + type foo { + x number + } - type foo { - x number - } + main = \(ctx context) none { + x = foo{x: 42} - main = \(ctx context) none { - x = foo{x: 42} + if [x, ...xs] = [foo x] { + x() + } else { + none + } - if [x, ...xs] = [foo x] { - x() - } else { none } - - none - } - """ + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Drop an unforced list with no environment Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - type foo { - x number - } + type foo { + x number + } - main = \(ctx context) none { - [foo foo{x: 42}] + main = \(ctx context) none { + [foo foo{x: 42}] - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Drop a forced list with no environment Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - type foo { - x number - } + type foo { + x number + } + + main = \(ctx context) none { + if [x, ...xs] = [foo foo{x: 42}] { + x() + } else { + none + } - main = \(ctx context) none { - if [x, ...xs] = [foo foo{x: 42}] { - x() - } else { none } - - none - } - """ + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Force an element twice Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - main = \(ctx context) none { - xs = [none none] + main = \(ctx context) none { + xs = [none none] + + if [x, ..._] = xs { + x() + x() + } else { + none + } - if [x, ..._] = xs { - x() - x() - } else { none } - - none - } - """ + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Use spawn function Given a file named "main.pen" with: - """pen - main = \(ctx context) none { - f = go(\() none { none }) + """pen + main = \(ctx context) none { + f = go(\() none { none }) - f() - } - """ + f() + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Use spawn function with a record Given a file named "main.pen" with: - """pen - type foo { - x number - y number - z number - } - - main = \(ctx context) none { - x = foo{x: 1, y: 2, z: 3} - - f = go(\() none { - _ = x - none - }) + """pen + type foo { + x number + y number + z number + } + + main = \(ctx context) none { + x = foo{x: 1, y: 2, z: 3} - f() - } - """ + f = go(\() none { + _ = x + none + }) + + f() + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Use spawn function with a closure Given a file named "main.pen" with: - """pen - main = \(ctx context) none { - x = \() none { none } + """pen + main = \(ctx context) none { + x = \() none { none } - f = go(\() none { - _ = x - none - }) + f = go(\() none { + _ = x + none + }) - f() - } - """ + f() + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Use spawn function with a closure with a record Given a file named "main.pen" with: - """pen - type foo { - x number - y number - z number - } - - main = \(ctx context) none { - x = foo{x: 1, y: 2, z: 3} - - y = \() none { - _ = x - none + """pen + type foo { + x number + y number + z number } - f = go(\() none { - _ = y - none - }) + main = \(ctx context) none { + x = foo{x: 1, y: 2, z: 3} - f() - } - """ + y = \() none { + _ = x + none + } + + f = go(\() none { + _ = y + none + }) + + f() + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Concatenate strings Given a file named "main.pen" with: - """pen - main = \(ctx context) none { - x = "foo" - y = x + x - z = y + y - - none - } - """ + """pen + main = \(ctx context) none { + x = "foo" + y = x + x + z = y + y + + none + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` diff --git a/features/smoke/module.feature b/features/smoke/module.feature index 7b3e001c5d..4242280fc3 100644 --- a/features/smoke/module.feature +++ b/features/smoke/module.feature @@ -1,56 +1,56 @@ Feature: Modules Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Import a duplicate name Given a file named "foo.pen" with: - """pen - Foo = \(x number) number { x } - """ + """pen + Foo = \(x number) number { x } + """ And a file named "bar.pen" with: - """pen - import 'foo { Foo } + """pen + import 'foo { Foo } - Foo = \() none { Foo() } - """ + Foo = \() none { Foo() } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Compare a type imported indirectly Given a file named "foo.pen" with: - """pen - type Foo {} - """ + """pen + type Foo {} + """ And a file named "bar.pen" with: - """pen - import 'foo { Foo } + """pen + import 'foo { Foo } - type Bar { - xs [Foo] - } - """ + type Bar { + xs [Foo] + } + """ And a file named "baz.pen" with: - """pen - import 'bar { Bar } + """pen + import 'bar { Bar } - type Baz = Bar - """ + type Baz = Bar + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Import an undefined name Given a file named "foo.pen" with: - """pen - """ + """pen + """ And a file named "bar.pen" with: - """pen - import 'foo { tomato } - """ + """pen + import 'foo { tomato } + """ When I run `pen build` Then the exit status should not be 0 diff --git a/features/smoke/os.feature b/features/smoke/os.feature index 52d87e08f2..c647421f23 100644 --- a/features/smoke/os.feature +++ b/features/smoke/os.feature @@ -1,49 +1,49 @@ Feature: OS Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os", - "Core": "pen:///core" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os", + "Core": "pen:///core" + } } - } - """ + """ Scenario: Read and write files Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'File'OpenOptions { OpenOptions } - import Os'Process + """pen + import Os'Context { Context } + import Os'File + import Os'File'OpenOptions { OpenOptions } + import Os'Process - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - f = File'Open(ctx, "foo.txt")? - d = File'Read(ctx, f)? - f = File'OpenWithOptions( - ctx, - "bar.txt", - OpenOptions{ - ...OpenOptions'Default(), - Create: true, - Write: true, - }, - )? - File'Write(ctx, f, d)? + run = \(ctx Context) none | error { + f = File'Open(ctx, "foo.txt")? + d = File'Read(ctx, f)? + f = File'OpenWithOptions( + ctx, + "bar.txt", + OpenOptions{ + ...OpenOptions'Default(), + Create: true, + Write: true, + }, + )? + File'Write(ctx, f, d)? - none - } - """ + none + } + """ And a file named "foo.txt" with "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -51,27 +51,27 @@ Feature: OS Scenario: Read a file until a limit Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process + """pen + import Os'Context { Context } + import Os'File + import Os'Process - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - f = File'Open(ctx, "foo.txt")? - d = File'ReadLimit(ctx, f, 5)? - File'Write(ctx, File'StdOut(), d)? + run = \(ctx Context) none | error { + f = File'Open(ctx, "foo.txt")? + d = File'ReadLimit(ctx, f, 5)? + File'Write(ctx, File'StdOut(), d)? - none - } - """ + none + } + """ And a file named "foo.txt" with "Hello, world!" When I successfully run `pen build` Then I successfully run `./app` @@ -79,31 +79,31 @@ Feature: OS Scenario: Read a directory Given a file named "main.pen" with: - """pen - import Core'String - import Os'Context { Context } - import Os'File - import Os'Directory - import Os'Process + """pen + import Core'String + import Os'Context { Context } + import Os'File + import Os'Directory + import Os'Process - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write( - ctx, - File'StdOut(), - String'Join(Directory'Read(ctx, ".")?, "\n"), - )? + run = \(ctx Context) none | error { + File'Write( + ctx, + File'StdOut(), + String'Join(Directory'Read(ctx, ".")?, "\n"), + )? - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should contain "main.pen" @@ -111,14 +111,14 @@ Feature: OS Scenario: Use go syntax Given a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - main = \(ctx context) none { - f = go(\() none { none }) + main = \(ctx context) none { + f = go(\() none { none }) - f() - } - """ + f() + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` diff --git a/features/smoke/standard-packages.feature b/features/smoke/standard-packages.feature index 6fe51c9dc9..3ffa2c286f 100644 --- a/features/smoke/standard-packages.feature +++ b/features/smoke/standard-packages.feature @@ -1,9 +1,9 @@ Feature: Standard packages Scenario Outline: Build and test standard packages Given I run the following script: - """ - cp -r $PEN_ROOT/packages . - """ + """ + cp -r $PEN_ROOT/packages . + """ When I cd to "packages/" Then I successfully run `pen format --check` And I successfully run `pen build` diff --git a/features/smoke/syntax.feature b/features/smoke/syntax.feature index 67d1e4c500..8e3550bac3 100644 --- a/features/smoke/syntax.feature +++ b/features/smoke/syntax.feature @@ -1,49 +1,49 @@ Feature: Syntax Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Override a built-in function Given a file named "Foo.pen" with: - """pen - go = \() none { - none - } + """pen + go = \() none { + none + } - foo = \() none { - go() - } - """ + foo = \() none { + go() + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Override a built-in type with a type definition Given a file named "Foo.pen" with: - """pen - type none { - x number - } + """pen + type none { + x number + } - foo = \() none { - none{x: 42} - } - """ + foo = \() none { + none{x: 42} + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Override a built-in type with a type alias Given a file named "Foo.pen" with: - """pen - type none = number + """pen + type none = number - foo = \() none { - 0 - } - """ + foo = \() none { + 0 + } + """ When I successfully run `pen build` Then the exit status should be 0 diff --git a/features/smoke/test-packages.feature b/features/smoke/test-packages.feature index 660a359ca4..900d79972a 100644 --- a/features/smoke/test-packages.feature +++ b/features/smoke/test-packages.feature @@ -1,9 +1,9 @@ Feature: Test packages Scenario Outline: Build and test test packages Given I run the following script: - """ - cp -r $PEN_ROOT/test . - """ + """ + cp -r $PEN_ROOT/test . + """ When I cd to "test/" Then I successfully run `pen format --check` And I successfully run `pen build` diff --git a/features/smoke/test.feature b/features/smoke/test.feature index 47b8ffe704..7d4361433d 100644 --- a/features/smoke/test.feature +++ b/features/smoke/test.feature @@ -1,97 +1,97 @@ Feature: Testing Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": { - "Test": "pen:///test" + """json + { + "type": "library", + "dependencies": { + "Test": "pen:///test" + } } - } - """ + """ And a file named "Foo.pen" with: - """pen - Add = \(x number, y number) number { - x + y - } - """ + """pen + Add = \(x number, y number) number { + x + y + } + """ Scenario: Run a test referencing an Os package Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os", - "Test": "pen:///test" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os", + "Test": "pen:///test" + } } - } - """ + """ And a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - main = \(ctx context) none { - none - } - """ + main = \(ctx context) none { + none + } + """ And a file named "main.test.pen" with: - """pen - import Os'File + """pen + import Os'File - Foo = \() none | error { - _ = File'Write + Foo = \() none | error { + _ = File'Write - none - } - """ + none + } + """ When I successfully run `pen test` Then the exit status should be 0 Scenario: Run tests without a Test package Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ And a file named "Foo.test.pen" with: - """pen - import 'Foo + """pen + import 'Foo - Add = \() none | error { - if Foo'Add(41, 1) == 42 { none } else { error("oh no") } - } - """ + Add = \() none | error { + if Foo'Add(41, 1) == 42 { none } else { error("oh no") } + } + """ When I successfully run `pen test` Then the exit status should be 0 Scenario: Keep an application file on testing Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os", - "Test": "pen:///test" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os", + "Test": "pen:///test" + } } - } - """ + """ And a file named "main.pen" with: - """pen - import Os'Context { Context } + """pen + import Os'Context { Context } - main = \(ctx context) none { - none - } - """ + main = \(ctx context) none { + none + } + """ And a file named "main.test.pen" with: - """pen - Foo = \() none | error { - none - } - """ + """pen + Foo = \() none | error { + none + } + """ And I successfully run `pen build` When I successfully run `pen test` Then I successfully run `./app` diff --git a/features/smoke/types/list.feature b/features/smoke/types/list.feature index b36cda0a13..ff464a2821 100644 --- a/features/smoke/types/list.feature +++ b/features/smoke/types/list.feature @@ -1,106 +1,106 @@ Feature: List Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os" + } } - } - """ + """ Scenario: Force multiple elements of a list Given a file named "main.pen" with: - """pen - import Os'Process + """pen + import Os'Process - main = \(ctx context) none { - if [x, ...xs] = [none ...[none none]] { - x() + main = \(ctx context) none { + if [x, ...xs] = [none ...[none none]] { + x() - none - } else { - Process'Exit(ctx.Os, 1) + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Force an element in a list of any type Given a file named "main.pen" with: - """pen - import Os'Process + """pen + import Os'Process - main = \(ctx context) none { - if [x, ..._] = [any "foo"] { - x() + main = \(ctx context) none { + if [x, ..._] = [any "foo"] { + x() - none - } else { - Process'Exit(ctx.Os, 1) + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Compile nested list comprehension Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Process - - f = \(xss [[boolean]]) [[number]] { - [[number] - [number if x() { 1 } else { 0 } for x in xs()] - for xs in xss - ] - } + """pen + import Os'Context { Context } + import Os'Process + + f = \(xss [[boolean]]) [[number]] { + [[number] + [number if x() { 1 } else { 0 } for x in xs()] + for xs in xss + ] + } - main = \(ctx context) none { - if [x, ..._] = f([[boolean] [boolean true, false]]) { - x() + main = \(ctx context) none { + if [x, ..._] = f([[boolean] [boolean true, false]]) { + x() - none - } else { - Process'Exit(ctx.Os, 1) + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` Scenario: Compile list comprehension with wrong typing Given a file named "main.pen" with: - """pen - main = \(ctx context) none { - _ = [none x() for x in [none 1]] + """pen + main = \(ctx context) none { + _ = [none x() for x in [none 1]] - none - } - """ + none + } + """ When I run `pen build` Then the stderr should contain "types not matched" Scenario: Evaluate list comprehension lazily Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Process + """pen + import Os'Context { Context } + import Os'Process - xs = \(ctx Context) [none] { - Process'Exit(ctx, 1) + xs = \(ctx Context) [none] { + Process'Exit(ctx, 1) - [none] - } + [none] + } - main = \(ctx context) none { - _ = [none x() for x in xs(ctx.Os)] + main = \(ctx context) none { + _ = [none x() for x in xs(ctx.Os)] - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` diff --git a/features/smoke/types/string.feature b/features/smoke/types/string.feature index 0f544bd60c..7d78d14710 100644 --- a/features/smoke/types/string.feature +++ b/features/smoke/types/string.feature @@ -1,24 +1,24 @@ Feature: String Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os" + } } - } - """ + """ Scenario: Concatenate zero-length strings Given a file named "main.pen" with: - """pen - import Os'Process + """pen + import Os'Process - main = \(ctx context) none { - debug("" + "foo" + "") - } - """ + main = \(ctx context) none { + debug("" + "foo" + "") + } + """ When I successfully run `pen build` Then I successfully run `check_memory_leak.sh ./app` And I successfully run `./app` diff --git a/features/standard-packages/core.feature b/features/standard-packages/core.feature index adc60ad6df..6d842841a8 100644 --- a/features/standard-packages/core.feature +++ b/features/standard-packages/core.feature @@ -1,59 +1,59 @@ Feature: Core Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": { - "Core": "pen:///core" + """json + { + "type": "library", + "dependencies": { + "Core": "pen:///core" + } } - } - """ + """ Scenario: Convert a number to a string Given a file named "Foo.pen" with: - """pen - import Core'Number + """pen + import Core'Number - f = \() string { - Number'String(42) - } - """ + f = \() string { + Number'String(42) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Sum numbers Given a file named "Foo.pen" with: - """pen - import Core'Number + """pen + import Core'Number - f = \() number { - Number'Sum([number 1, 2, 3]) - } - """ + f = \() number { + Number'Sum([number 1, 2, 3]) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Join strings Given a file named "Foo.pen" with: - """pen - import Core'String + """pen + import Core'String - f = \() string { - String'Join([string "hello", "world"], " ") - } - """ + f = \() string { + String'Join([string "hello", "world"], " ") + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Slice a string as bytes Given a file named "Foo.pen" with: - """pen - import Core'String'Byte + """pen + import Core'String'Byte - f = \() string { - Byte'Slice("foo", 1, 2) - } - """ + f = \() string { + Byte'Slice("foo", 1, 2) + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/standard-packages/os-sync.feature b/features/standard-packages/os-sync.feature index a060ea2f4b..c8aabd1818 100644 --- a/features/standard-packages/os-sync.feature +++ b/features/standard-packages/os-sync.feature @@ -1,91 +1,91 @@ Feature: OS (synchronous version) Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os-sync", - "Core": "pen:///core" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os-sync", + "Core": "pen:///core" + } } - } - """ + """ Scenario: Build an application Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write(ctx, File'StdOut(), "Hello, world!")? + run = \(ctx Context) none | error { + File'Write(ctx, File'StdOut(), "Hello, world!")? - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should contain exactly "Hello, world!" Scenario: Get arguments Given a file named "main.pen" with: - """pen - import Core'String - import Os'Context { Context } - import Os'Environment - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Core'String + import Os'Context { Context } + import Os'Environment + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write(ctx, File'StdOut(), String'Join(Environment'Arguments(ctx), " "))? + run = \(ctx Context) none | error { + File'Write(ctx, File'StdOut(), String'Join(Environment'Arguments(ctx), " "))? - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app foo bar` And stdout from "./app foo bar" should contain exactly "foo bar" Scenario: Get an environment variable Given a file named "main.pen" with: - """pen - import Core'String - import Os'Context { Context } - import Os'File - import Os'Environment - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Core'String + import Os'Context { Context } + import Os'File + import Os'Environment + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write(ctx, File'StdOut(), Environment'Variable(ctx, "FOO")?)? + run = \(ctx Context) none | error { + File'Write(ctx, File'StdOut(), Environment'Variable(ctx, "FOO")?)? - none - } - """ + none + } + """ And I append "foo" to the environment variable "FOO" When I successfully run `pen build` Then I successfully run `./app` @@ -93,54 +93,54 @@ Feature: OS (synchronous version) Scenario: Open a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File { File } - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File { File } + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Open(ctx, "./foo.txt")? + run = \(ctx Context) none | error { + File'Open(ctx, "./foo.txt")? - none - } - """ + none + } + """ And a file named "foo.txt" with "" When I successfully run `pen build` Then I successfully run `./app` Scenario: Read a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'File'OpenOptions - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'File'OpenOptions + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - f = File'Open(ctx, "foo.txt")? - d = File'Read(ctx, f)? + run = \(ctx Context) none | error { + f = File'Open(ctx, "foo.txt")? + d = File'Read(ctx, f)? - File'Write(ctx, File'StdOut(), d)? + File'Write(ctx, File'StdOut(), d)? - none - } - """ + none + } + """ And a file named "foo.txt" with "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -148,27 +148,27 @@ Feature: OS (synchronous version) Scenario: Read a file until a limit Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - f = File'Open(ctx, "foo.txt")? - d = File'ReadLimit(ctx, f, 5)? - File'Write(ctx, File'StdOut(), d)? + run = \(ctx Context) none | error { + f = File'Open(ctx, "foo.txt")? + d = File'ReadLimit(ctx, f, 5)? + File'Write(ctx, File'StdOut(), d)? - none - } - """ + none + } + """ And a file named "foo.txt" with "Hello, world!" When I successfully run `pen build` Then I successfully run `./app` @@ -176,32 +176,32 @@ Feature: OS (synchronous version) Scenario: Write a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'File'OpenOptions { OpenOptions } - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'File'OpenOptions { OpenOptions } + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - f = File'OpenWithOptions( - ctx, - "./foo.txt", - OpenOptions{...OpenOptions'Default(), Write: true}, - )? + run = \(ctx Context) none | error { + f = File'OpenWithOptions( + ctx, + "./foo.txt", + OpenOptions{...OpenOptions'Default(), Write: true}, + )? - File'Write(ctx, f, "foo")? + File'Write(ctx, f, "foo")? - none - } - """ + none + } + """ And a file named "foo.txt" with "" When I successfully run `pen build` Then I successfully run `./app` @@ -209,19 +209,19 @@ Feature: OS (synchronous version) Scenario: Copy a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = File'Copy(ctx.Os, "foo.txt", "bar.txt") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = File'Copy(ctx.Os, "foo.txt", "bar.txt") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ And a file named "foo.txt" with "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -230,19 +230,19 @@ Feature: OS (synchronous version) Scenario: Move a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = File'Move(ctx.Os, "foo.txt", "bar.txt") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = File'Move(ctx.Os, "foo.txt", "bar.txt") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ And a file named "foo.txt" with "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -251,19 +251,19 @@ Feature: OS (synchronous version) Scenario: Remove a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = File'Remove(ctx.Os, "foo.txt") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = File'Remove(ctx.Os, "foo.txt") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ And a file named "foo.txt" with "" When I successfully run `pen build` Then I successfully run `./app` @@ -271,31 +271,31 @@ Feature: OS (synchronous version) Scenario: Read a directory Given a file named "main.pen" with: - """pen - import Core'String - import Os'Context { Context } - import Os'File - import Os'Directory - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { + """pen + import Core'String + import Os'Context { Context } + import Os'File + import Os'Directory + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } + } + + run = \(ctx Context) none | error { + File'Write( + ctx, + File'StdOut(), + String'Join(Directory'Read(ctx, ".")?, "\n"), + )? + none - } else { - Process'Exit(ctx.Os, 1) } - } - - run = \(ctx Context) none | error { - File'Write( - ctx, - File'StdOut(), - String'Join(Directory'Read(ctx, ".")?, "\n"), - )? - - none - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should contain "main.pen" @@ -303,38 +303,38 @@ Feature: OS (synchronous version) Scenario: Create a directory Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Directory - import Os'Process - - main = \(ctx context) none { - if _ = Directory'Create(ctx.Os, "foo") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'Directory + import Os'Process + + main = \(ctx context) none { + if _ = Directory'Create(ctx.Os, "foo") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` And a directory named "foo" should exist Scenario: Remove a directory Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Directory - import Os'Process - - main = \(ctx context) none { - if _ = Directory'Remove(ctx.Os, "foo") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'Directory + import Os'Process + + main = \(ctx context) none { + if _ = Directory'Remove(ctx.Os, "foo") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ And a directory named "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -342,84 +342,84 @@ Feature: OS (synchronous version) Scenario: Get file metadata Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'File'Metadata { Metadata } - import Os'Process - - main = \(ctx context) none { - m = File'Metadata(ctx.Os, "foo") - - c = if m = m as Metadata { - if m.Size == 3 { - 0 + """pen + import Os'Context { Context } + import Os'File + import Os'File'Metadata { Metadata } + import Os'Process + + main = \(ctx context) none { + m = File'Metadata(ctx.Os, "foo") + + c = if m = m as Metadata { + if m.Size == 3 { + 0 + } else { + 1 + } } else { 1 } - } else { - 1 - } - Process'Exit(ctx.Os, c) - } - """ + Process'Exit(ctx.Os, c) + } + """ And a file named "foo" with: - """ - foo - """ + """ + foo + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Get system time Given a file named "main.pen" with: - """pen - import Core'Number - import Os'Context { Context } - import Os'File - import Os'Process - import Os'Time - - main = \(ctx context) none { - if m = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Core'Number + import Os'Context { Context } + import Os'File + import Os'Process + import Os'Time + + main = \(ctx context) none { + if m = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write(ctx, File'StdOut(), Number'String(Time'Now(ctx)))? + run = \(ctx Context) none | error { + File'Write(ctx, File'StdOut(), Number'String(Time'Now(ctx)))? - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Sleep Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Time - - main = \(ctx context) none { - Time'Sleep(ctx.Os, 1) - } - """ + """pen + import Os'Context { Context } + import Os'Time + + main = \(ctx context) none { + Time'Sleep(ctx.Os, 1) + } + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Exit a process Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Process - - main = \(ctx context) none { - Process'Exit(ctx.Os, 42) - } - """ + """pen + import Os'Context { Context } + import Os'Process + + main = \(ctx context) none { + Process'Exit(ctx.Os, 42) + } + """ When I successfully run `pen build` Then I run `./app` And the exit status should be 42 diff --git a/features/standard-packages/os.feature b/features/standard-packages/os.feature index 2465a4bc9a..ce8bddc26b 100644 --- a/features/standard-packages/os.feature +++ b/features/standard-packages/os.feature @@ -1,91 +1,91 @@ Feature: Os Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os", - "Core": "pen:///core" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os", + "Core": "pen:///core" + } } - } - """ + """ Scenario: Build an application Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write(ctx, File'StdOut(), "Hello, world!")? + run = \(ctx Context) none | error { + File'Write(ctx, File'StdOut(), "Hello, world!")? - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should contain exactly "Hello, world!" Scenario: Get arguments Given a file named "main.pen" with: - """pen - import Core'String - import Os'Context { Context } - import Os'Environment - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Core'String + import Os'Context { Context } + import Os'Environment + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write(ctx, File'StdOut(), String'Join(Environment'Arguments(ctx), " "))? + run = \(ctx Context) none | error { + File'Write(ctx, File'StdOut(), String'Join(Environment'Arguments(ctx), " "))? - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app foo bar` And stdout from "./app foo bar" should contain exactly "foo bar" Scenario: Get an environment variable Given a file named "main.pen" with: - """pen - import Core'String - import Os'Context { Context } - import Os'File - import Os'Environment - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Core'String + import Os'Context { Context } + import Os'File + import Os'Environment + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write(ctx, File'StdOut(), Environment'Variable(ctx, "FOO")?)? + run = \(ctx Context) none | error { + File'Write(ctx, File'StdOut(), Environment'Variable(ctx, "FOO")?)? - none - } - """ + none + } + """ And I append "foo" to the environment variable "FOO" When I successfully run `pen build` Then I successfully run `./app` @@ -93,54 +93,54 @@ Feature: Os Scenario: Open a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File { File } - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File { File } + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Open(ctx, "./foo.txt")? + run = \(ctx Context) none | error { + File'Open(ctx, "./foo.txt")? - none - } - """ + none + } + """ And a file named "foo.txt" with "" When I successfully run `pen build` Then I successfully run `./app` Scenario: Read a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'File'OpenOptions - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'File'OpenOptions + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - f = File'Open(ctx, "foo.txt")? - d = File'Read(ctx, f)? + run = \(ctx Context) none | error { + f = File'Open(ctx, "foo.txt")? + d = File'Read(ctx, f)? - File'Write(ctx, File'StdOut(), d)? + File'Write(ctx, File'StdOut(), d)? - none - } - """ + none + } + """ And a file named "foo.txt" with "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -148,27 +148,27 @@ Feature: Os Scenario: Read a file until a limit Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - f = File'Open(ctx, "foo.txt")? - d = File'ReadLimit(ctx, f, 5)? - File'Write(ctx, File'StdOut(), d)? + run = \(ctx Context) none | error { + f = File'Open(ctx, "foo.txt")? + d = File'ReadLimit(ctx, f, 5)? + File'Write(ctx, File'StdOut(), d)? - none - } - """ + none + } + """ And a file named "foo.txt" with "Hello, world!" When I successfully run `pen build` Then I successfully run `./app` @@ -176,32 +176,32 @@ Feature: Os Scenario: Write a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'File'OpenOptions { OpenOptions } - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'File'OpenOptions { OpenOptions } + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - f = File'OpenWithOptions( - ctx, - "./foo.txt", - OpenOptions{...OpenOptions'Default(), Write: true}, - )? + run = \(ctx Context) none | error { + f = File'OpenWithOptions( + ctx, + "./foo.txt", + OpenOptions{...OpenOptions'Default(), Write: true}, + )? - File'Write(ctx, f, "foo")? + File'Write(ctx, f, "foo")? - none - } - """ + none + } + """ And a file named "foo.txt" with "" When I successfully run `pen build` Then I successfully run `./app` @@ -209,19 +209,19 @@ Feature: Os Scenario: Copy a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = File'Copy(ctx.Os, "foo.txt", "bar.txt") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = File'Copy(ctx.Os, "foo.txt", "bar.txt") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ And a file named "foo.txt" with "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -230,19 +230,19 @@ Feature: Os Scenario: Move a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = File'Move(ctx.Os, "foo.txt", "bar.txt") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = File'Move(ctx.Os, "foo.txt", "bar.txt") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ And a file named "foo.txt" with "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -251,19 +251,19 @@ Feature: Os Scenario: Remove a file Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'Process - - main = \(ctx context) none { - if _ = File'Remove(ctx.Os, "foo.txt") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'File + import Os'Process + + main = \(ctx context) none { + if _ = File'Remove(ctx.Os, "foo.txt") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ And a file named "foo.txt" with "" When I successfully run `pen build` Then I successfully run `./app` @@ -271,31 +271,31 @@ Feature: Os Scenario: Read a directory Given a file named "main.pen" with: - """pen - import Core'String - import Os'Context { Context } - import Os'File - import Os'Directory - import Os'Process - - main = \(ctx context) none { - if _ = run(ctx.Os) as none { + """pen + import Core'String + import Os'Context { Context } + import Os'File + import Os'Directory + import Os'Process + + main = \(ctx context) none { + if _ = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } + } + + run = \(ctx Context) none | error { + File'Write( + ctx, + File'StdOut(), + String'Join(Directory'Read(ctx, ".")?, "\n"), + )? + none - } else { - Process'Exit(ctx.Os, 1) } - } - - run = \(ctx Context) none | error { - File'Write( - ctx, - File'StdOut(), - String'Join(Directory'Read(ctx, ".")?, "\n"), - )? - - none - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should contain "main.pen" @@ -303,38 +303,38 @@ Feature: Os Scenario: Create a directory Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Directory - import Os'Process - - main = \(ctx context) none { - if _ = Directory'Create(ctx.Os, "foo") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'Directory + import Os'Process + + main = \(ctx context) none { + if _ = Directory'Create(ctx.Os, "foo") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` And a directory named "foo" should exist Scenario: Remove a directory Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Directory - import Os'Process - - main = \(ctx context) none { - if _ = Directory'Remove(ctx.Os, "foo") as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Os'Context { Context } + import Os'Directory + import Os'Process + + main = \(ctx context) none { + if _ = Directory'Remove(ctx.Os, "foo") as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ And a directory named "foo" When I successfully run `pen build` Then I successfully run `./app` @@ -342,84 +342,84 @@ Feature: Os Scenario: Get file metadata Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'File - import Os'File'Metadata { Metadata } - import Os'Process - - main = \(ctx context) none { - m = File'Metadata(ctx.Os, "foo") - - c = if m = m as Metadata { - if m.Size == 3 { - 0 + """pen + import Os'Context { Context } + import Os'File + import Os'File'Metadata { Metadata } + import Os'Process + + main = \(ctx context) none { + m = File'Metadata(ctx.Os, "foo") + + c = if m = m as Metadata { + if m.Size == 3 { + 0 + } else { + 1 + } } else { 1 } - } else { - 1 - } - Process'Exit(ctx.Os, c) - } - """ + Process'Exit(ctx.Os, c) + } + """ And a file named "foo" with: - """ - foo - """ + """ + foo + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Get system time Given a file named "main.pen" with: - """pen - import Core'Number - import Os'Context { Context } - import Os'File - import Os'Process - import Os'Time - - main = \(ctx context) none { - if m = run(ctx.Os) as none { - none - } else { - Process'Exit(ctx.Os, 1) + """pen + import Core'Number + import Os'Context { Context } + import Os'File + import Os'Process + import Os'Time + + main = \(ctx context) none { + if m = run(ctx.Os) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx Context) none | error { - File'Write(ctx, File'StdOut(), Number'String(Time'Now(ctx)))? + run = \(ctx Context) none | error { + File'Write(ctx, File'StdOut(), Number'String(Time'Now(ctx)))? - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Sleep Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Time - - main = \(ctx context) none { - Time'Sleep(ctx.Os, 1) - } - """ + """pen + import Os'Context { Context } + import Os'Time + + main = \(ctx context) none { + Time'Sleep(ctx.Os, 1) + } + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Exit a process Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Process - - main = \(ctx context) none { - Process'Exit(ctx.Os, 42) - } - """ + """pen + import Os'Context { Context } + import Os'Process + + main = \(ctx context) none { + Process'Exit(ctx.Os, 42) + } + """ When I successfully run `pen build` Then I run `./app` And the exit status should be 42 diff --git a/features/standard-packages/random.feature b/features/standard-packages/random.feature index 8c6b400168..df45bffd86 100644 --- a/features/standard-packages/random.feature +++ b/features/standard-packages/random.feature @@ -1,39 +1,39 @@ Feature: Random Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Core": "pen:///core", - "Os": "pen:///os", - "Random": "pen:///random" + """json + { + "type": "application", + "dependencies": { + "Core": "pen:///core", + "Os": "pen:///os", + "Random": "pen:///random" + } } - } - """ + """ Scenario: Generate a random number Given a file named "main.pen" with: - """pen - import Core'Number - import Os'Context { Context } - import Os'File - import Os'Process - import Random'Random + """pen + import Core'Number + import Os'Context { Context } + import Os'File + import Os'Process + import Random'Random - main = \(ctx context) none { - if m = run(ctx) as none { - none - } else { - Process'Exit(ctx.Os, 1) + main = \(ctx context) none { + if m = run(ctx) as none { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - run = \(ctx context) none | error { - File'Write(ctx.Os, File'StdOut(), Number'String(Random'Number(ctx.Random)))? + run = \(ctx context) none | error { + File'Write(ctx.Os, File'StdOut(), Number'String(Random'Number(ctx.Random)))? - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` diff --git a/features/standard-packages/test.feature b/features/standard-packages/test.feature index 25cae8abb3..a9ed21dcc2 100644 --- a/features/standard-packages/test.feature +++ b/features/standard-packages/test.feature @@ -1,47 +1,47 @@ Feature: Test Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": { - "Test": "pen:///test" + """json + { + "type": "library", + "dependencies": { + "Test": "pen:///test" + } } - } - """ + """ Scenario: Check if a condition is true Given a file named "foo.test.pen" with: - """pen - import Test'Assert + """pen + import Test'Assert - Foo = \() none | error { - Assert'True(true) - } - """ + Foo = \() none | error { + Assert'True(true) + } + """ When I run `pen test` Then the exit status should be 0 Scenario: Check if a value is an error Given a file named "foo.test.pen" with: - """pen - import Test'Assert + """pen + import Test'Assert - Foo = \() none | error { - Assert'Error(error(none)) - } - """ + Foo = \() none | error { + Assert'Error(error(none)) + } + """ When I run `pen test` Then the exit status should be 0 Scenario: Make a test fail Given a file named "foo.test.pen" with: - """pen - import Test'Assert + """pen + import Test'Assert - Foo = \() none | error { - Assert'Fail() - } - """ + Foo = \() none | error { + Assert'Fail() + } + """ When I run `pen test` Then the exit status should be 1 diff --git a/features/syntax/block.feature b/features/syntax/block.feature index 43e3eefd93..4c14b9a93f 100644 --- a/features/syntax/block.feature +++ b/features/syntax/block.feature @@ -1,61 +1,61 @@ Feature: Block Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Define a variable Given a file named "Foo.pen" with: - """pen - f = \(x number) number { - y = x + """pen + f = \(x number) number { + y = x - y - } - """ + y + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Call a function Given a file named "Foo.pen" with: - """pen - f = \() none { - none - } + """pen + f = \() none { + none + } - g = \() none { - f() + g = \() none { + f() - none - } - """ + none + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use if expression Given a file named "Foo.pen" with: - """pen - f = \() none { - none - } - - g = \() none { - none - } + """pen + f = \() none { + none + } - h = \(x boolean) none { - if x { - f() - } else { - g() + g = \() none { + none } - none - } - """ + h = \(x boolean) none { + if x { + f() + } else { + g() + } + + none + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/syntax/concurrency.feature b/features/syntax/concurrency.feature index c84c12697d..a04ad8d7d6 100644 --- a/features/syntax/concurrency.feature +++ b/features/syntax/concurrency.feature @@ -1,109 +1,109 @@ Feature: Concurrency Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os" + } } - } - """ + """ Scenario: Use spawn function Given a file named "main.pen" with: - """pen - main = \(ctx context) none { - f = go(\() none { none }) + """pen + main = \(ctx context) none { + f = go(\() none { none }) - f() - } - """ + f() + } + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Use race function Given a file named "main.pen" with: - """pen - import Os'Process + """pen + import Os'Process - main = \(ctx context) none { - xs = race([[none] [none none]]) + main = \(ctx context) none { + xs = race([[none] [none none]]) - if [x, ...xs] = xs { - x() - } else { - Process'Exit(ctx.Os, 1) + if [x, ...xs] = xs { + x() + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Use race function with multiple lists Given a file named "main.pen" with: - """pen - import Os'Process + """pen + import Os'Process - main = \(ctx context) none { - xs = race([[none] [none none], [none none]]) + main = \(ctx context) none { + xs = race([[none] [none none], [none none]]) - if [x, ...xs] = xs { - x() - } else { - Process'Exit(ctx.Os, 1) + if [x, ...xs] = xs { + x() + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Use race function to get the first result Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Process - import Os'Time + """pen + import Os'Context { Context } + import Os'Process + import Os'Time - main = \(ctx context) none { - xs = race([[boolean] - [boolean (\() boolean { loop(ctx.Os) false })()], - [boolean true], - ]) + main = \(ctx context) none { + xs = race([[boolean] + [boolean (\() boolean { loop(ctx.Os) false })()], + [boolean true], + ]) - if [x, ...xs] = xs { - if x() { - none + if [x, ...xs] = xs { + if x() { + none + } else { + Process'Exit(ctx.Os, 1) + } } else { Process'Exit(ctx.Os, 1) } - } else { - Process'Exit(ctx.Os, 1) } - } - loop = \(ctx Context) none { - Time'Sleep(ctx, 1) - loop(ctx) - } - """ + loop = \(ctx Context) none { + Time'Sleep(ctx, 1) + loop(ctx) + } + """ When I successfully run `pen build` Then I successfully run `./app` Scenario: Use race function and get all elements Given a file named "main.pen" with: - """pen - import Os'Process + """pen + import Os'Process - main = \(ctx context) none { - xs = race([[none] [none none], [none none]]) + main = \(ctx context) none { + xs = race([[none] [none none], [none none]]) - if xs == [none none, none] { - none - } else { - Process'Exit(ctx.Os, 1) + if xs == [none none, none] { + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` diff --git a/features/types/any.feature b/features/types/any.feature index 05b6c163d3..4c33ddc448 100644 --- a/features/types/any.feature +++ b/features/types/any.feature @@ -1,33 +1,33 @@ Feature: Any Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Use an any type Given a file named "Foo.pen" with: - """pen - f = \() any { - 42 - } - """ + """pen + f = \() any { + 42 + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Downcast an any type Given a file named "Foo.pen" with: - """pen - f = \(x any) number { - if x = x as number { - x - } else { - 0 + """pen + f = \(x any) number { + if x = x as number { + x + } else { + 0 + } } - } - """ + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/boolean.feature b/features/types/boolean.feature index 3b146cda0f..dc688f4c04 100644 --- a/features/types/boolean.feature +++ b/features/types/boolean.feature @@ -1,67 +1,67 @@ Feature: Boolean Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Use boolean literals Given a file named "Foo.pen" with: - """pen - f = \() boolean { - true - } + """pen + f = \() boolean { + true + } - g = \() boolean { - false - } - """ + g = \() boolean { + false + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use an and operation Given a file named "Foo.pen" with: - """pen - f = \() boolean { - true & false - } - """ + """pen + f = \() boolean { + true & false + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use an or operation Given a file named "Foo.pen" with: - """pen - f = \() boolean { - true | false - } - """ + """pen + f = \() boolean { + true | false + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use a not operation Given a file named "Foo.pen" with: - """pen - f = \() boolean { - !true - } - """ + """pen + f = \() boolean { + !true + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use an if expression Given a file named "Foo.pen" with: - """pen - f = \() number { - if true { - 1 - } else { - 0 + """pen + f = \() number { + if true { + 1 + } else { + 0 + } } - } - """ + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/error.feature b/features/types/error.feature index e39a91d5cc..7648df56c4 100644 --- a/features/types/error.feature +++ b/features/types/error.feature @@ -1,53 +1,53 @@ Feature: Error Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Call an error function Given a file named "Foo.pen" with: - """pen - f = \() error { - error(none) - } - """ + """pen + f = \() error { + error(none) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Call a source function Given a file named "Foo.pen" with: - """pen - f = \(e error) any { - source(e) - } - """ + """pen + f = \(e error) any { + source(e) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use a try operator Given a file named "Foo.pen" with: - """pen - f = \(x number | error) number | error { - x? + 1 - } - """ + """pen + f = \(x number | error) number | error { + x? + 1 + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use a try operator with a union type Given a file named "Foo.pen" with: - """pen - f = \(x number | none | error) number | error { - if x = x? as number { - x + 1 - } else if none { - 0 + """pen + f = \(x number | none | error) number | error { + if x = x? as number { + x + 1 + } else if none { + 0 + } } - } - """ + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/function.feature b/features/types/function.feature index b2cccb52b6..a4da5e6990 100644 --- a/features/types/function.feature +++ b/features/types/function.feature @@ -1,61 +1,61 @@ Feature: Function Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Define a function Given a file named "Foo.pen" with: - """pen - f = \(x number) number { - x - } - """ + """pen + f = \(x number) number { + x + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Call a function with no argument Given a file named "Foo.pen" with: - """pen - f = \() number { - f() - } - """ + """pen + f = \() number { + f() + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Call a function with an argument Given a file named "Foo.pen" with: - """pen - f = \(x number) number { - f(x) - } - """ + """pen + f = \(x number) number { + f(x) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Call a function with two arguments Given a file named "Foo.pen" with: - """pen - f = \(x number, y number) number { - f(x, y) - } - """ + """pen + f = \(x number, y number) number { + f(x, y) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Define a closure Given a file named "Foo.pen" with: - """pen - f = \(x number) \(number) number { - \(y number) number { - x + y + """pen + f = \(x number) \(number) number { + \(y number) number { + x + y + } } - } - """ + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/list.feature b/features/types/list.feature index 315acbde31..6e613915ab 100644 --- a/features/types/list.feature +++ b/features/types/list.feature @@ -1,143 +1,143 @@ Feature: List Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Create an empty list Given a file named "Foo.pen" with: - """pen - f = \() [number] { - [number] - } - """ + """pen + f = \() [number] { + [number] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Create a list with an element Given a file named "Foo.pen" with: - """pen - f = \() [number] { - [number 1] - } - """ + """pen + f = \() [number] { + [number 1] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Create a list with two elements Given a file named "Foo.pen" with: - """pen - f = \() [number] { - [number 1, 2] - } - """ + """pen + f = \() [number] { + [number 1, 2] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Join lists Given a file named "Foo.pen" with: - """pen - f = \(xs [number]) [number] { - [number ...xs, ...xs] - } - """ + """pen + f = \(xs [number]) [number] { + [number ...xs, ...xs] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Create a list of a union type Given a file named "Foo.pen" with: - """pen - f = \() [number | none] { - [number | none 1, none] - } - """ + """pen + f = \() [number | none] { + [number | none 1, none] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Coerce elements of a spread list Given a file named "Foo.pen" with: - """pen - f = \(xs [number]) [number | none] { - [number | none ...xs] - } - """ + """pen + f = \(xs [number]) [number | none] { + [number | none ...xs] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use if-list expression Given a file named "Foo.pen" with: - """pen - f = \(xs [number]) [number] { - if [y, ...ys] = xs { - [number y(), ...ys] - } else { - [number] + """pen + f = \(xs [number]) [number] { + if [y, ...ys] = xs { + [number y(), ...ys] + } else { + [number] + } } - } - """ + """ When I run `pen build` Then the exit status should be 0 Scenario: Use list comprehension Given a file named "Foo.pen" with: - """pen - f = \(xs [number]) [number] { - [number x() + 42 for x in xs] - } - """ + """pen + f = \(xs [number]) [number] { + [number x() + 42 for x in xs] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Permutate lists Given a file named "Foo.pen" with: - """pen - f = \(xs [number], ys [number]) [number] { - [number x() + y() for x in xs for y in ys] - } - """ + """pen + f = \(xs [number], ys [number]) [number] { + [number x() + y() for x in xs for y in ys] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Flatten a list Given a file named "Foo.pen" with: - """pen - f = \(xs [[number]]) [number] { - [number y() for y in x() for x in xs] - } - """ + """pen + f = \(xs [[number]]) [number] { + [number y() for y in x() for x in xs] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Filter a list Given a file named "Foo.pen" with: - """pen - f = \(xs [number]) [number] { - [number x() for x in xs if x() < 42] - } - """ + """pen + f = \(xs [number]) [number] { + [number x() for x in xs if x() < 42] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Zip lists Given a file named "Foo.pen" with: - """pen - f = \(xs [number], ys [number]) [number] { - [number x() + y() for x, y in xs, ys] - } - """ + """pen + f = \(xs [number], ys [number]) [number] { + [number x() + y() for x, y in xs, ys] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Get a size of a list Given a file named "Foo.pen" with: - """pen - f = \(xs [none]) number { - size(xs) - } - """ + """pen + f = \(xs [none]) number { + size(xs) + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/map.feature b/features/types/map.feature index 7301be9448..7fb940e727 100644 --- a/features/types/map.feature +++ b/features/types/map.feature @@ -1,133 +1,133 @@ Feature: Map Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Create an empty map Given a file named "Foo.pen" with: - """pen - f = \() {string: number} { - {string: number} - } - """ + """pen + f = \() {string: number} { + {string: number} + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Create a map with an entry Given a file named "Foo.pen" with: - """pen - f = \() {string: number} { - {string: number "foo": 42} - } - """ + """pen + f = \() {string: number} { + {string: number "foo": 42} + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Create a map with two elements Given a file named "Foo.pen" with: - """pen - f = \() {string: number} { - {string: number "foo": 1, "bar": 2} - } - """ + """pen + f = \() {string: number} { + {string: number "foo": 1, "bar": 2} + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Get a value in a map Given a file named "Foo.pen" with: - """pen - f = \(xs {string: number}) number { - if x = xs["foo"] { - x - } else { - 0 + """pen + f = \(xs {string: number}) number { + if x = xs["foo"] { + x + } else { + 0 + } } - } - """ + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Merge maps Given a file named "Foo.pen" with: - """pen - f = \(xs {string: number}) {string: number} { - {string: number ...xs, ...xs} - } - """ + """pen + f = \(xs {string: number}) {string: number} { + {string: number ...xs, ...xs} + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Merge a map of different types Given a file named "Foo.pen" with: - """pen - f = \(xs {string: number}) {string | none: number | none} { - {string | none: number | none ...xs} - } - """ + """pen + f = \(xs {string: number}) {string | none: number | none} { + {string | none: number | none ...xs} + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Create a map of a union type key Given a file named "Foo.pen" with: - """pen - f = \() {string|none:number} { - {string|none:number "foo": 1, none: 2} - } - """ + """pen + f = \() {string|none:number} { + {string|none:number "foo": 1, none: 2} + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Create a map of a union type value Given a file named "Foo.pen" with: - """pen - f = \() {string: number | none} { - {string: number | none "foo": 42, "bar": none} - } - """ + """pen + f = \() {string: number | none} { + {string: number | none "foo": 42, "bar": none} + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Iterate map keys Given a file named "Foo.pen" with: - """pen - f = \(xs {string: number}) [string] { - keys(xs) - } - """ + """pen + f = \(xs {string: number}) [string] { + keys(xs) + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Iterate map values Given a file named "Foo.pen" with: - """pen - f = \(xs {string: number}) [number] { - values(xs) - } - """ + """pen + f = \(xs {string: number}) [number] { + values(xs) + } + """ When I successfully run `pen build` Then the exit status should be 0 Scenario: Get a size of a map Given a file named "Foo.pen" with: - """pen - f = \(xs {string: number}) number { - size(xs) - } - """ + """pen + f = \(xs {string: number}) number { + size(xs) + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Delete an entry of a map Given a file named "Foo.pen" with: - """pen - f = \(xs {string: number}) {string: number} { - delete(xs, "foo") - } - """ + """pen + f = \(xs {string: number}) {string: number} { + delete(xs, "foo") + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/none.feature b/features/types/none.feature index 31f52dfe2f..d23de4c5dc 100644 --- a/features/types/none.feature +++ b/features/types/none.feature @@ -1,19 +1,19 @@ Feature: None Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Use a none literal Given a file named "Foo.pen" with: - """pen - f = \() none { - none - } - """ + """pen + f = \() none { + none + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/number.feature b/features/types/number.feature index bb518d8d73..1171d98dc2 100644 --- a/features/types/number.feature +++ b/features/types/number.feature @@ -1,65 +1,65 @@ Feature: Number Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Use a number literal Given a file named "Foo.pen" with: - """pen - f = \() number { - 42 - } - """ + """pen + f = \() number { + 42 + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use arithmetic operators Given a file named "Foo.pen" with: - """pen - f = \() number { - 1 + 2 - 3 * 4 / 5 - } - """ + """pen + f = \() number { + 1 + 2 - 3 * 4 / 5 + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use equality operators Given a file named "Foo.pen" with: - """pen - f = \() boolean { - 0 == 0 - } + """pen + f = \() boolean { + 0 == 0 + } - g = \() boolean { - 0 != 0 - } - """ + g = \() boolean { + 0 != 0 + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use order operators Given a file named "Foo.pen" with: - """pen - f = \() boolean { - 0 < 0 - } + """pen + f = \() boolean { + 0 < 0 + } - g = \() boolean { - 0 <= 0 - } + g = \() boolean { + 0 <= 0 + } - h = \() boolean { - 0 > 0 - } + h = \() boolean { + 0 > 0 + } - i = \() boolean { - 0 >= 0 - } - """ + i = \() boolean { + 0 >= 0 + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/polymorphism.feature b/features/types/polymorphism.feature index 585db03eff..37e4bba10a 100644 --- a/features/types/polymorphism.feature +++ b/features/types/polymorphism.feature @@ -1,49 +1,49 @@ Feature: Polymorphism Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Use an equal operator Given a file named "Foo.pen" with: - """pen - f = \(x number | none) boolean { - x == none - } - """ + """pen + f = \(x number | none) boolean { + x == none + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use a not-equal operator Given a file named "Foo.pen" with: - """pen - f = \(x number | none) boolean { - x != none - } - """ + """pen + f = \(x number | none) boolean { + x != none + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Compare unions Given a file named "Foo.pen" with: - """pen - f = \(x number | none, y number | none) boolean { - x == y - } - """ + """pen + f = \(x number | none, y number | none) boolean { + x == y + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Compare a union and none Given a file named "Foo.pen" with: - """pen - f = \(x number | none) boolean { - x == none - } - """ + """pen + f = \(x number | none) boolean { + x == none + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/record.feature b/features/types/record.feature index d46251fe97..08c95bb0c1 100644 --- a/features/types/record.feature +++ b/features/types/record.feature @@ -1,133 +1,133 @@ Feature: Record Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Create a record with a field Given a file named "Foo.pen" with: - """pen - type r { - x number - } - - f = \() r { - r{x: 42} - } - """ + """pen + type r { + x number + } + + f = \() r { + r{x: 42} + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Create a record with two fields Given a file named "Foo.pen" with: - """pen - type r { - x number - y none - } - - f = \() r { - r{x: 42, y: none} - } - """ + """pen + 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 Scenario: Create a record with no field Given a file named "Foo.pen" with: - """pen - type r {} + """pen + type r {} - f = \() r { - r{} - } - """ + f = \() r { + r{} + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Update a record Given a file named "Foo.pen" with: - """pen - type r { - x number - y none - } - - f = \(x r) r { - r{...x, y: none} - } - """ + """pen + 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 Scenario: Get a field in a record Given a file named "Foo.pen" with: - """pen - type r { - x number - } - - f = \(x r) number { - x.x - } - """ + """pen + type r { + x number + } + + f = \(x r) number { + x.x + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use an equal operator Given a file named "Foo.pen" with: - """pen - type r { - x number - } - - f = \(x r, y r) boolean { - x == y - } - """ + """pen + type r { + x number + } + + f = \(x r, y r) boolean { + x == y + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use a not-equal operator Given a file named "Foo.pen" with: - """pen - type r { - x number - } - - f = \(x r, y r) boolean { - x == y - } - """ + """pen + type r { + x number + } + + f = \(x r, y r) boolean { + x == y + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Propagate openness of a record Given a file named "Foo.pen" with: - """pen - type Foo { - X number - } - """ + """pen + type Foo { + X number + } + """ And a file named "Bar.pen" with: - """pen - import 'Foo + """pen + import 'Foo - Bar = \() Foo'Foo { - Foo'Foo{X: 42} - } - """ + Bar = \() Foo'Foo { + Foo'Foo{X: 42} + } + """ And a file named "Baz.pen" with: - """pen - import 'Bar + """pen + import 'Bar - f = \() number { - Bar'Bar().X - } - """ + f = \() number { + Bar'Bar().X + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/stream.feature b/features/types/stream.feature index 3079187ce0..77f19ae530 100644 --- a/features/types/stream.feature +++ b/features/types/stream.feature @@ -1,111 +1,111 @@ Feature: List as stream Background: Given a file named "pen.json" with: - """json - { - "type": "application", - "dependencies": { - "Os": "pen:///os" + """json + { + "type": "application", + "dependencies": { + "Os": "pen:///os" + } } - } - """ + """ And a file named "Hello.pen" with: - """pen - import Os'Context { Context } - import Os'File + """pen + import Os'Context { Context } + import Os'File - Hello = \(ctx Context) none { - _ = File'Write(ctx, File'StdOut(), "hello") + Hello = \(ctx Context) none { + _ = File'Write(ctx, File'StdOut(), "hello") - none - } - """ + none + } + """ Scenario: Evaluate an element lazily Given a file named "main.pen" with: - """pen - import 'Hello + """pen + import 'Hello - main = \(ctx context) none { - [none Hello'Hello(ctx.Os)] + main = \(ctx context) none { + [none Hello'Hello(ctx.Os)] - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should not contain "hello" Scenario: Evaluate an element lazily but only once Given a file named "main.pen" with: - """pen - import Os'Process - import 'Hello + """pen + import Os'Process + import 'Hello - main = \(ctx context) none { - if [x, ...xs] = [none Hello'Hello(ctx.Os)] { - x() - x() + main = \(ctx context) none { + if [x, ...xs] = [none Hello'Hello(ctx.Os)] { + x() + x() - none - } else { - Process'Exit(ctx.Os, 1) + none + } else { + Process'Exit(ctx.Os, 1) + } } - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should contain exactly "hello" Scenario: Evaluate multiple elements lazily Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import 'Hello + """pen + import Os'Context { Context } + import 'Hello - foo = \(ctx Context) [none] { - Hello'Hello(ctx) + foo = \(ctx Context) [none] { + Hello'Hello(ctx) - [none] - } + [none] + } - main = \(ctx context) none { - [none ...foo(ctx.Os)] + main = \(ctx context) none { + [none ...foo(ctx.Os)] - none - } - """ + none + } + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should not contain "hello" Scenario: Evaluate multiple elements lazily but only once Given a file named "main.pen" with: - """pen - import Os'Context { Context } - import Os'Process - import 'Hello + """pen + import Os'Context { Context } + import Os'Process + import 'Hello - foo = \(ctx Context) [none] { - Hello'Hello(ctx) + foo = \(ctx Context) [none] { + Hello'Hello(ctx) - [none] - } + [none] + } - main = \(ctx context) none { - xs = [none ...foo(ctx.Os)] + main = \(ctx context) none { + xs = [none ...foo(ctx.Os)] - if [x, ...xs] = xs { - Process'Exit(ctx.Os, 1) - } else { if [x, ...xs] = xs { Process'Exit(ctx.Os, 1) } else { - none + if [x, ...xs] = xs { + Process'Exit(ctx.Os, 1) + } else { + none + } } } - } - """ + """ When I successfully run `pen build` Then I successfully run `./app` And the stdout from "./app" should contain exactly "hello" diff --git a/features/types/string.feature b/features/types/string.feature index 02d4a9bb96..f31fb1a020 100644 --- a/features/types/string.feature +++ b/features/types/string.feature @@ -1,53 +1,53 @@ Feature: String Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Use a string literal Given a file named "Foo.pen" with: - """pen - f = \() string { - "foo" - } - """ + """pen + f = \() string { + "foo" + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Use equality operators Given a file named "Foo.pen" with: - """pen - f = \() boolean { - "" == "" - } + """pen + f = \() boolean { + "" == "" + } - g = \() boolean { - "" != "" - } - """ + g = \() boolean { + "" != "" + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Concatenate strings Given a file named "Foo.pen" with: - """pen - f = \() string { - "foo" + "bar" - } - """ + """pen + f = \() string { + "foo" + "bar" + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Concatenate 3 strings Given a file named "Foo.pen" with: - """pen - f = \() string { - "foo" + "bar" + "baz" - } - """ + """pen + f = \() string { + "foo" + "bar" + "baz" + } + """ When I run `pen build` Then the exit status should be 0 diff --git a/features/types/union.feature b/features/types/union.feature index b73e8bf05c..8c12d308fa 100644 --- a/features/types/union.feature +++ b/features/types/union.feature @@ -1,83 +1,83 @@ Feature: Union Background: Given a file named "pen.json" with: - """json - { - "type": "library", - "dependencies": {} - } - """ + """json + { + "type": "library", + "dependencies": {} + } + """ Scenario: Upcast a number into a union Given a file named "Foo.pen" with: - """pen - f = \() number | none { - 42 - } - """ + """pen + f = \() number | none { + 42 + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Upcast a function into a union Given a file named "Foo.pen" with: - """pen - f = \() (\() number) | none { - \() number { - 42 + """pen + f = \() (\() number) | none { + \() number { + 42 + } } - } - """ + """ When I run `pen build` Then the exit status should be 0 Scenario: Upcast a list into a union Given a file named "Foo.pen" with: - """pen - f = \() [number] | none { - [number 42] - } - """ + """pen + f = \() [number] | none { + [number 42] + } + """ When I run `pen build` Then the exit status should be 0 Scenario: Downcast a union type Given a file named "Foo.pen" with: - """pen - f = \(x number | none) number { - if x = x as number { - x - } else if none { - 0 + """pen + f = \(x number | none) number { + if x = x as number { + x + } else if none { + 0 + } } - } - """ + """ When I run `pen build` Then the exit status should be 0 Scenario: Downcast a union type with an else block Given a file named "Foo.pen" with: - """pen - f = \(x number | none) number { - if x = x as none { - 0 - } else { - x + """pen + f = \(x number | none) number { + if x = x as none { + 0 + } else { + x + } } - } - """ + """ When I run `pen build` Then the exit status should be 0 Scenario: Downcast a union type to another union type Given a file named "Foo.pen" with: - """pen - f = \(x number | boolean | none) number | none { - if x = x as number | none { - x - } else { - none + """pen + f = \(x number | boolean | none) number | none { + if x = x as number | none { + x + } else { + none + } } - } - """ + """ When I run `pen build` Then the exit status should be 0