Skip to content

Commit

Permalink
add nph formatting linter
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Aug 14, 2024
1 parent 0313bce commit ee0f018
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,22 @@ jobs:
env TEST_LANG="c" nimble test
env TEST_LANG="cpp" nimble test
lint:
name: "Check formatting"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base

- name: Check nph formatting
# Pin nph to a specific version to avoid sudden style differences.
run: |
VERSION="v0.6.0"
ARCHIVE="nph-linux_x64.tar.gz"
curl -L "https://github.com/arnetheduck/nph/releases/download/${VERSION}/${ARCHIVE}" -o ${ARCHIVE}
tar -xzf ${ARCHIVE}
./nph
git diff --exit-code
15 changes: 7 additions & 8 deletions results.nimble
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Package

version = "0.4.0"
author = "Jacek Sieka"
description = "Friendly, exception-free value-or-error returns, similar to Option[T]"
license = "MIT"
skipDirs = @["benchmarks", "tests"]
installFiles = @["results.nim"]
version = "0.4.0"
author = "Jacek Sieka"
description = "Friendly, exception-free value-or-error returns, similar to Option[T]"
license = "MIT"
skipDirs = @["benchmarks", "tests"]
installFiles = @["results.nim"]
# Dependencies

requires "nim >= 1.2"
Expand All @@ -15,8 +15,7 @@ proc test(env, path: string) =
var lang = "c"
if existsEnv"TEST_LANG":
lang = getEnv"TEST_LANG"
exec "nim " & lang & " " & env &
" -r " & path
exec "nim " & lang & " " & env & " -r " & path

task test, "Runs the test suite":
for f in ["test_results.nim", "test_results2.nim"]:
Expand Down
8 changes: 5 additions & 3 deletions tests/test_results.nim
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ block: # Result[T, void] aka `Opt`
$x
)
.get() == $oOk.get()

oOk
.map(
proc(x: int) =
Expand Down Expand Up @@ -593,10 +594,11 @@ block: # Result[T, void] aka `Opt`
doAssert oOk.value() + 1 notin oOk

block: # Nested `?`
proc inside: Opt[int] =
proc inside(): Opt[int] =
ok(5)
proc kput: Opt[int] =
ok(? inside())

proc kput(): Opt[int] =
ok(?inside())

doAssert kput() == Opt.some(5)

Expand Down

0 comments on commit ee0f018

Please sign in to comment.