From e1f080a0bb6c1f8872e6a3da72329bedc4f674ea Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Fri, 15 Nov 2024 16:14:11 +0800 Subject: [PATCH] move example code to examples --- README.md | 10 +++++----- docs/articles/programming-with-interaction-nets.md | 10 +++++----- ...345\272\224\347\275\221\347\274\226\347\250\213.md" | 10 +++++----- package.json | 4 ++-- src/command-line/commands/Run.ts | 4 ++-- tests/module/circular-import-1.error.i.err | 4 ++-- tests/module/circular-import-2.error.i.err | 4 ++-- tests/module/circular-import-3.error.i.err | 4 ++-- tests/module/circular-require-1.error.i.err | 4 ++-- tests/module/circular-require-2.error.i.err | 4 ++-- tests/module/circular-require-3.error.i.err | 4 ++-- tests/module/define-rule-for-non-own-node.error.i.err | 6 +++--- tests/module/self-import.error.i.err | 4 ++-- tests/module/self-require.error.i.err | 4 ++-- 14 files changed, 38 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index b506ce37..57fd2229 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ inet-cute help [name] # Display help for a command ## Examples -Please see [tests/](./tests) for some example code. +Please see [examples/](./tests) for some example code. ### Nat @@ -116,7 +116,7 @@ rule cons append result-(append) end -import zero from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.i" +import zero from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.i" null zero cons zero cons null zero cons zero cons @@ -130,7 +130,7 @@ append @run $result ### DiffList ```inet -import List from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/List.i" +import List from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/List.i" // Concatenation of lists is performed in linear time // with respect to its first argument. @@ -172,8 +172,8 @@ rule diff diffOpen (diff)-front oldBack-(diffOpen) end -import zero from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.i" -import cons from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/List.i" +import zero from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.i" +import cons from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/List.i" (diff) @spread $front $back $value back zero cons zero cons front @connect value diff --git a/docs/articles/programming-with-interaction-nets.md b/docs/articles/programming-with-interaction-nets.md index 3e6ff1e8..b28d8bd3 100644 --- a/docs/articles/programming-with-interaction-nets.md +++ b/docs/articles/programming-with-interaction-nets.md @@ -779,7 +779,7 @@ to a local variable named `local`. import Nat, zero, add1, add, one, two, three, -from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.i" +from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.i" node natErase Nat :target! @@ -892,7 +892,7 @@ rule cons append result-(append) end -import zero from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.i" +import zero from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.i" null zero cons zero cons null zero cons zero cons @@ -937,7 +937,7 @@ in reverse order of the definition, then we save the ports to local variables for later use. ``` -import List from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/List.i" +import List from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/List.i" type DiffList @Type -- @Type end @@ -972,8 +972,8 @@ rule diff diffOpen (diff)-front oldBack-(diffOpen) end -import zero from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.i" -import cons from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/List.i" +import zero from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.i" +import cons from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/List.i" (diff) @spread $front $back $value back zero cons zero cons front @connect value diff --git "a/docs/articles/\345\217\215\345\272\224\347\275\221\347\274\226\347\250\213.md" "b/docs/articles/\345\217\215\345\272\224\347\275\221\347\274\226\347\250\213.md" index 468dcde2..e8a11920 100644 --- "a/docs/articles/\345\217\215\345\272\224\347\275\221\347\274\226\347\250\213.md" +++ "b/docs/articles/\345\217\215\345\272\224\347\275\221\347\274\226\347\250\213.md" @@ -750,7 +750,7 @@ three two max import Nat, zero, add1, add, one, two, three, -from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.i" +from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.i" node natErase Nat :target! @@ -861,7 +861,7 @@ rule cons append result-(append) end -import zero from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.i" +import zero from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.i" null zero cons zero cons null zero cons zero cons @@ -900,7 +900,7 @@ append @run $result 然后我们把这些接口保存到了一些局部变量中。 ``` -import List from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/List.i" +import List from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/List.i" type DiffList @Type -- @Type end @@ -935,8 +935,8 @@ rule diff diffOpen (diff)-front oldBack-(diffOpen) end -import zero from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.i" -import cons from "https://code-of-inet-cute.xieyuheng.com/tests/datatype/List.i" +import zero from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.i" +import cons from "https://code-of-inet-cute.xieyuheng.com/examples/datatype/List.i" (diff) @spread $front $back $value back zero cons zero cons front @connect value diff --git a/package.json b/package.json index 8a50ab0f..77f16131 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "build": "tsc", "build:watch": "tsc --watch", "test:ts": "vitest --dir src --run", - "test:inet": "test-runner snapshot 'node ./bin/inet-cute.js run --no-color' 'tests/**/*.i' --exclude 'tests/**/*.error.i'", - "test:inet-error": "test-runner snapshot-error 'node ./bin/inet-cute.js run --no-color' 'tests/**/*.error.i'", + "test:inet": "test-runner snapshot 'node ./bin/inet-cute.js run --no-color' 'examples/**/*.i' --exclude 'examples/**/*.error.i'", + "test:inet-error": "test-runner snapshot-error 'node ./bin/inet-cute.js run --no-color' 'examples/**/*.error.i'", "test": "npm run test:ts && npm run test:inet && npm run test:inet-error", "format": "prettier src docs --write" }, diff --git a/src/command-line/commands/Run.ts b/src/command-line/commands/Run.ts index b93c2d52..bb8a3172 100644 --- a/src/command-line/commands/Run.ts +++ b/src/command-line/commands/Run.ts @@ -26,11 +26,11 @@ export class Run extends Command { return [ `Run a file:`, ``, - blue(` ${runner.name} ${this.name} tests/datatype/Nat.test.i`), + blue(` ${runner.name} ${this.name} examples/datatype/Nat.test.i`), ``, `Run a URL:`, ``, - blue(` ${runner.name} ${this.name} https://code-of-inet-cute.xieyuheng.com/tests/datatype/Nat.test.i`), + blue(` ${runner.name} ${this.name} https://code-of-inet-cute.xieyuheng.com/examples/datatype/Nat.test.i`), ``, ].join("\n") diff --git a/tests/module/circular-import-1.error.i.err b/tests/module/circular-import-1.error.i.err index da6a0c08..71797acf 100644 --- a/tests/module/circular-import-1.error.i.err +++ b/tests/module/circular-import-1.error.i.err @@ -1,7 +1,7 @@ [Import.execute] I can not do circular import. - loading module url: tests/module/circular-import-3.error.i - requiring module url: tests/module/circular-import-1.error.i + loading module url: examples/module/circular-import-3.error.i + requiring module url: examples/module/circular-import-1.error.i [Import.execute] I fail to import module. diff --git a/tests/module/circular-import-2.error.i.err b/tests/module/circular-import-2.error.i.err index 2c814b5f..2b74127f 100644 --- a/tests/module/circular-import-2.error.i.err +++ b/tests/module/circular-import-2.error.i.err @@ -1,7 +1,7 @@ [Import.execute] I can not do circular import. - loading module url: tests/module/circular-import-1.error.i - requiring module url: tests/module/circular-import-2.error.i + loading module url: examples/module/circular-import-1.error.i + requiring module url: examples/module/circular-import-2.error.i [Import.execute] I fail to import module. diff --git a/tests/module/circular-import-3.error.i.err b/tests/module/circular-import-3.error.i.err index cd2f221e..7fe9ff31 100644 --- a/tests/module/circular-import-3.error.i.err +++ b/tests/module/circular-import-3.error.i.err @@ -1,7 +1,7 @@ [Import.execute] I can not do circular import. - loading module url: tests/module/circular-import-2.error.i - requiring module url: tests/module/circular-import-3.error.i + loading module url: examples/module/circular-import-2.error.i + requiring module url: examples/module/circular-import-3.error.i [Import.execute] I fail to import module. diff --git a/tests/module/circular-require-1.error.i.err b/tests/module/circular-require-1.error.i.err index ed0609fd..230a331f 100644 --- a/tests/module/circular-require-1.error.i.err +++ b/tests/module/circular-require-1.error.i.err @@ -1,7 +1,7 @@ [Require.execute] I can not do circular require. - loading module url: tests/module/circular-require-3.error.i - requiring module url: tests/module/circular-require-1.error.i + loading module url: examples/module/circular-require-3.error.i + requiring module url: examples/module/circular-require-1.error.i [Require.execute] I fail to require module. diff --git a/tests/module/circular-require-2.error.i.err b/tests/module/circular-require-2.error.i.err index 7447f2b8..527cd669 100644 --- a/tests/module/circular-require-2.error.i.err +++ b/tests/module/circular-require-2.error.i.err @@ -1,7 +1,7 @@ [Require.execute] I can not do circular require. - loading module url: tests/module/circular-require-1.error.i - requiring module url: tests/module/circular-require-2.error.i + loading module url: examples/module/circular-require-1.error.i + requiring module url: examples/module/circular-require-2.error.i [Require.execute] I fail to require module. diff --git a/tests/module/circular-require-3.error.i.err b/tests/module/circular-require-3.error.i.err index dae1e234..99be9c37 100644 --- a/tests/module/circular-require-3.error.i.err +++ b/tests/module/circular-require-3.error.i.err @@ -1,7 +1,7 @@ [Require.execute] I can not do circular require. - loading module url: tests/module/circular-require-2.error.i - requiring module url: tests/module/circular-require-3.error.i + loading module url: examples/module/circular-require-2.error.i + requiring module url: examples/module/circular-require-3.error.i [Require.execute] I fail to require module. diff --git a/tests/module/define-rule-for-non-own-node.error.i.err b/tests/module/define-rule-for-non-own-node.error.i.err index 153ee45b..2e098833 100644 --- a/tests/module/define-rule-for-non-own-node.error.i.err +++ b/tests/module/define-rule-for-non-own-node.error.i.err @@ -1,8 +1,8 @@ [checkRuleIsAboutOwnNode] To define a rule, one of the node must be owned by this module. - loading module url: tests/module/define-rule-for-non-own-node.error.i - first node module url: tests/datatype/Nat.i - second node module url: tests/datatype/Nat.i + loading module url: examples/module/define-rule-for-non-own-node.error.i + first node module url: examples/datatype/Nat.i + second node module url: examples/datatype/Nat.i [DefineRule.execute] I fail to define rule. diff --git a/tests/module/self-import.error.i.err b/tests/module/self-import.error.i.err index e6de7467..c96ec6ff 100644 --- a/tests/module/self-import.error.i.err +++ b/tests/module/self-import.error.i.err @@ -1,7 +1,7 @@ [Import.execute] I can not do circular import. - loading module url: tests/module/self-import.error.i - requiring module url: tests/module/self-import.error.i + loading module url: examples/module/self-import.error.i + requiring module url: examples/module/self-import.error.i [Import.execute] I fail to import module. diff --git a/tests/module/self-require.error.i.err b/tests/module/self-require.error.i.err index 93a5a644..f73d80d9 100644 --- a/tests/module/self-require.error.i.err +++ b/tests/module/self-require.error.i.err @@ -1,7 +1,7 @@ [Require.execute] I can not do circular require. - loading module url: tests/module/self-require.error.i - requiring module url: tests/module/self-require.error.i + loading module url: examples/module/self-require.error.i + requiring module url: examples/module/self-require.error.i [Require.execute] I fail to require module.