Nock extended tests: nock-2,6,7,8,9 + fix nock-9#22
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nock-9implementation intests/nock.fs:R> make-atomerroneously wrapped an existing noun address in a newmake-atomcall (creating atom-with-value=address rather than reusing the noun); fixed toR>alonemake-cellbefore finaltar— nock-9 was callingtarwith two items on the stack (formulaandcore) instead of one combined[core formula]noun*[42 [2 [0 1] [1 [4 [0 1]]]]]= 43 (evaluate with computed subject/formula)*[42 [6 [1 0] [4 [0 1]] [1 99]]]= 43*[42 [6 [1 1] [4 [0 1]] [1 99]]]= 99*[42 [7 [4 [0 1]] [4 [0 1]]]]= 44 (compose: increment twice)*[42 [8 [4 [0 1]] [0 2]]]= 43 (push: extend subject, slot result)*[0 [9 2 [1 [[4 [0 3]] 42]]]]= 43 (invoke arm at slot 2 of core)Test plan
bash tests/test-nock.sh)🤖 Generated with Claude Code