dirac-lang 0.1.24 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +13 -1
- package/lib/index.di +9 -0
- package/{examples/lib → lib}/math.di +3 -3
- package/package.json +13 -1
- package/.env.example +0 -8
- package/COMMUNITY.md +0 -465
- package/CONDITIONAL-TAGS.md +0 -172
- package/EXCEPTION-HANDLING.md +0 -156
- package/LIBRARIES.md +0 -172
- package/LLM-VALIDATION.md +0 -128
- package/NAMESPACES.md +0 -366
- package/PROMOTION.md +0 -257
- package/QUICKSTART-LIBRARY.md +0 -93
- package/TEST-COVERAGE.md +0 -113
- package/TESTING.md +0 -162
- package/config.test.yml +0 -5
- package/dirac-http/examples/demo.di +0 -9
- package/dirac-http/lib/index.di +0 -12
- package/examples/add-demo.di +0 -74
- package/examples/add.bk +0 -11
- package/examples/advanced-math-demo.di +0 -53
- package/examples/calculator.di +0 -32
- package/examples/compact-test.di +0 -6
- package/examples/comprehensive.bk +0 -29
- package/examples/defvar-variable-demo.di +0 -18
- package/examples/direct-call.di +0 -17
- package/examples/disk-analysis.di +0 -16
- package/examples/exception-demo.di +0 -82
- package/examples/executable-hello.di +0 -7
- package/examples/execute-demo.di +0 -38
- package/examples/file-manager.di +0 -77
- package/examples/file-stats.di +0 -18
- package/examples/hello.bk +0 -1
- package/examples/hello.di +0 -5
- package/examples/if-comparison.di +0 -91
- package/examples/if-cstyle-test.di +0 -149
- package/examples/if-vs-testif.di +0 -56
- package/examples/import-demo.di +0 -31
- package/examples/inline-test.bk +0 -7
- package/examples/llm-agent.di +0 -32
- package/examples/llm-basic.di +0 -12
- package/examples/llm-command-more.di +0 -6
- package/examples/llm-command-no-exec.di +0 -13
- package/examples/llm-command.di +0 -6
- package/examples/llm-complex.di +0 -141
- package/examples/llm-feedback-debug.di +0 -30
- package/examples/llm-feedback-demo.di +0 -19
- package/examples/llm-feedback-math.di +0 -22
- package/examples/llm-feedback-simple.di +0 -16
- package/examples/llm-feedback-sub.di +0 -22
- package/examples/llm-no-feedback.di +0 -10
- package/examples/llm-recursive.di +0 -31
- package/examples/llm-reflection-test.di +0 -19
- package/examples/llm-simple-test.di +0 -12
- package/examples/llm-subs.di +0 -132
- package/examples/llm-use-subs.di +0 -6
- package/examples/llm-validate-test.di +0 -18
- package/examples/loop.di +0 -12
- package/examples/math-test.di +0 -22
- package/examples/minimal-test.di +0 -13
- package/examples/mongodb-context-test.di +0 -27
- package/examples/mongodb-count-events.di +0 -8
- package/examples/mongodb-import-demo.di +0 -25
- package/examples/mongodb-simple-test.di +0 -18
- package/examples/nl-agent.di +0 -47
- package/examples/parameters-demo.di +0 -68
- package/examples/params-meta-test.di +0 -17
- package/examples/params-test.di +0 -10
- package/examples/recipe-chain.di +0 -38
- package/examples/recursive-llm.di +0 -44
- package/examples/sample-library/README.md +0 -152
- package/examples/sample-library/examples/demo.di +0 -34
- package/examples/sample-library/lib/index.di +0 -65
- package/examples/sample-library/package.json +0 -31
- package/examples/scope-test-nested.di +0 -60
- package/examples/scope-test.di +0 -55
- package/examples/seamless.di +0 -45
- package/examples/shell-test.bk +0 -10
- package/examples/simple-import.di +0 -13
- package/examples/simple-recursive.di +0 -26
- package/examples/story-builder.di +0 -45
- package/examples/subroutine.di +0 -23
- package/examples/system-llm.di +0 -21
- package/examples/system-simple.di +0 -3
- package/examples/system-test.di +0 -8
- package/examples/tag-check-test.di +0 -139
- package/examples/task-assistant.di +0 -27
- package/examples/test-if-demo.di +0 -110
- package/examples/test-parameters.di +0 -50
- package/examples/try-catch-test.di +0 -118
- package/examples/two-styles.di +0 -28
- package/examples/var-debug.di +0 -6
- package/examples/var-inline.di +0 -4
- package/examples/var-test2.di +0 -6
- package/examples/variable-replace.di +0 -25
- package/examples/variable-simple.di +0 -16
- package/examples/variable-test.di +0 -22
- package/examples/whitespace-test.di +0 -24
- package/filePath +0 -1
- package/greeting.txt +0 -1
- package/src/cli.ts +0 -140
- package/src/index.ts +0 -33
- package/src/llm/ollama.ts +0 -58
- package/src/runtime/braket-parser.ts +0 -234
- package/src/runtime/interpreter.ts +0 -203
- package/src/runtime/parser.ts +0 -155
- package/src/runtime/session.ts +0 -325
- package/src/tags/assign.ts +0 -37
- package/src/tags/attr.ts +0 -64
- package/src/tags/available-subroutines.ts +0 -70
- package/src/tags/call.ts +0 -259
- package/src/tags/catch.ts +0 -24
- package/src/tags/defvar.ts +0 -115
- package/src/tags/environment.ts +0 -21
- package/src/tags/eval.ts +0 -71
- package/src/tags/exception.ts +0 -20
- package/src/tags/execute.ts +0 -52
- package/src/tags/expr.ts +0 -128
- package/src/tags/foreach.ts +0 -170
- package/src/tags/if.ts +0 -191
- package/src/tags/import.ts +0 -135
- package/src/tags/index.ts +0 -41
- package/src/tags/input.ts +0 -182
- package/src/tags/llm.ts +0 -415
- package/src/tags/loop.ts +0 -43
- package/src/tags/mongodb.ts +0 -70
- package/src/tags/output.ts +0 -53
- package/src/tags/parameters.ts +0 -81
- package/src/tags/require_module.ts +0 -19
- package/src/tags/subroutine.ts +0 -75
- package/src/tags/system.ts +0 -93
- package/src/tags/tag-check.ts +0 -176
- package/src/tags/test-if.ts +0 -112
- package/src/tags/throw.ts +0 -26
- package/src/tags/try.ts +0 -19
- package/src/tags/variable.ts +0 -25
- package/src/test-runner.ts +0 -300
- package/src/types/index.ts +0 -128
- package/src/utils/llm-adapter.ts +0 -113
- package/src/utils/tag-validator.ts +0 -231
- package/test-available-extends.di +0 -28
- package/test-available-simple.di +0 -12
- package/test-available-subroutines.di +0 -16
- package/test-call.di +0 -9
- package/test-extend-basic.di +0 -17
- package/test-extend-chain.di +0 -26
- package/test-extend-debug.di +0 -17
- package/test-extend-debug2.di +0 -15
- package/test-extend-person.di +0 -17
- package/test-extend-simple.di +0 -11
- package/test-extend-zhi.di +0 -23
- package/test-extend.di +0 -19
- package/test-extend2.di +0 -26
- package/test-extend3-fixed.di +0 -23
- package/test-extend3-trouble.di +0 -23
- package/test-extend3.di +0 -21
- package/test-factorial.di +0 -19
- package/test-input-debug.di +0 -19
- package/test-nested-debug.di +0 -7
- package/test-nested-debug2.di +0 -8
- package/test-no-extend.di +0 -16
- package/test-simple-call.di +0 -7
- package/test-simple.di +0 -6
- package/tests/README.md +0 -69
- package/tests/assign-basic.test.di +0 -7
- package/tests/assign-from-eval.test.di +0 -7
- package/tests/available-subroutines-foreach.test.di +0 -32
- package/tests/basic-output.test.di +0 -5
- package/tests/call-basic.test.di +0 -11
- package/tests/call-with-output.test.di +0 -10
- package/tests/comments-before-content.test.di +0 -6
- package/tests/defvar-multiple.test.di +0 -8
- package/tests/environment-basic.test.di +0 -22
- package/tests/environment-nonexistent.test.di +0 -5
- package/tests/environment-with-defvar.test.di +0 -15
- package/tests/eval-basic.test.di +0 -6
- package/tests/eval-with-variables.test.di +0 -8
- package/tests/exception-basic.test.di +0 -10
- package/tests/expr-basic.test.di +0 -11
- package/tests/extend-basic.test.di +0 -19
- package/tests/extend-inheritance-chain.test.di +0 -26
- package/tests/extend-multiple-nested.test.di +0 -24
- package/tests/extend-self.test.di +0 -19
- package/tests/extend-with-parameters.test.di +0 -14
- package/tests/generate-dirac.test.di +0 -22
- package/tests/if-conditional.test.di +0 -17
- package/tests/if-else.test.di +0 -11
- package/tests/if-with-variables.test.di +0 -8
- package/tests/import-basic.test.di +0 -6
- package/tests/input-file-all.test.di +0 -5
- package/tests/input-file-line.test.di +0 -15
- package/tests/input-file-loop.test.di +0 -12
- package/tests/input-stdin-all.test.di +0 -8
- package/tests/input-stdin-all.txt +0 -1
- package/tests/llm-validate.test.di +0 -17
- package/tests/loop-basic.test.di +0 -9
- package/tests/loop-nested.test.di +0 -10
- package/tests/loop-with-eval.test.di +0 -8
- package/tests/no-root-element.test.di +0 -6
- package/tests/output-file.test.di +0 -19
- package/tests/output-multiple.test.di +0 -9
- package/tests/parameters-basic.test.di +0 -6
- package/tests/require-module-basic.test.di +0 -7
- package/tests/subroutine-basic.test.di +0 -9
- package/tests/subroutine-multiple-params.test.di +0 -10
- package/tests/subroutine-nested-calls.test.di +0 -32
- package/tests/subroutine-sequential-calls.test.di +0 -36
- package/tests/system-background.test.di +0 -39
- package/tests/system-basic.test.di +0 -5
- package/tests/tag-check.test.di +0 -27
- package/tests/test-if-basic.test.di +0 -8
- package/tests/test-input.txt +0 -3
- package/tests/try-catch-basic.test.di +0 -10
- package/tests/try-catch-eval-error.test.di +0 -10
- package/tests/variable-basic.test.di +0 -6
- package/tests/variable-interpolation.test.di +0 -7
- package/tools/create-library.sh +0 -175
- package/tsconfig.json +0 -19
- /package/{examples/lib → lib}/advanced-math.di +0 -0
- /package/{examples/lib → lib}/fileops.di +0 -0
- /package/{examples/lib → lib}/mongodb.di +0 -0
package/tests/README.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# Dirac Test Suite
|
|
2
|
-
|
|
3
|
-
Comprehensive unit tests for all Dirac tags and features.
|
|
4
|
-
|
|
5
|
-
## Running Tests
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm test
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Test Coverage
|
|
12
|
-
|
|
13
|
-
### Core Tags
|
|
14
|
-
- ✅ `<output>` - Basic output, multiple outputs
|
|
15
|
-
- ✅ `<defvar>` - Variable definition, multiple variables
|
|
16
|
-
- ✅ `<variable>` - Variable interpolation
|
|
17
|
-
- ✅ `<assign>` - Basic assignment, assignment from eval
|
|
18
|
-
- ✅ `<eval>` - Basic eval, eval with variables
|
|
19
|
-
- ✅ `<expr>` - Basic expressions, string concatenation
|
|
20
|
-
|
|
21
|
-
### Control Flow
|
|
22
|
-
- ✅ `<if>` - Basic conditionals, with variables, else logic
|
|
23
|
-
- ✅ `<loop>` - Basic loops, nested loops, loops with eval
|
|
24
|
-
|
|
25
|
-
### Functions
|
|
26
|
-
- ✅ `<subroutine>` - Basic subroutines, multiple params, recursive
|
|
27
|
-
- ✅ `<call>` - Basic calls, calls with output
|
|
28
|
-
- ✅ `<import>` - Import external libraries
|
|
29
|
-
- ✅ `<parameters>` - Parameter definitions with defaults
|
|
30
|
-
|
|
31
|
-
### System Integration
|
|
32
|
-
- ✅ `<system>` - Basic system commands, output capture, trim
|
|
33
|
-
- ✅ `<require_module>` - Node.js module imports
|
|
34
|
-
|
|
35
|
-
### Error Handling
|
|
36
|
-
- ✅ `<try>` - Try blocks
|
|
37
|
-
- ✅ `<catch>` - Catch blocks, error variable
|
|
38
|
-
- ✅ `<throw>` - Throw custom errors
|
|
39
|
-
- ✅ `<exception>` - Exception handling
|
|
40
|
-
|
|
41
|
-
### Advanced (Need manual testing with LLM)
|
|
42
|
-
- ⚠️ `<llm>` - Requires LLM configuration
|
|
43
|
-
- ⚠️ `<execute>` - Requires LLM configuration
|
|
44
|
-
- ⚠️ `<mongodb>` - Requires MongoDB connection
|
|
45
|
-
|
|
46
|
-
## Test Format
|
|
47
|
-
|
|
48
|
-
Each test file follows this format:
|
|
49
|
-
|
|
50
|
-
```xml
|
|
51
|
-
<!-- TEST: test_name -->
|
|
52
|
-
<!-- EXPECT: expected output -->
|
|
53
|
-
<dirac>
|
|
54
|
-
<!-- Test code here -->
|
|
55
|
-
</dirac>
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Adding New Tests
|
|
59
|
-
|
|
60
|
-
1. Create a new `.test.di` file in `/tests`
|
|
61
|
-
2. Add TEST and EXPECT comments
|
|
62
|
-
3. Write your test
|
|
63
|
-
4. Run `npm test`
|
|
64
|
-
|
|
65
|
-
## Test Statistics
|
|
66
|
-
|
|
67
|
-
- **Total Tests**: 32
|
|
68
|
-
- **Tag Coverage**: 19/24 tags (79%)
|
|
69
|
-
- **Missing Coverage**: llm, execute, mongodb (require external services)
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!-- TEST: available-subroutines with foreach and attr -->
|
|
2
|
-
<!-- EXPECT: - show-subroutines:
|
|
3
|
-
- greet: Greets someone
|
|
4
|
-
- gender: Returns gender identity
|
|
5
|
-
- age: Returns the person age -->
|
|
6
|
-
<dirac>
|
|
7
|
-
<subroutine name="TestSuite">
|
|
8
|
-
<subroutine name="age" description="Returns the person age">
|
|
9
|
-
<output>42</output>
|
|
10
|
-
</subroutine>
|
|
11
|
-
|
|
12
|
-
<subroutine name="gender" description="Returns gender identity">
|
|
13
|
-
<output>Male</output>
|
|
14
|
-
</subroutine>
|
|
15
|
-
|
|
16
|
-
<subroutine name="greet" description="Greets someone">
|
|
17
|
-
<output>Hello!</output>
|
|
18
|
-
</subroutine>
|
|
19
|
-
|
|
20
|
-
<subroutine name="show-subroutines">
|
|
21
|
-
<defvar name="subs"><available-subroutines /></defvar>
|
|
22
|
-
<foreach from="$subs" as="sub" xpath="//subroutine">
|
|
23
|
-
<output>- <attr name="name" from="$sub" />: <attr name="description" from="$sub" />
|
|
24
|
-
</output>
|
|
25
|
-
</foreach>
|
|
26
|
-
</subroutine>
|
|
27
|
-
|
|
28
|
-
<show-subroutines />
|
|
29
|
-
</subroutine>
|
|
30
|
-
|
|
31
|
-
<TestSuite />
|
|
32
|
-
</dirac>
|
package/tests/call-basic.test.di
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<!-- TEST: call_basic -->
|
|
2
|
-
<!-- EXPECT: Square of 5 is: 25 -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<subroutine name="square" param-x="number">
|
|
5
|
-
<eval name="result">return parseInt(x) * parseInt(x);</eval>
|
|
6
|
-
<output><variable name="result" /></output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
|
|
9
|
-
<output>Square of 5 is: </output>
|
|
10
|
-
<call name="square" x="5" />
|
|
11
|
-
</dirac>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<!-- TEST: call_with_output -->
|
|
2
|
-
<!-- EXPECT: 100 -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<subroutine name="square" param-x="number">
|
|
5
|
-
<eval name="result">return parseInt(x) * parseInt(x);</eval>
|
|
6
|
-
<output><variable name="result" /></output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
|
|
9
|
-
<call name="square" x="10" />
|
|
10
|
-
</dirac>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<!-- TEST: defvar_multiple -->
|
|
2
|
-
<!-- EXPECT: a=1, b=2, c=3 -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<defvar name="a" value="1" />
|
|
5
|
-
<defvar name="b" value="2" />
|
|
6
|
-
<defvar name="c" value="3" />
|
|
7
|
-
<output>a=<variable name="a" />, b=<variable name="b" />, c=<variable name="c" /></output>
|
|
8
|
-
</dirac>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!-- TEST: environment_basic -->
|
|
2
|
-
<!-- EXPECT: HOME exists: true USER exists: true -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<defvar name="home"><environment name="HOME" /></defvar>
|
|
5
|
-
<defvar name="user"><environment name="USER" /></defvar>
|
|
6
|
-
|
|
7
|
-
<output>HOME exists: </output>
|
|
8
|
-
<test-if test="$home != ''">
|
|
9
|
-
<output>true</output>
|
|
10
|
-
</test-if>
|
|
11
|
-
<test-if test="$home == ''">
|
|
12
|
-
<output>false</output>
|
|
13
|
-
</test-if>
|
|
14
|
-
|
|
15
|
-
<output> USER exists: </output>
|
|
16
|
-
<test-if test="$user != ''">
|
|
17
|
-
<output>true</output>
|
|
18
|
-
</test-if>
|
|
19
|
-
<test-if test="$user == ''">
|
|
20
|
-
<output>false</output>
|
|
21
|
-
</test-if>
|
|
22
|
-
</dirac>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!-- TEST: environment_with_defvar -->
|
|
2
|
-
<!-- EXPECT: Path exists: true -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<defvar name="mypath">
|
|
5
|
-
<environment name="PATH" />
|
|
6
|
-
</defvar>
|
|
7
|
-
|
|
8
|
-
<output>Path exists: </output>
|
|
9
|
-
<test-if test="$mypath != ''">
|
|
10
|
-
<output>true</output>
|
|
11
|
-
</test-if>
|
|
12
|
-
<test-if test="$mypath == ''">
|
|
13
|
-
<output>false</output>
|
|
14
|
-
</test-if>
|
|
15
|
-
</dirac>
|
package/tests/eval-basic.test.di
DELETED
package/tests/expr-basic.test.di
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<!-- TEST: expr_basic -->
|
|
2
|
-
<!-- EXPECT: Result: 15 -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<defvar name="a" value="10" />
|
|
5
|
-
<defvar name="b" value="5" />
|
|
6
|
-
<output>Result: </output>
|
|
7
|
-
<expr eval="plus">
|
|
8
|
-
<arg><variable name="a" /></arg>
|
|
9
|
-
<arg><variable name="b" /></arg>
|
|
10
|
-
</expr>
|
|
11
|
-
</dirac>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<!-- TEST: extend_basic -->
|
|
2
|
-
<!-- EXPECT: In parent, calling: Child nested -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<subroutine name="parent">
|
|
5
|
-
<subroutine name="nested">
|
|
6
|
-
<output>Parent nested</output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
<output>In parent, calling: </output>
|
|
9
|
-
<call name="nested" />
|
|
10
|
-
</subroutine>
|
|
11
|
-
|
|
12
|
-
<subroutine name="child" extends="parent">
|
|
13
|
-
<subroutine name="nested">
|
|
14
|
-
<output>Child nested</output>
|
|
15
|
-
</subroutine>
|
|
16
|
-
</subroutine>
|
|
17
|
-
|
|
18
|
-
<call name="child" />
|
|
19
|
-
</dirac>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<!-- TEST: extend_inheritance_chain -->
|
|
2
|
-
<!-- EXPECT: A X C -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<subroutine name="data">
|
|
5
|
-
<subroutine name="field1">
|
|
6
|
-
<output>A</output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
<subroutine name="field2">
|
|
9
|
-
<output>B</output>
|
|
10
|
-
</subroutine>
|
|
11
|
-
<subroutine name="field3">
|
|
12
|
-
<output>C</output>
|
|
13
|
-
</subroutine>
|
|
14
|
-
<call name="field1" />
|
|
15
|
-
<call name="field2" />
|
|
16
|
-
<call name="field3" />
|
|
17
|
-
</subroutine>
|
|
18
|
-
|
|
19
|
-
<subroutine name="data" extends="data">
|
|
20
|
-
<subroutine name="field2">
|
|
21
|
-
<output>X</output>
|
|
22
|
-
</subroutine>
|
|
23
|
-
</subroutine>
|
|
24
|
-
|
|
25
|
-
<call name="data" />
|
|
26
|
-
</dirac>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<!-- TEST: extend_multiple_nested -->
|
|
2
|
-
<!-- EXPECT: 63 , M -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<subroutine name="base">
|
|
5
|
-
<subroutine name="age">
|
|
6
|
-
<output>60</output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
<subroutine name="gender">
|
|
9
|
-
<output>M</output>
|
|
10
|
-
</subroutine>
|
|
11
|
-
<parameters select="*" />
|
|
12
|
-
</subroutine>
|
|
13
|
-
|
|
14
|
-
<subroutine name="base" extends="base">
|
|
15
|
-
<subroutine name="age">
|
|
16
|
-
<output>63</output>
|
|
17
|
-
</subroutine>
|
|
18
|
-
<parameters select="*" />
|
|
19
|
-
</subroutine>
|
|
20
|
-
|
|
21
|
-
<base><age /></base>
|
|
22
|
-
<output>,</output>
|
|
23
|
-
<base><gender /></base>
|
|
24
|
-
</dirac>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<!-- TEST: extend_self -->
|
|
2
|
-
<!-- EXPECT: Age: 63 -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<subroutine name="person">
|
|
5
|
-
<subroutine name="age">
|
|
6
|
-
<output>60</output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
<output>Age: </output>
|
|
9
|
-
<call name="age" />
|
|
10
|
-
</subroutine>
|
|
11
|
-
|
|
12
|
-
<subroutine name="person" extends="person">
|
|
13
|
-
<subroutine name="age">
|
|
14
|
-
<output>63</output>
|
|
15
|
-
</subroutine>
|
|
16
|
-
</subroutine>
|
|
17
|
-
|
|
18
|
-
<call name="person" />
|
|
19
|
-
</dirac>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<!-- TEST: extend_with_parameters -->
|
|
2
|
-
<!-- EXPECT: Hello, World -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<subroutine name="greet" param-name="string:required">
|
|
5
|
-
<output>Hello, </output>
|
|
6
|
-
<output><variable name="name" /></output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
|
|
9
|
-
<subroutine name="greet" extends="greet" param-name="string:required">
|
|
10
|
-
<!-- Child body is not executed with extends, only nested subroutines override -->
|
|
11
|
-
</subroutine>
|
|
12
|
-
|
|
13
|
-
<greet name="World" />
|
|
14
|
-
</dirac>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!-- TEST: generate_and_execute_dirac -->
|
|
2
|
-
<!-- EXPECT: Generated file executed
|
|
3
|
-
Result: 42 -->
|
|
4
|
-
<dirac>
|
|
5
|
-
<!-- Define a DIRAC script as literal -->
|
|
6
|
-
<defvar name="generated_script" literal="true" trim="false">
|
|
7
|
-
<dirac>
|
|
8
|
-
<defvar name="value">42</defvar>
|
|
9
|
-
<output>Result: <variable name="value" /></output>
|
|
10
|
-
</dirac>
|
|
11
|
-
</defvar>
|
|
12
|
-
|
|
13
|
-
<!-- Write to file -->
|
|
14
|
-
<output file="temp-generated.di"><variable name="generated_script" /></output>
|
|
15
|
-
|
|
16
|
-
<!-- Execute the generated script -->
|
|
17
|
-
<output>Generated file executed</output>
|
|
18
|
-
<system shell="bash">
|
|
19
|
-
node dist/cli.js temp-generated.di
|
|
20
|
-
rm temp-generated.di
|
|
21
|
-
</system>
|
|
22
|
-
</dirac>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!-- TEST: if_conditional_true -->
|
|
2
|
-
<!-- EXPECT: Match! -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<defvar name="x" value="5" />
|
|
5
|
-
<if>
|
|
6
|
-
<cond eval="eq">
|
|
7
|
-
<arg><variable name="x" /></arg>
|
|
8
|
-
<arg>5</arg>
|
|
9
|
-
</cond>
|
|
10
|
-
<then>
|
|
11
|
-
<output>Match!</output>
|
|
12
|
-
</then>
|
|
13
|
-
<else>
|
|
14
|
-
<output>No match!</output>
|
|
15
|
-
</else>
|
|
16
|
-
</if>
|
|
17
|
-
</dirac>
|
package/tests/if-else.test.di
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<!-- TEST: if_else -->
|
|
2
|
-
<!-- EXPECT: Value is small -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<defvar name="num" value="5" />
|
|
5
|
-
<test-if test="$num > 10">
|
|
6
|
-
<output>Value is large</output>
|
|
7
|
-
</test-if>
|
|
8
|
-
<test-if test="$num <= 10">
|
|
9
|
-
<output>Value is small</output>
|
|
10
|
-
</test-if>
|
|
11
|
-
</dirac>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!-- TEST: input_file_line -->
|
|
2
|
-
<!-- EXPECT: First: line one Second: line two Third: line three EOF: -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<output>First: </output>
|
|
5
|
-
<input source="file" path="tests/test-input.txt" mode="line" />
|
|
6
|
-
|
|
7
|
-
<output> Second: </output>
|
|
8
|
-
<input source="file" path="tests/test-input.txt" mode="line" />
|
|
9
|
-
|
|
10
|
-
<output> Third: </output>
|
|
11
|
-
<input source="file" path="tests/test-input.txt" mode="line" />
|
|
12
|
-
|
|
13
|
-
<output> EOF: </output>
|
|
14
|
-
<input source="file" path="tests/test-input.txt" mode="line" />
|
|
15
|
-
</dirac>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!-- TEST: input_file_with_loop -->
|
|
2
|
-
<!-- EXPECT: line one | line two | line three | -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<loop count="3">
|
|
5
|
-
<defvar name="line">
|
|
6
|
-
<input source="file" path="tests/test-input.txt" mode="line" />
|
|
7
|
-
</defvar>
|
|
8
|
-
|
|
9
|
-
<variable name="line" />
|
|
10
|
-
<output> | </output>
|
|
11
|
-
</loop>
|
|
12
|
-
</dirac>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
hello from stdin
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!-- TEST: llm_execute_with_validation -->
|
|
2
|
-
<!-- EXPECT: Background color is: blue -->
|
|
3
|
-
|
|
4
|
-
<dirac>
|
|
5
|
-
<subroutine name="set-color"
|
|
6
|
-
description="Set a background color"
|
|
7
|
-
param-color="string:required:Color name">
|
|
8
|
-
<parameters select="@color"/>
|
|
9
|
-
<output>Background color is: <variable name="color" /></output>
|
|
10
|
-
</subroutine>
|
|
11
|
-
|
|
12
|
-
<!-- Test: LLM with execute=true and validate=true should work -->
|
|
13
|
-
<!-- This tests that DIRAC-ROOT wrapper tag is properly skipped during validation -->
|
|
14
|
-
<llm execute="true" validate="true" maxTokens="100">
|
|
15
|
-
Set the background color to blue
|
|
16
|
-
</llm>
|
|
17
|
-
</dirac>
|
package/tests/loop-basic.test.di
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<!-- TEST: loop_nested -->
|
|
2
|
-
<!-- EXPECT: 0-A 0-B 1-A 1-B -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<loop count="2" var="i">
|
|
5
|
-
<loop count="2" var="j">
|
|
6
|
-
<eval name="letter">return j === 0 ? 'A' : 'B';</eval>
|
|
7
|
-
<output><variable name="i" />-<variable name="letter" /> </output>
|
|
8
|
-
</loop>
|
|
9
|
-
</loop>
|
|
10
|
-
</dirac>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<!-- TEST: output_file_basic -->
|
|
2
|
-
<!-- EXPECT: stdout output
|
|
3
|
-
File written -->
|
|
4
|
-
<dirac>
|
|
5
|
-
<!-- Write to file -->
|
|
6
|
-
<output file="output-test-temp.txt">File line 1</output>
|
|
7
|
-
<output file="output-test-temp.txt">File line 2</output>
|
|
8
|
-
|
|
9
|
-
<!-- Output to stdout to verify test runs -->
|
|
10
|
-
<output>stdout output</output>
|
|
11
|
-
|
|
12
|
-
<!-- Use system to verify file and clean up -->
|
|
13
|
-
<system shell="bash">
|
|
14
|
-
if [ -f output-test-temp.txt ]; then
|
|
15
|
-
echo "File written"
|
|
16
|
-
rm output-test-temp.txt
|
|
17
|
-
fi
|
|
18
|
-
</system>
|
|
19
|
-
</dirac>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
<!-- TEST: subroutine_multiple_params -->
|
|
2
|
-
<!-- EXPECT: John Doe -->
|
|
3
|
-
<dirac>
|
|
4
|
-
<subroutine name="fullname" param-first="string" param-last="string">
|
|
5
|
-
<eval name="result">return first + ' ' + last;</eval>
|
|
6
|
-
<output><variable name="result" /></output>
|
|
7
|
-
</subroutine>
|
|
8
|
-
|
|
9
|
-
<call name="fullname" first="John" last="Doe" />
|
|
10
|
-
</dirac>
|