Skip to content

Nock extended tests: nock-2,6,7,8,9 + fix nock-9#22

Merged
sigilante merged 6 commits intomasterfrom
sigilante/nock-extended-tests
Apr 13, 2026
Merged

Nock extended tests: nock-2,6,7,8,9 + fix nock-9#22
sigilante merged 6 commits intomasterfrom
sigilante/nock-extended-tests

Conversation

@sigilante
Copy link
Copy Markdown
Owner

Summary

  • Fix two bugs in nock-9 implementation in tests/nock.fs:
    1. R> make-atom erroneously wrapped an existing noun address in a new make-atom call (creating atom-with-value=address rather than reusing the noun); fixed to R> alone
    2. Missing make-cell before final tar — nock-9 was calling tar with two items on the stack (formula and core) instead of one combined [core formula] noun
  • Add 6 new reference tests covering all major Nock opcodes not previously tested:
    • nock-2: *[42 [2 [0 1] [1 [4 [0 1]]]]] = 43 (evaluate with computed subject/formula)
    • nock-6 true: *[42 [6 [1 0] [4 [0 1]] [1 99]]] = 43
    • nock-6 false: *[42 [6 [1 1] [4 [0 1]] [1 99]]] = 99
    • nock-7: *[42 [7 [4 [0 1]] [4 [0 1]]]] = 44 (compose: increment twice)
    • nock-8: *[42 [8 [4 [0 1]] [0 2]]] = 43 (push: extend subject, slot result)
    • nock-9: *[0 [9 2 [1 [[4 [0 3]] 42]]]] = 43 (invoke arm at slot 2 of core)

Test plan

  • All 30 Nock tests pass (bash tests/test-nock.sh)

🤖 Generated with Claude Code

sigilante and others added 6 commits April 12, 2026 13:20
Adds the words needed to run the nock.fs Nock interpreter:

- DEFER name: allocates an xt cell at HERE (default NOOP), defines an
  indirect word whose body is [addr @ EXECUTE]. Emits a %defer token.
- IS name: stores TOS xt into a deferred word's data cell. Reads the
  next token as the target word name, extracts its data address from
  the first %num in its body, and stores the new xt there.
- EXIT: immediately returns from the current word (sets ip=n in the
  eval loop), leaving the data stack unchanged.
- NOOP: no-op primitive, default xt for newly DEFERed words.
- -ROT: ( a b c -- c a b ) implemented as ROT ROT.
- CELL: pushes 1 (cell size in North).
- CHARS: identity, same as CELLS (cell size = 1).
- [CHAR] x: push ASCII value of first character of next token.

288 tests, 0 failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Port of https://github.com/mopfel-winrux/forth-nock/blob/main/nock.fs to
North Forth. Drops bigint (Hoon atoms are arbitrary precision). Uses
DEFER/IS for mutual recursion (tar/slot/tis/hax). All 24 nock tests pass:
noun construction, wut/lus/tis primitives, slot tree-addressing, and
nock-0 through nock-5 evaluation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix two bugs in nock-9:
- R> retrieved a noun address but make-atom wrapped it again, creating
  an atom with value=address instead of reusing the existing noun
- Missing make-cell to combine new-subject+formula into [subj fml]
  before the final tar call

Add 6 new reference tests covering all major Nock opcodes:
nock-2 (eval), nock-6 (if-then-else), nock-7 (compose),
nock-8 (push/extend-subject), nock-9 (core invocation).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Adds parse-noun-tok, parse-cell-items, build-noun-toks arms to ++parse
  in desk/lib/north.hoon so [ 42 99 ] emits 42 MAKE-ATOM 99 MAKE-ATOM
  MAKE-CELL at parse time (Option B — pure Forth parsing word — noted as
  future possibility)
- Rewrites test-nock.sh to use [ ] notation instead of verbose
  make-atom/make-cell chains; adds urbit/benchmark decrement cases

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove long-running urbit/benchmark decrement tests from test-nock.sh
  (each requires a full urbit eval + nock.fs load, O(minutes) per test)
- Add tests/test-nock-long.sh with dec 1/2/10/42 using corrected formula:
  condition [5 [0 7] [4 [0 6]]] (n == counter+1), not [0 6] (was infinite loop)
- Add Makefile: `make test` for fast CI, `make test-long` for benchmarks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Reverts [ ] noun literal dispatch from ++parse: [ is already a Forth
  compile-time word ([ ] LITERAL, Tier 14) so parser-level interception
  breaks existing CI. The three helper arms (parse-noun-tok,
  parse-cell-items, build-noun-toks) remain for a future Option B
  Forth parsing word in nock.fs.
- Adds nock-10 (hax edit, Nock 4K spec) and nock-11 (static and dynamic
  hint) test cases; all 34 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sigilante sigilante merged commit 1f121ea into master Apr 13, 2026
2 checks passed
@sigilante sigilante deleted the sigilante/nock-extended-tests branch April 13, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant