Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ jobs:
- name: Run phel tests
run: composer test

- name: Mutation tests
run: composer mutate

- name: Build standalone binary
run: composer build

Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help install d dev t test f format fc c check ci w watch nc new-command b build export r repl doctor clean
.PHONY: help install d dev t test f format fc c check ci mu mutate w watch nc new-command b build export r repl doctor clean

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-10s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -29,9 +29,13 @@ c: check
check: ## fast pre-commit gate: format-check + lint + test
composer check

ci: ## full CI gate: format-check + lint + test + build
ci: ## full CI gate: format-check + lint + test + mutate + build + export
composer ci

mu: mutate
mutate: ## mutation-test the pure core (fails below 90% MSI)
composer mutate

b: build
build: ## build standalone PHP binary -> out/main.php
composer build
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Every task is both a `make <target>` (with short aliases) and a
| Watch (reload on save) | `composer watch` |
| REPL | `composer repl` |
| Local gate (format+lint+test) | `composer check` |
| Mutation-test `core/` | `composer mutate` |
| Scaffold a command | `make new-command NAME=foo` |

```bash
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"format-check": "vendor/bin/phel format --dry-run",
"lint": "vendor/bin/phel lint src tests",
"test": "vendor/bin/phel test",
"mutate": "vendor/bin/phel mutate src/core --min-msi=90 --parallel=auto",
"watch": "vendor/bin/phel watch src tests",
"doctor": "vendor/bin/phel doctor",
"check": [
Expand All @@ -47,6 +48,7 @@
"@format-check",
"@lint",
"@test",
"@mutate",
"@build",
"@export"
],
Expand Down
3 changes: 2 additions & 1 deletion src/commands/adder.phel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns cli-skeleton.commands.adder
(:require phel.cli :as cli)
(:require phel.string :as str)
(:require cli-skeleton.core.adder :refer [sum-tokens]))

;; COMMAND layer = IO boundary: parse args, print results. Math lives in core.
Expand All @@ -11,7 +12,7 @@
1)
(let [{:keys [total invalid overflow]} (sum-tokens tokens)]
(cond
invalid (do (cli/error ctx (str "Not an integer: " (php/implode ", " (to-php-array invalid))))
invalid (do (cli/error ctx (str "Not an integer: " (str/join ", " invalid)))
1)
overflow (do (cli/error ctx "Sum is too large for an integer.")
1)
Expand Down
3 changes: 2 additions & 1 deletion src/core/adder.phel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
(defn parse-int
"Parse a string as a strict integer. Returns nil for anything else:
floats, text, empty input, or a value outside the PHP integer range. Pure."
;; Not `parse-long`: it clamps an out-of-range value to the maximum integer.
[s]
(php/filter_var s php/FILTER_VALIDATE_INT php/FILTER_NULL_ON_FAILURE))

Expand All @@ -24,6 +25,6 @@
(if (seq invalid)
{:invalid (vec invalid)}
(let [total (apply adder parsed)]
(if (php/is_int total)
(if (int? total)
{:total total}
{:overflow true})))))
Loading