dirac-lang 0.1.23 → 0.1.25
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/{chunk-APWJJXNI.js → chunk-7OUYWIZV.js} +55 -14
- package/dist/{chunk-RGS2XK6T.js → chunk-OUMUIBK3.js} +1 -1
- package/dist/cli.js +15 -3
- package/dist/index.js +2 -2
- package/dist/{interpreter-UZDVASAW.js → interpreter-MTIIHIIQ.js} +1 -1
- package/dist/test-runner.js +1 -1
- package/lib/index.di +9 -0
- 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 -66
- 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}/math.di +0 -0
- /package/{examples/lib → lib}/mongodb.di +0 -0
package/TEST-COVERAGE.md
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# Dirac Unit Test Coverage Report
|
|
2
|
-
|
|
3
|
-
## Summary
|
|
4
|
-
- **Total Tests**: 32
|
|
5
|
-
- **Passing**: 20 (62.5%)
|
|
6
|
-
- **Failing**: 12 (37.5%)
|
|
7
|
-
|
|
8
|
-
## Test Status by Tag
|
|
9
|
-
|
|
10
|
-
### ✅ Fully Covered (Passing)
|
|
11
|
-
- `<output>` - Basic output, multiple outputs
|
|
12
|
-
- `<defvar>` - Variable definition, multiple variables
|
|
13
|
-
- `<variable>` - Variable interpolation
|
|
14
|
-
- `<assign>` - Basic assignment
|
|
15
|
-
- `<eval>` - Basic eval, eval with variables, eval naming
|
|
16
|
-
- `<loop>` - Basic loops
|
|
17
|
-
- `<test-if>` - Attribute-based conditional testing
|
|
18
|
-
- `<system>` - Basic system commands
|
|
19
|
-
- `<require_module>` - Node.js module imports
|
|
20
|
-
- `<subroutine>` - Basic subroutine calls
|
|
21
|
-
- `<try>/<catch>` - Error handling, error expectations
|
|
22
|
-
- `<exception>` - Exception handling
|
|
23
|
-
|
|
24
|
-
### ⚠️ Partially Covered (Has Issues)
|
|
25
|
-
- `<expr>` - Syntax needs fixing (requires `eval` attribute)
|
|
26
|
-
- `<call>` - Subroutine calls (parameter definition issues)
|
|
27
|
-
- `<loop>` - Nested loops (logic issues)
|
|
28
|
-
- `<import>` - Import functionality (needs investigation)
|
|
29
|
-
- `<system>` - Output capture order
|
|
30
|
-
|
|
31
|
-
### ❌ Not Tested
|
|
32
|
-
- `<llm>` - Requires LLM provider configuration
|
|
33
|
-
- `<execute>` - Requires LLM provider configuration
|
|
34
|
-
- `<mongodb>` - Requires MongoDB connection
|
|
35
|
-
- `<if>` - Conditional expression evaluation (different from test-if)
|
|
36
|
-
- `<parameters>` - HTTP parameter extraction
|
|
37
|
-
|
|
38
|
-
## Failing Tests Details
|
|
39
|
-
|
|
40
|
-
### 1. call_basic & call_with_output
|
|
41
|
-
**Issue**: Subroutine parameter binding
|
|
42
|
-
```
|
|
43
|
-
Error: Eval error: x is not defined
|
|
44
|
-
```
|
|
45
|
-
**Fix Needed**: Verify param-* attribute syntax
|
|
46
|
-
|
|
47
|
-
### 2. expr_basic & expr_string_concat
|
|
48
|
-
**Issue**: Missing `eval` attribute
|
|
49
|
-
```
|
|
50
|
-
Error: <expr> requires eval or op attribute
|
|
51
|
-
```
|
|
52
|
-
**Already Fixed**: Changed to `<expr eval="..." />`
|
|
53
|
-
|
|
54
|
-
### 3. if_else & if_with_variables
|
|
55
|
-
**Issue**: test-if syntax
|
|
56
|
-
```
|
|
57
|
-
Error: <test-if> requires test attribute
|
|
58
|
-
```
|
|
59
|
-
**Fix Needed**: Use proper test-if syntax with `test="$var"` and comparison operators
|
|
60
|
-
|
|
61
|
-
### 4. import_basic
|
|
62
|
-
**Issue**: Import not finding parameter
|
|
63
|
-
```
|
|
64
|
-
Error: Eval error: x is not defined
|
|
65
|
-
```
|
|
66
|
-
**Fix Needed**: Check import mechanism and subroutine parameter passing
|
|
67
|
-
|
|
68
|
-
### 5. loop_nested
|
|
69
|
-
**Issue**: Logic error in nested loop test
|
|
70
|
-
```
|
|
71
|
-
Expected: "0-A 0-B 1-A 1-B"
|
|
72
|
-
Actual: "0-B 0-B 1-B 1-B"
|
|
73
|
-
```
|
|
74
|
-
**Fix Needed**: Fix letter calculation logic
|
|
75
|
-
|
|
76
|
-
### 6. subroutine_multiple_params & subroutine_recursive
|
|
77
|
-
**Issue**: Output variable not captured
|
|
78
|
-
```
|
|
79
|
-
Expected: "Full name: John Doe"
|
|
80
|
-
Actual: "Full name:"
|
|
81
|
-
```
|
|
82
|
-
**Fix Needed**: Check param-output and eval output assignment
|
|
83
|
-
|
|
84
|
-
### 7. system_capture & system_with_trim
|
|
85
|
-
**Issue**: Output order
|
|
86
|
-
```
|
|
87
|
-
Expected: "hello Result: hello"
|
|
88
|
-
Actual: "hello Result:"
|
|
89
|
-
```
|
|
90
|
-
**Fix Needed**: System command output comes first, variable not captured
|
|
91
|
-
|
|
92
|
-
## Next Steps
|
|
93
|
-
|
|
94
|
-
1. **High Priority** - Fix subroutine parameter passing (4 tests)
|
|
95
|
-
2. **Medium Priority** - Fix expr and test-if syntax (4 tests)
|
|
96
|
-
3. **Low Priority** - Fix system output capture (2 tests), loop logic (1 test), import (1 test)
|
|
97
|
-
4. **Future** - Add LLM/MongoDB integration tests when services available
|
|
98
|
-
|
|
99
|
-
## Test Execution
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
npm test
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
All tests run automatically on build. Test files are in `/tests` directory with format:
|
|
106
|
-
```xml
|
|
107
|
-
<!-- TEST: test_name -->
|
|
108
|
-
<!-- EXPECT: expected output -->
|
|
109
|
-
<!-- EXPECT_ERROR: expected error message -->
|
|
110
|
-
<dirac>
|
|
111
|
-
<!-- test code -->
|
|
112
|
-
</dirac>
|
|
113
|
-
```
|
package/TESTING.md
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
# Dirac Testing System
|
|
2
|
-
|
|
3
|
-
A simple, lightweight testing framework for Dirac language files.
|
|
4
|
-
|
|
5
|
-
## Running Tests
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm test
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
This will:
|
|
12
|
-
1. Build the project
|
|
13
|
-
2. Run all `*.test.di` files in the `tests/` directory
|
|
14
|
-
3. Report results
|
|
15
|
-
|
|
16
|
-
## Writing Tests
|
|
17
|
-
|
|
18
|
-
Tests are standard Dirac `.di` files with special comments that define expectations.
|
|
19
|
-
|
|
20
|
-
### Test File Format
|
|
21
|
-
|
|
22
|
-
```xml
|
|
23
|
-
<!-- TEST: test_name -->
|
|
24
|
-
<!-- EXPECT: expected output -->
|
|
25
|
-
<dirac>
|
|
26
|
-
<!-- your test code here -->
|
|
27
|
-
</dirac>
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Test Metadata Comments
|
|
31
|
-
|
|
32
|
-
- `<!-- TEST: name -->` - Name of the test (optional, defaults to filename)
|
|
33
|
-
- `<!-- EXPECT: output -->` - Expected output (optional)
|
|
34
|
-
- `<!-- EXPECT_ERROR: error message -->` - Expected error message (optional)
|
|
35
|
-
|
|
36
|
-
### Example Tests
|
|
37
|
-
|
|
38
|
-
#### Basic Output Test
|
|
39
|
-
|
|
40
|
-
```xml
|
|
41
|
-
<!-- TEST: hello_world -->
|
|
42
|
-
<!-- EXPECT: Hello, World! -->
|
|
43
|
-
<dirac>
|
|
44
|
-
<output>Hello, World!</output>
|
|
45
|
-
</dirac>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
#### Variable Test
|
|
49
|
-
|
|
50
|
-
```xml
|
|
51
|
-
<!-- TEST: variables -->
|
|
52
|
-
<!-- EXPECT: Value is: test123 -->
|
|
53
|
-
<dirac>
|
|
54
|
-
<defvar name="myvar" value="test123" />
|
|
55
|
-
<output>Value is: <variable name="myvar" /></output>
|
|
56
|
-
</dirac>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
#### Error Test
|
|
60
|
-
|
|
61
|
-
```xml
|
|
62
|
-
<!-- TEST: missing_variable -->
|
|
63
|
-
<!-- EXPECT_ERROR: Variable 'missing' not found -->
|
|
64
|
-
<dirac>
|
|
65
|
-
<variable name="missing" />
|
|
66
|
-
</dirac>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
#### No Expectation (Just Run)
|
|
70
|
-
|
|
71
|
-
```xml
|
|
72
|
-
<!-- TEST: runs_without_error -->
|
|
73
|
-
<dirac>
|
|
74
|
-
<defvar name="x" value="10" />
|
|
75
|
-
<!-- Test passes if it runs without throwing an error -->
|
|
76
|
-
</dirac>
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Test Organization
|
|
80
|
-
|
|
81
|
-
Tests should be placed in the `tests/` directory with the `.test.di` extension:
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
tests/
|
|
85
|
-
├── basic-output.test.di
|
|
86
|
-
├── variable-basic.test.di
|
|
87
|
-
├── subroutine-basic.test.di
|
|
88
|
-
├── if-conditional.test.di
|
|
89
|
-
└── ...
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
You can organize tests into subdirectories:
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
tests/
|
|
96
|
-
├── core/
|
|
97
|
-
│ ├── output.test.di
|
|
98
|
-
│ └── variables.test.di
|
|
99
|
-
├── control-flow/
|
|
100
|
-
│ ├── if.test.di
|
|
101
|
-
│ └── loop.test.di
|
|
102
|
-
└── llm/
|
|
103
|
-
└── basic.test.di
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Output Matching
|
|
107
|
-
|
|
108
|
-
The test runner normalizes whitespace when comparing output:
|
|
109
|
-
- Multiple spaces/newlines are collapsed to single spaces
|
|
110
|
-
- Leading/trailing whitespace is trimmed
|
|
111
|
-
- This allows tests to ignore XML formatting whitespace
|
|
112
|
-
|
|
113
|
-
For example, these are equivalent:
|
|
114
|
-
- Expected: `Hello World`
|
|
115
|
-
- Actual: ` Hello World ` → matches ✓
|
|
116
|
-
- Actual: `Hello\n World` → matches ✓
|
|
117
|
-
|
|
118
|
-
## Exit Codes
|
|
119
|
-
|
|
120
|
-
- `0` - All tests passed
|
|
121
|
-
- `1` - One or more tests failed
|
|
122
|
-
|
|
123
|
-
## Continuous Integration
|
|
124
|
-
|
|
125
|
-
Add to your CI pipeline:
|
|
126
|
-
|
|
127
|
-
```yaml
|
|
128
|
-
# .github/workflows/test.yml
|
|
129
|
-
- name: Run tests
|
|
130
|
-
run: npm test
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Best Practices
|
|
134
|
-
|
|
135
|
-
1. **One concept per test** - Each test should verify one specific behavior
|
|
136
|
-
2. **Descriptive names** - Use clear test names that describe what's being tested
|
|
137
|
-
3. **Test edge cases** - Include tests for error conditions and boundary cases
|
|
138
|
-
4. **Keep tests fast** - Avoid LLM calls in unit tests (use mocks or separate integration tests)
|
|
139
|
-
5. **Test regressions** - When fixing bugs, add a test to prevent regression
|
|
140
|
-
|
|
141
|
-
## Example Test Suite
|
|
142
|
-
|
|
143
|
-
```
|
|
144
|
-
tests/
|
|
145
|
-
├── basic-output.test.di # Basic output functionality
|
|
146
|
-
├── variable-basic.test.di # Variable definition and output
|
|
147
|
-
├── subroutine-basic.test.di # Subroutine calls
|
|
148
|
-
├── if-conditional.test.di # Conditional execution
|
|
149
|
-
├── loop-basic.test.di # Loop functionality
|
|
150
|
-
├── exception-basic.test.di # Exception handling
|
|
151
|
-
└── test-if-basic.test.di # test-if conditional
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Future Enhancements
|
|
155
|
-
|
|
156
|
-
Potential improvements:
|
|
157
|
-
- Watch mode for TDD workflow
|
|
158
|
-
- Code coverage reporting
|
|
159
|
-
- Performance benchmarks
|
|
160
|
-
- Parallel test execution
|
|
161
|
-
- Test fixtures/setup/teardown
|
|
162
|
-
- Snapshot testing for complex outputs
|
package/config.test.yml
DELETED
package/dirac-http/lib/index.di
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
|
|
3
|
-
<!-- All tags use the library prefix to avoid naming conflicts -->
|
|
4
|
-
<subroutine name="HTTP_EXAMPLE">
|
|
5
|
-
<eval>
|
|
6
|
-
const caller = getParams();
|
|
7
|
-
const input = caller.attributes.input || 'no input';
|
|
8
|
-
console.log('Processed: ' + input);
|
|
9
|
-
</eval>
|
|
10
|
-
</subroutine>
|
|
11
|
-
|
|
12
|
-
</dirac>
|
package/examples/add-demo.di
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<dirac>
|
|
3
|
-
<!--
|
|
4
|
-
Method 1: Using <expr> tag (clean, declarative)
|
|
5
|
-
-->
|
|
6
|
-
<subroutine name="ADD">
|
|
7
|
-
<expr eval="plus">
|
|
8
|
-
<arg><parameters select="@x"/></arg>
|
|
9
|
-
<arg><parameters select="@y"/></arg>
|
|
10
|
-
</expr>
|
|
11
|
-
</subroutine>
|
|
12
|
-
|
|
13
|
-
<output>Method 1 (expr tag): </output>
|
|
14
|
-
<output> 1 + 2 = </output>
|
|
15
|
-
<ADD x="1" y="2"/>
|
|
16
|
-
<output> </output>
|
|
17
|
-
|
|
18
|
-
<output> 5 + 7 = </output>
|
|
19
|
-
<ADD x="5" y="7"/>
|
|
20
|
-
<output> </output>
|
|
21
|
-
|
|
22
|
-
<output> 100 + 200 = </output>
|
|
23
|
-
<ADD x="100" y="200"/>
|
|
24
|
-
<output> </output>
|
|
25
|
-
|
|
26
|
-
<!--
|
|
27
|
-
Method 2: Using getParams() in eval (programmatic)
|
|
28
|
-
-->
|
|
29
|
-
<subroutine name="MULTIPLY">
|
|
30
|
-
<eval>
|
|
31
|
-
const caller = getParams();
|
|
32
|
-
if (caller && caller.attributes) {
|
|
33
|
-
const x = parseInt(caller.attributes.x || 0);
|
|
34
|
-
const y = parseInt(caller.attributes.y || 0);
|
|
35
|
-
console.log(x * y);
|
|
36
|
-
}
|
|
37
|
-
</eval>
|
|
38
|
-
</subroutine>
|
|
39
|
-
|
|
40
|
-
<output> Method 2 (eval with getParams): </output>
|
|
41
|
-
<output>3 * 4 = </output>
|
|
42
|
-
<MULTIPLY x="3" y="4"/>
|
|
43
|
-
<output> </output>
|
|
44
|
-
|
|
45
|
-
<output>5 * 6 = </output>
|
|
46
|
-
<MULTIPLY x="5" y="6"/>
|
|
47
|
-
<output> </output>
|
|
48
|
-
|
|
49
|
-
<!-- More expr examples -->
|
|
50
|
-
<output> More operations: </output>
|
|
51
|
-
<output>10 - 3 = </output>
|
|
52
|
-
<expr eval="minus"><arg>10</arg><arg>3</arg></expr>
|
|
53
|
-
<output> </output>
|
|
54
|
-
|
|
55
|
-
<output>7 * 8 = </output>
|
|
56
|
-
<expr eval="times"><arg>7</arg><arg>8</arg></expr>
|
|
57
|
-
<output> </output>
|
|
58
|
-
|
|
59
|
-
<output>20 / 4 = </output>
|
|
60
|
-
<expr eval="divide"><arg>20</arg><arg>4</arg></expr>
|
|
61
|
-
<output> </output>
|
|
62
|
-
|
|
63
|
-
<output>17 mod 5 = </output>
|
|
64
|
-
<expr eval="mod"><arg>17</arg><arg>5</arg></expr>
|
|
65
|
-
<output> </output>
|
|
66
|
-
|
|
67
|
-
<output>5 < 10 = </output>
|
|
68
|
-
<expr eval="lt"><arg>5</arg><arg>10</arg></expr>
|
|
69
|
-
<output> </output>
|
|
70
|
-
|
|
71
|
-
<output>5 > 10 = </output>
|
|
72
|
-
<expr eval="gt"><arg>5</arg><arg>10</arg></expr>
|
|
73
|
-
<output> </output>
|
|
74
|
-
</dirac>
|
package/examples/add.bk
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<dirac>
|
|
3
|
-
<!-- Import advanced math library -->
|
|
4
|
-
<import src="./lib/advanced-math.di"/>
|
|
5
|
-
|
|
6
|
-
<output>Advanced Math Library Demo </output>
|
|
7
|
-
|
|
8
|
-
<!-- Square root -->
|
|
9
|
-
<output>Square root of 16: </output>
|
|
10
|
-
<MATH_SQRT n="16"/>
|
|
11
|
-
<output> </output>
|
|
12
|
-
|
|
13
|
-
<output>Square root of 2: </output>
|
|
14
|
-
<MATH_SQRT n="2"/>
|
|
15
|
-
<output> </output>
|
|
16
|
-
|
|
17
|
-
<!-- Factorial -->
|
|
18
|
-
<output>Factorial of 5: </output>
|
|
19
|
-
<MATH_FACTORIAL n="5"/>
|
|
20
|
-
<output> </output>
|
|
21
|
-
|
|
22
|
-
<output>Factorial of 10: </output>
|
|
23
|
-
<MATH_FACTORIAL n="10"/>
|
|
24
|
-
<output> </output>
|
|
25
|
-
|
|
26
|
-
<!-- GCD -->
|
|
27
|
-
<output>GCD(48, 18): </output>
|
|
28
|
-
<MATH_GCD a="48" b="18"/>
|
|
29
|
-
<output> </output>
|
|
30
|
-
|
|
31
|
-
<output>GCD(100, 35): </output>
|
|
32
|
-
<MATH_GCD a="100" b="35"/>
|
|
33
|
-
<output> </output>
|
|
34
|
-
|
|
35
|
-
<!-- Prime check -->
|
|
36
|
-
<output>Is 17 prime? </output>
|
|
37
|
-
<MATH_PRIME n="17"/>
|
|
38
|
-
<output> </output>
|
|
39
|
-
|
|
40
|
-
<output>Is 20 prime? </output>
|
|
41
|
-
<MATH_PRIME n="20"/>
|
|
42
|
-
<output> </output>
|
|
43
|
-
|
|
44
|
-
<!-- Random number -->
|
|
45
|
-
<output>Random number [0-100]: </output>
|
|
46
|
-
<MATH_RANDOM min="0" max="100"/>
|
|
47
|
-
<output> </output>
|
|
48
|
-
|
|
49
|
-
<!-- Statistics -->
|
|
50
|
-
<output> Statistics for [1,2,3,4,5,10,100]: </output>
|
|
51
|
-
<MATH_STATS data="[1,2,3,4,5,10,100]"/>
|
|
52
|
-
<output> </output>
|
|
53
|
-
</dirac>
|
package/examples/calculator.di
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
```xml
|
|
2
|
-
<?xml version="1.0"?>
|
|
3
|
-
<!-- Basic Arithmetic Calculator -->
|
|
4
|
-
<dirac>
|
|
5
|
-
<!-- Declaration of variables -->
|
|
6
|
-
<defvar name="num1" value="0" />
|
|
7
|
-
<defvar name="num2" value="0" />
|
|
8
|
-
<defvar name="result" value="0" />
|
|
9
|
-
<defvar name="operation" value="" />
|
|
10
|
-
|
|
11
|
-
<!-- User input for first number -->
|
|
12
|
-
<LLM output="num1">Please enter the first number:</LLM>
|
|
13
|
-
|
|
14
|
-
<!-- User input for second number -->
|
|
15
|
-
<LLM output="num2">Please enter the second number:</LLM>
|
|
16
|
-
|
|
17
|
-
<!-- User input for the operation -->
|
|
18
|
-
<LLM output="operation">Please choose the operation (+, -, *, /):</LLM>
|
|
19
|
-
|
|
20
|
-
<!-- Perform selected operation -->
|
|
21
|
-
<if test="${operation} == '+'">
|
|
22
|
-
<set var="result" value="${num1} + ${num2}" />
|
|
23
|
-
</if>
|
|
24
|
-
<if test="${operation} == '-'">
|
|
25
|
-
<set var="result" value="${num1} - ${num2}" />
|
|
26
|
-
</if>
|
|
27
|
-
<if test="${operation} == '*'">
|
|
28
|
-
<set var="result" value="${num1} * ${num2}" />
|
|
29
|
-
</if>
|
|
30
|
-
<if test="${operation} == '/'">
|
|
31
|
-
<if test="${num2} == 0">
|
|
32
|
-
<output>Division by zero is not allowed.</output>
|
package/examples/compact-test.di
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
|output>Bra-Ket Notation Demo
|
|
2
|
-
|
|
3
|
-
<factorial|
|
|
4
|
-
|parameters select=@n>
|
|
5
|
-
|variable name=n>
|
|
6
|
-
|if>
|
|
7
|
-
|expr op=eq>
|
|
8
|
-
|arg>
|
|
9
|
-
|variable name=n>
|
|
10
|
-
|arg>1
|
|
11
|
-
|output>1
|
|
12
|
-
|expr op=times>
|
|
13
|
-
|arg>
|
|
14
|
-
|variable name=n>
|
|
15
|
-
|arg>
|
|
16
|
-
|factorial>
|
|
17
|
-
|expr op=minus>
|
|
18
|
-
|arg>
|
|
19
|
-
|variable name=n>
|
|
20
|
-
|arg>1
|
|
21
|
-
|
|
22
|
-
|output>Factorial of 5 =
|
|
23
|
-
|factorial n=5>
|
|
24
|
-
|output>
|
|
25
|
-
|
|
26
|
-
<format|
|
|
27
|
-
|output>Name: |variable name=name>, Age: |variable name=age>
|
|
28
|
-
|
|
29
|
-
|format name=Alice age=30>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<!-- Simple example: defvar sets, variable gets -->
|
|
3
|
-
<defvar name="greeting">Hello, World!</defvar>
|
|
4
|
-
<output><variable name="greeting"/></output>
|
|
5
|
-
<output> </output>
|
|
6
|
-
|
|
7
|
-
<!-- Subroutine with parameter -->
|
|
8
|
-
<subroutine name="greet">
|
|
9
|
-
<parameters select="@name">
|
|
10
|
-
<defvar name="localname"/>
|
|
11
|
-
</parameters>
|
|
12
|
-
<output>Greetings, <variable name="localname"/>!</output>
|
|
13
|
-
</subroutine>
|
|
14
|
-
|
|
15
|
-
<greet name="Alice"/>
|
|
16
|
-
<output> </output>
|
|
17
|
-
<greet name="Bob"/>
|
|
18
|
-
</dirac>
|
package/examples/direct-call.di
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env dirac
|
|
2
|
-
<dirac>
|
|
3
|
-
<import src="./lib/math.di" />
|
|
4
|
-
|
|
5
|
-
<output>Direct Tag Call Test </output>
|
|
6
|
-
|
|
7
|
-
<defvar name="x" value="9" />
|
|
8
|
-
<output>Using <SQUARE />: </output>
|
|
9
|
-
<SQUARE />
|
|
10
|
-
<output> </output>
|
|
11
|
-
|
|
12
|
-
<defvar name="a" value="100" />
|
|
13
|
-
<defvar name="b" value="200" />
|
|
14
|
-
<output>Using <ADD />: </output>
|
|
15
|
-
<ADD />
|
|
16
|
-
<output> </output>
|
|
17
|
-
</dirac>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<!-- Get disk usage and ask LLM to summarize -->
|
|
3
|
-
<output>Analyzing disk usage...</output>
|
|
4
|
-
<output> </output>
|
|
5
|
-
|
|
6
|
-
<llm>
|
|
7
|
-
<system>du -sh . 2>/dev/null</system>
|
|
8
|
-
<system>df -h . | tail -1</system>
|
|
9
|
-
|
|
10
|
-
Above are two commands:
|
|
11
|
-
1. Total size of current directory
|
|
12
|
-
2. Disk space information for the filesystem
|
|
13
|
-
|
|
14
|
-
Please tell me in one sentence: How much space is this directory using and what percentage of the disk is free?
|
|
15
|
-
</llm>
|
|
16
|
-
</dirac>
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
<dirac>
|
|
2
|
-
<output>===== Try/Catch/Throw Exception Handling Tests =====</output>
|
|
3
|
-
<output>
|
|
4
|
-
</output>
|
|
5
|
-
|
|
6
|
-
<!-- Test 1: Simple exception -->
|
|
7
|
-
<output>Test 1: Simple exception throw and catch</output>
|
|
8
|
-
<try>
|
|
9
|
-
<throw name="error1">
|
|
10
|
-
<output>Error message from throw</output>
|
|
11
|
-
</throw>
|
|
12
|
-
</try>
|
|
13
|
-
|
|
14
|
-
<catch name="error1">
|
|
15
|
-
<output>Caught: </output>
|
|
16
|
-
<exception/>
|
|
17
|
-
</catch>
|
|
18
|
-
<output>
|
|
19
|
-
</output>
|
|
20
|
-
|
|
21
|
-
<!-- Test 2: Named exceptions -->
|
|
22
|
-
<output>Test 2: Multiple named exceptions</output>
|
|
23
|
-
<try>
|
|
24
|
-
<throw name="warning">
|
|
25
|
-
<output>This is a warning</output>
|
|
26
|
-
</throw>
|
|
27
|
-
<throw name="error">
|
|
28
|
-
<output>This is an error</output>
|
|
29
|
-
</throw>
|
|
30
|
-
</try>
|
|
31
|
-
|
|
32
|
-
<catch name="warning">
|
|
33
|
-
<output>Warnings: </output>
|
|
34
|
-
<exception/>
|
|
35
|
-
</catch>
|
|
36
|
-
|
|
37
|
-
<catch name="error">
|
|
38
|
-
<output>Errors: </output>
|
|
39
|
-
<exception/>
|
|
40
|
-
</catch>
|
|
41
|
-
<output>
|
|
42
|
-
</output>
|
|
43
|
-
|
|
44
|
-
<!-- Test 3: Exception with variable data -->
|
|
45
|
-
<output>Test 3: Exception with variable data</output>
|
|
46
|
-
<defvar name="errorCode" value="404"/>
|
|
47
|
-
<defvar name="errorMsg" value="Not Found"/>
|
|
48
|
-
|
|
49
|
-
<try>
|
|
50
|
-
<throw name="httperror">
|
|
51
|
-
<output>HTTP Error </output>
|
|
52
|
-
<variable name="errorCode"/>
|
|
53
|
-
<output>: </output>
|
|
54
|
-
<variable name="errorMsg"/>
|
|
55
|
-
</throw>
|
|
56
|
-
</try>
|
|
57
|
-
|
|
58
|
-
<catch name="httperror">
|
|
59
|
-
<output>Caught HTTP error: </output>
|
|
60
|
-
<exception/>
|
|
61
|
-
</catch>
|
|
62
|
-
<output>
|
|
63
|
-
</output>
|
|
64
|
-
|
|
65
|
-
<!-- Test 4: No matching catch -->
|
|
66
|
-
<output>Test 4: Exception with no matching catch (should not output)</output>
|
|
67
|
-
<try>
|
|
68
|
-
<throw name="uncaught">
|
|
69
|
-
<output>This won't be caught</output>
|
|
70
|
-
</throw>
|
|
71
|
-
</try>
|
|
72
|
-
|
|
73
|
-
<catch name="different">
|
|
74
|
-
<output>This should NOT appear</output>
|
|
75
|
-
<exception/>
|
|
76
|
-
</catch>
|
|
77
|
-
<output>Done with test 4</output>
|
|
78
|
-
<output>
|
|
79
|
-
</output>
|
|
80
|
-
|
|
81
|
-
<output>===== All tests complete =====</output>
|
|
82
|
-
</dirac>
|