@holoscript/core 2.0.0 → 2.0.2
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/LICENSE +21 -0
- package/dist/chunk-3N67RLQP.cjs +1298 -0
- package/dist/chunk-3N67RLQP.cjs.map +1 -0
- package/dist/chunk-3X2EGU7Z.cjs +52 -0
- package/dist/chunk-3X2EGU7Z.cjs.map +1 -0
- package/dist/chunk-4CV4JOE5.js +24 -0
- package/dist/chunk-4CV4JOE5.js.map +1 -0
- package/dist/chunk-4OHVW4XR.cjs +1027 -0
- package/dist/chunk-4OHVW4XR.cjs.map +1 -0
- package/dist/chunk-CZLDE2OZ.cjs +28 -0
- package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
- package/{src/HoloScriptRuntime.ts → dist/chunk-EU6CZMGJ.js} +437 -794
- package/dist/chunk-EU6CZMGJ.js.map +1 -0
- package/dist/chunk-KWYIVRIH.js +344 -0
- package/dist/chunk-KWYIVRIH.js.map +1 -0
- package/dist/chunk-MCP6D4LT.js +1025 -0
- package/dist/chunk-MCP6D4LT.js.map +1 -0
- package/dist/chunk-SATNCODL.js +45 -0
- package/dist/chunk-SATNCODL.js.map +1 -0
- package/dist/chunk-VMZN4EVR.cjs +347 -0
- package/dist/chunk-VMZN4EVR.cjs.map +1 -0
- package/{src/HoloScriptDebugger.ts → dist/chunk-VYIDLUCV.js} +118 -257
- package/dist/chunk-VYIDLUCV.js.map +1 -0
- package/dist/chunk-WFI4T3XB.cjs +424 -0
- package/dist/chunk-WFI4T3XB.cjs.map +1 -0
- package/dist/debugger.cjs +20 -0
- package/dist/debugger.cjs.map +1 -0
- package/dist/debugger.d.cts +171 -0
- package/dist/debugger.d.ts +171 -0
- package/dist/debugger.js +7 -0
- package/dist/debugger.js.map +1 -0
- package/dist/index.cjs +6006 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2482 -0
- package/dist/index.d.ts +2482 -0
- package/dist/index.js +5926 -0
- package/dist/index.js.map +1 -0
- package/dist/parser.cjs +14 -0
- package/dist/parser.cjs.map +1 -0
- package/dist/parser.d.cts +139 -0
- package/dist/parser.d.ts +139 -0
- package/dist/parser.js +5 -0
- package/dist/parser.js.map +1 -0
- package/dist/runtime.cjs +14 -0
- package/dist/runtime.cjs.map +1 -0
- package/dist/runtime.d.cts +180 -0
- package/dist/runtime.d.ts +180 -0
- package/dist/runtime.js +5 -0
- package/dist/runtime.js.map +1 -0
- package/dist/type-checker.cjs +17 -0
- package/dist/type-checker.cjs.map +1 -0
- package/dist/type-checker.d.cts +105 -0
- package/dist/type-checker.d.ts +105 -0
- package/dist/type-checker.js +4 -0
- package/dist/type-checker.js.map +1 -0
- package/dist/types-D6g4ACjP.d.cts +262 -0
- package/dist/types-D6g4ACjP.d.ts +262 -0
- package/package.json +11 -8
- package/src/HoloScript2DParser.js +0 -227
- package/src/HoloScript2DParser.ts +0 -261
- package/src/HoloScriptCodeParser.js +0 -1102
- package/src/HoloScriptCodeParser.ts +0 -1188
- package/src/HoloScriptDebugger.js +0 -458
- package/src/HoloScriptParser.js +0 -338
- package/src/HoloScriptParser.ts +0 -397
- package/src/HoloScriptPlusParser.js +0 -371
- package/src/HoloScriptPlusParser.ts +0 -543
- package/src/HoloScriptRuntime.js +0 -1399
- package/src/HoloScriptRuntime.test.js +0 -351
- package/src/HoloScriptRuntime.test.ts +0 -436
- package/src/HoloScriptTypeChecker.js +0 -356
- package/src/HoloScriptTypeChecker.ts +0 -475
- package/src/__tests__/GraphicsServices.test.js +0 -357
- package/src/__tests__/GraphicsServices.test.ts +0 -427
- package/src/__tests__/HoloScriptPlusParser.test.js +0 -317
- package/src/__tests__/HoloScriptPlusParser.test.ts +0 -392
- package/src/__tests__/integration.test.js +0 -336
- package/src/__tests__/integration.test.ts +0 -416
- package/src/__tests__/performance.bench.js +0 -218
- package/src/__tests__/performance.bench.ts +0 -262
- package/src/__tests__/type-checker.test.js +0 -60
- package/src/__tests__/type-checker.test.ts +0 -73
- package/src/index.js +0 -217
- package/src/index.ts +0 -426
- package/src/interop/Interoperability.js +0 -413
- package/src/interop/Interoperability.ts +0 -494
- package/src/logger.js +0 -42
- package/src/logger.ts +0 -57
- package/src/parser/EnhancedParser.js +0 -205
- package/src/parser/EnhancedParser.ts +0 -251
- package/src/parser/HoloScriptPlusParser.js +0 -928
- package/src/parser/HoloScriptPlusParser.ts +0 -1089
- package/src/runtime/HoloScriptPlusRuntime.js +0 -674
- package/src/runtime/HoloScriptPlusRuntime.ts +0 -861
- package/src/runtime/PerformanceTelemetry.js +0 -323
- package/src/runtime/PerformanceTelemetry.ts +0 -467
- package/src/runtime/RuntimeOptimization.js +0 -361
- package/src/runtime/RuntimeOptimization.ts +0 -416
- package/src/services/HololandGraphicsPipelineService.js +0 -506
- package/src/services/HololandGraphicsPipelineService.ts +0 -662
- package/src/services/PlatformPerformanceOptimizer.js +0 -356
- package/src/services/PlatformPerformanceOptimizer.ts +0 -503
- package/src/state/ReactiveState.js +0 -427
- package/src/state/ReactiveState.ts +0 -572
- package/src/tools/DeveloperExperience.js +0 -376
- package/src/tools/DeveloperExperience.ts +0 -438
- package/src/traits/AIDriverTrait.js +0 -322
- package/src/traits/AIDriverTrait.test.js +0 -329
- package/src/traits/AIDriverTrait.test.ts +0 -357
- package/src/traits/AIDriverTrait.ts +0 -474
- package/src/traits/LightingTrait.js +0 -313
- package/src/traits/LightingTrait.test.js +0 -410
- package/src/traits/LightingTrait.test.ts +0 -462
- package/src/traits/LightingTrait.ts +0 -505
- package/src/traits/MaterialTrait.js +0 -194
- package/src/traits/MaterialTrait.test.js +0 -286
- package/src/traits/MaterialTrait.test.ts +0 -329
- package/src/traits/MaterialTrait.ts +0 -324
- package/src/traits/RenderingTrait.js +0 -356
- package/src/traits/RenderingTrait.test.js +0 -363
- package/src/traits/RenderingTrait.test.ts +0 -427
- package/src/traits/RenderingTrait.ts +0 -555
- package/src/traits/VRTraitSystem.js +0 -740
- package/src/traits/VRTraitSystem.ts +0 -1040
- package/src/traits/VoiceInputTrait.js +0 -284
- package/src/traits/VoiceInputTrait.test.js +0 -226
- package/src/traits/VoiceInputTrait.test.ts +0 -252
- package/src/traits/VoiceInputTrait.ts +0 -401
- package/src/types/AdvancedTypeSystem.js +0 -226
- package/src/types/AdvancedTypeSystem.ts +0 -494
- package/src/types/HoloScriptPlus.d.ts +0 -853
- package/src/types.js +0 -6
- package/src/types.ts +0 -369
- package/tsconfig.json +0 -23
- package/tsup.config.d.ts +0 -2
- package/tsup.config.js +0 -18
- package/tsup.config.ts +0 -19
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HoloScript Integration Tests
|
|
3
|
-
*
|
|
4
|
-
* End-to-end tests that verify the complete pipeline:
|
|
5
|
-
* Parser -> Runtime -> Type Checker -> Debugger
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
9
|
-
import { HoloScriptCodeParser } from '../HoloScriptCodeParser';
|
|
10
|
-
import { HoloScriptRuntime } from '../HoloScriptRuntime';
|
|
11
|
-
import { HoloScriptTypeChecker } from '../HoloScriptTypeChecker';
|
|
12
|
-
import { HoloScriptDebugger } from '../HoloScriptDebugger';
|
|
13
|
-
|
|
14
|
-
describe('HoloScript Integration Tests', () => {
|
|
15
|
-
let parser: HoloScriptCodeParser;
|
|
16
|
-
let runtime: HoloScriptRuntime;
|
|
17
|
-
let typeChecker: HoloScriptTypeChecker;
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
parser = new HoloScriptCodeParser();
|
|
21
|
-
runtime = new HoloScriptRuntime();
|
|
22
|
-
typeChecker = new HoloScriptTypeChecker();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('Parser -> Runtime Pipeline', () => {
|
|
26
|
-
it('should parse and execute a simple orb declaration', async () => {
|
|
27
|
-
const code = `
|
|
28
|
-
orb myOrb {
|
|
29
|
-
name: "TestOrb"
|
|
30
|
-
color: "#ff0000"
|
|
31
|
-
glow: true
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
const parseResult = parser.parse(code);
|
|
36
|
-
expect(parseResult.success).toBe(true);
|
|
37
|
-
expect(parseResult.ast.length).toBeGreaterThan(0);
|
|
38
|
-
|
|
39
|
-
const results = await runtime.executeProgram(parseResult.ast);
|
|
40
|
-
expect(results.length).toBeGreaterThan(0);
|
|
41
|
-
expect(results[0].success).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should parse and execute a function definition', async () => {
|
|
45
|
-
const code = `
|
|
46
|
-
function greet(name: string): string {
|
|
47
|
-
return "Hello, " + name
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
50
|
-
|
|
51
|
-
const parseResult = parser.parse(code);
|
|
52
|
-
expect(parseResult.success).toBe(true);
|
|
53
|
-
|
|
54
|
-
const results = await runtime.executeProgram(parseResult.ast);
|
|
55
|
-
expect(results[0].success).toBe(true);
|
|
56
|
-
|
|
57
|
-
// Call the function
|
|
58
|
-
const callResult = await runtime.callFunction('greet', ['World']);
|
|
59
|
-
expect(callResult.success).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('should parse and execute connections between orbs', async () => {
|
|
63
|
-
const code = `
|
|
64
|
-
orb source {
|
|
65
|
-
name: "Source"
|
|
66
|
-
}
|
|
67
|
-
orb target {
|
|
68
|
-
name: "Target"
|
|
69
|
-
}
|
|
70
|
-
connect source to target as "data"
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
const parseResult = parser.parse(code);
|
|
74
|
-
expect(parseResult.success).toBe(true);
|
|
75
|
-
expect(parseResult.ast.length).toBe(3);
|
|
76
|
-
|
|
77
|
-
const results = await runtime.executeProgram(parseResult.ast);
|
|
78
|
-
expect(results.every(r => r.success)).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should handle program with multiple orbs', async () => {
|
|
82
|
-
const code = `
|
|
83
|
-
orb dataOrb {
|
|
84
|
-
value: 42
|
|
85
|
-
name: "DataOrb"
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
orb outputOrb {
|
|
89
|
-
name: "OutputOrb"
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
92
|
-
|
|
93
|
-
const parseResult = parser.parse(code);
|
|
94
|
-
expect(parseResult.success).toBe(true);
|
|
95
|
-
expect(parseResult.ast.length).toBeGreaterThanOrEqual(2);
|
|
96
|
-
|
|
97
|
-
const results = await runtime.executeProgram(parseResult.ast);
|
|
98
|
-
expect(results.length).toBeGreaterThanOrEqual(2);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe('Parser -> Type Checker Pipeline', () => {
|
|
103
|
-
it('should type check orb declarations', () => {
|
|
104
|
-
const code = `
|
|
105
|
-
orb typedOrb {
|
|
106
|
-
count: 10
|
|
107
|
-
name: "TypedOrb"
|
|
108
|
-
active: true
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
|
-
const parseResult = parser.parse(code);
|
|
113
|
-
expect(parseResult.success).toBe(true);
|
|
114
|
-
|
|
115
|
-
const typeResult = typeChecker.check(parseResult.ast);
|
|
116
|
-
expect(typeResult.valid).toBe(true);
|
|
117
|
-
expect(typeResult.diagnostics.length).toBe(0);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('should type check function signatures', () => {
|
|
121
|
-
const code = `
|
|
122
|
-
function add(a: number, b: number): number {
|
|
123
|
-
return a + b
|
|
124
|
-
}
|
|
125
|
-
`;
|
|
126
|
-
|
|
127
|
-
const parseResult = parser.parse(code);
|
|
128
|
-
expect(parseResult.success).toBe(true);
|
|
129
|
-
|
|
130
|
-
const typeResult = typeChecker.check(parseResult.ast);
|
|
131
|
-
expect(typeResult.valid).toBe(true);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('should detect type information', () => {
|
|
135
|
-
const code = `
|
|
136
|
-
const MAX_VALUE = 100
|
|
137
|
-
let counter = 0
|
|
138
|
-
|
|
139
|
-
orb configOrb {
|
|
140
|
-
limit: MAX_VALUE
|
|
141
|
-
}
|
|
142
|
-
`;
|
|
143
|
-
|
|
144
|
-
const parseResult = parser.parse(code);
|
|
145
|
-
expect(parseResult.success).toBe(true);
|
|
146
|
-
|
|
147
|
-
const typeResult = typeChecker.check(parseResult.ast);
|
|
148
|
-
expect(typeResult.typeMap.size).toBeGreaterThan(0);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
describe('Full Pipeline: Parse -> Type Check -> Execute', () => {
|
|
153
|
-
it('should process a complete program through all stages', async () => {
|
|
154
|
-
const code = `
|
|
155
|
-
orb sensorOrb {
|
|
156
|
-
reading: 75
|
|
157
|
-
name: "Sensor"
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function checkReading(value: number): boolean {
|
|
161
|
-
return value > 50
|
|
162
|
-
}
|
|
163
|
-
`;
|
|
164
|
-
|
|
165
|
-
// Stage 1: Parse
|
|
166
|
-
const parseResult = parser.parse(code);
|
|
167
|
-
expect(parseResult.success).toBe(true);
|
|
168
|
-
expect(parseResult.errors.length).toBe(0);
|
|
169
|
-
|
|
170
|
-
// Stage 2: Type Check
|
|
171
|
-
const typeResult = typeChecker.check(parseResult.ast);
|
|
172
|
-
expect(typeResult.valid).toBe(true);
|
|
173
|
-
|
|
174
|
-
// Stage 3: Execute
|
|
175
|
-
const execResults = await runtime.executeProgram(parseResult.ast);
|
|
176
|
-
expect(execResults.every(r => r.success)).toBe(true);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
describe('Debugger Integration', () => {
|
|
181
|
-
it('should load source and set breakpoints', () => {
|
|
182
|
-
const debugger_ = new HoloScriptDebugger(runtime);
|
|
183
|
-
|
|
184
|
-
const code = `
|
|
185
|
-
orb debugOrb {
|
|
186
|
-
name: "DebugOrb"
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function test() {
|
|
190
|
-
show debugOrb
|
|
191
|
-
}
|
|
192
|
-
`;
|
|
193
|
-
|
|
194
|
-
const loadResult = debugger_.loadSource(code);
|
|
195
|
-
expect(loadResult.success).toBe(true);
|
|
196
|
-
|
|
197
|
-
const bp = debugger_.setBreakpoint(2);
|
|
198
|
-
expect(bp.id).toBeDefined();
|
|
199
|
-
expect(bp.line).toBe(2);
|
|
200
|
-
expect(bp.enabled).toBe(true);
|
|
201
|
-
|
|
202
|
-
const breakpoints = debugger_.getBreakpoints();
|
|
203
|
-
expect(breakpoints.length).toBe(1);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('should step through execution', async () => {
|
|
207
|
-
const debugger_ = new HoloScriptDebugger(runtime);
|
|
208
|
-
|
|
209
|
-
const code = `
|
|
210
|
-
orb stepOrb {
|
|
211
|
-
name: "StepOrb"
|
|
212
|
-
}
|
|
213
|
-
`;
|
|
214
|
-
|
|
215
|
-
debugger_.loadSource(code);
|
|
216
|
-
|
|
217
|
-
// Start and immediately pause
|
|
218
|
-
await debugger_.start();
|
|
219
|
-
|
|
220
|
-
const state = debugger_.getState();
|
|
221
|
-
expect(state.status).toBeDefined();
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it('should evaluate expressions in debug context', async () => {
|
|
225
|
-
const debugger_ = new HoloScriptDebugger(runtime);
|
|
226
|
-
|
|
227
|
-
const code = `
|
|
228
|
-
orb evalOrb {
|
|
229
|
-
value: 42
|
|
230
|
-
}
|
|
231
|
-
`;
|
|
232
|
-
|
|
233
|
-
debugger_.loadSource(code);
|
|
234
|
-
await debugger_.start();
|
|
235
|
-
|
|
236
|
-
// Wait for execution to complete
|
|
237
|
-
const result = await debugger_.evaluate('evalOrb');
|
|
238
|
-
expect(result).toBeDefined();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('should handle breakpoint events', async () => {
|
|
242
|
-
const debugger_ = new HoloScriptDebugger(runtime);
|
|
243
|
-
const events: string[] = [];
|
|
244
|
-
|
|
245
|
-
debugger_.on('breakpoint-hit', () => events.push('breakpoint'));
|
|
246
|
-
debugger_.on('state-change', () => events.push('state'));
|
|
247
|
-
|
|
248
|
-
const code = `
|
|
249
|
-
orb eventOrb {
|
|
250
|
-
name: "EventOrb"
|
|
251
|
-
}
|
|
252
|
-
`;
|
|
253
|
-
|
|
254
|
-
debugger_.loadSource(code);
|
|
255
|
-
debugger_.setBreakpoint(2);
|
|
256
|
-
|
|
257
|
-
await debugger_.start();
|
|
258
|
-
|
|
259
|
-
// Events should have been captured
|
|
260
|
-
expect(events.length).toBeGreaterThanOrEqual(0);
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
describe('Error Handling', () => {
|
|
265
|
-
it('should handle parse errors gracefully', () => {
|
|
266
|
-
const code = `
|
|
267
|
-
orb { invalid syntax here
|
|
268
|
-
`;
|
|
269
|
-
|
|
270
|
-
const parseResult = parser.parse(code);
|
|
271
|
-
expect(parseResult.success).toBe(false);
|
|
272
|
-
expect(parseResult.errors.length).toBeGreaterThan(0);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('should handle runtime errors gracefully', async () => {
|
|
276
|
-
const code = `
|
|
277
|
-
function errorFunc() {
|
|
278
|
-
throw "Error"
|
|
279
|
-
}
|
|
280
|
-
`;
|
|
281
|
-
|
|
282
|
-
const parseResult = parser.parse(code);
|
|
283
|
-
expect(parseResult.success).toBe(true);
|
|
284
|
-
|
|
285
|
-
const results = await runtime.executeProgram(parseResult.ast);
|
|
286
|
-
// Function definition should succeed
|
|
287
|
-
expect(results[0].success).toBe(true);
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it('should handle debugger errors gracefully', async () => {
|
|
291
|
-
const debugger_ = new HoloScriptDebugger(runtime);
|
|
292
|
-
|
|
293
|
-
// Completely invalid syntax that parser will reject
|
|
294
|
-
const loadResult = debugger_.loadSource('{{{{{{');
|
|
295
|
-
// Parser may or may not reject this depending on implementation
|
|
296
|
-
// Just verify we get a result without crashing
|
|
297
|
-
expect(loadResult).toBeDefined();
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
describe('Loop Constructs', () => {
|
|
302
|
-
it('should parse for loops', () => {
|
|
303
|
-
const code = `
|
|
304
|
-
for (i = 0; i < 10; i++) {
|
|
305
|
-
show i
|
|
306
|
-
}
|
|
307
|
-
`;
|
|
308
|
-
|
|
309
|
-
const parseResult = parser.parse(code);
|
|
310
|
-
expect(parseResult.success).toBe(true);
|
|
311
|
-
expect(parseResult.ast[0].type).toBe('for-loop');
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it.todo('should parse while loops - needs parser enhancement');
|
|
315
|
-
|
|
316
|
-
it.todo('should parse forEach loops - needs parser enhancement');
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
describe('Module System', () => {
|
|
320
|
-
it.todo('should parse import statements - needs parser enhancement');
|
|
321
|
-
|
|
322
|
-
it('should parse export statements', () => {
|
|
323
|
-
const code = `
|
|
324
|
-
export function helper() {
|
|
325
|
-
return 42
|
|
326
|
-
}
|
|
327
|
-
`;
|
|
328
|
-
|
|
329
|
-
const parseResult = parser.parse(code);
|
|
330
|
-
expect(parseResult.success).toBe(true);
|
|
331
|
-
expect(parseResult.ast[0].type).toBe('export');
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it('should parse variable declarations', () => {
|
|
335
|
-
const code = `
|
|
336
|
-
const MAX = 100
|
|
337
|
-
let count = 0
|
|
338
|
-
var legacy = true
|
|
339
|
-
`;
|
|
340
|
-
|
|
341
|
-
const parseResult = parser.parse(code);
|
|
342
|
-
expect(parseResult.success).toBe(true);
|
|
343
|
-
expect(parseResult.ast.length).toBe(3);
|
|
344
|
-
expect(parseResult.ast[0].type).toBe('variable-declaration');
|
|
345
|
-
});
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
describe('Runtime Context', () => {
|
|
349
|
-
it('should maintain variable state across executions', async () => {
|
|
350
|
-
const code1 = `
|
|
351
|
-
orb stateOrb {
|
|
352
|
-
counter: 0
|
|
353
|
-
}
|
|
354
|
-
`;
|
|
355
|
-
|
|
356
|
-
const parseResult1 = parser.parse(code1);
|
|
357
|
-
await runtime.executeProgram(parseResult1.ast);
|
|
358
|
-
|
|
359
|
-
// Context should exist after execution
|
|
360
|
-
const context = runtime.getContext();
|
|
361
|
-
expect(context).toBeDefined();
|
|
362
|
-
expect(context.variables).toBeDefined();
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
it('should support function calls with arguments', async () => {
|
|
366
|
-
const code = `
|
|
367
|
-
function multiply(a: number, b: number): number {
|
|
368
|
-
return a * b
|
|
369
|
-
}
|
|
370
|
-
`;
|
|
371
|
-
|
|
372
|
-
const parseResult = parser.parse(code);
|
|
373
|
-
await runtime.executeProgram(parseResult.ast);
|
|
374
|
-
|
|
375
|
-
const result = await runtime.callFunction('multiply', [5, 3]);
|
|
376
|
-
expect(result.success).toBe(true);
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
it('should reset context on runtime reset', async () => {
|
|
380
|
-
const code = `
|
|
381
|
-
orb tempOrb {
|
|
382
|
-
name: "Temporary"
|
|
383
|
-
}
|
|
384
|
-
`;
|
|
385
|
-
|
|
386
|
-
const parseResult = parser.parse(code);
|
|
387
|
-
await runtime.executeProgram(parseResult.ast);
|
|
388
|
-
|
|
389
|
-
const contextBefore = runtime.getContext();
|
|
390
|
-
expect(contextBefore).toBeDefined();
|
|
391
|
-
|
|
392
|
-
runtime.reset();
|
|
393
|
-
|
|
394
|
-
const contextAfter = runtime.getContext();
|
|
395
|
-
// After reset, variables should be empty
|
|
396
|
-
expect(contextAfter.variables.size).toBe(0);
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
describe('HoloScript Bridge Integration', () => {
|
|
402
|
-
// These tests would require the Hololand bridge
|
|
403
|
-
// Stubbed for now - would need mock world interface
|
|
404
|
-
|
|
405
|
-
it.skip('should sync orbs to world objects', async () => {
|
|
406
|
-
// Would test HoloScriptBridge.loadScript -> world.createObject
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
it.skip('should handle world events', async () => {
|
|
410
|
-
// Would test world.emit -> bridge event handling
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
it.skip('should sync runtime state to world', async () => {
|
|
414
|
-
// Would test bridge.sync() updating world objects
|
|
415
|
-
});
|
|
416
|
-
});
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HoloScript Performance Benchmarks
|
|
3
|
-
*
|
|
4
|
-
* Measures parsing, execution, and type checking performance.
|
|
5
|
-
* Run with: npx vitest bench
|
|
6
|
-
*/
|
|
7
|
-
import { describe, bench, beforeAll } from 'vitest';
|
|
8
|
-
import { HoloScriptCodeParser } from '../HoloScriptCodeParser';
|
|
9
|
-
import { HoloScriptRuntime } from '../HoloScriptRuntime';
|
|
10
|
-
import { HoloScriptTypeChecker } from '../HoloScriptTypeChecker';
|
|
11
|
-
// Test data
|
|
12
|
-
const SIMPLE_ORB = `
|
|
13
|
-
orb testOrb {
|
|
14
|
-
name: "TestOrb"
|
|
15
|
-
color: "#ff0000"
|
|
16
|
-
glow: true
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
const MULTIPLE_ORBS = Array.from({ length: 10 }, (_, i) => `
|
|
20
|
-
orb orb${i} {
|
|
21
|
-
name: "Orb${i}"
|
|
22
|
-
color: "#${i.toString(16).padStart(6, '0')}"
|
|
23
|
-
value: ${i * 10}
|
|
24
|
-
}
|
|
25
|
-
`).join('\n');
|
|
26
|
-
const COMPLEX_PROGRAM = `
|
|
27
|
-
orb dataSource {
|
|
28
|
-
name: "DataSource"
|
|
29
|
-
rate: 100
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
orb processor {
|
|
33
|
-
name: "Processor"
|
|
34
|
-
capacity: 1000
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
orb output {
|
|
38
|
-
name: "Output"
|
|
39
|
-
format: "json"
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function processData(input: number): number {
|
|
43
|
-
return input * 2
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function validateInput(data: object): boolean {
|
|
47
|
-
return true
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
connect dataSource to processor as "raw"
|
|
51
|
-
connect processor to output as "processed"
|
|
52
|
-
`;
|
|
53
|
-
const FUNCTIONS_PROGRAM = Array.from({ length: 20 }, (_, i) => `
|
|
54
|
-
function func${i}(x: number): number {
|
|
55
|
-
return x + ${i}
|
|
56
|
-
}
|
|
57
|
-
`).join('\n');
|
|
58
|
-
describe('Parser Performance', () => {
|
|
59
|
-
let parser;
|
|
60
|
-
beforeAll(() => {
|
|
61
|
-
parser = new HoloScriptCodeParser();
|
|
62
|
-
});
|
|
63
|
-
bench('parse simple orb', () => {
|
|
64
|
-
parser.parse(SIMPLE_ORB);
|
|
65
|
-
});
|
|
66
|
-
bench('parse 10 orbs', () => {
|
|
67
|
-
parser.parse(MULTIPLE_ORBS);
|
|
68
|
-
});
|
|
69
|
-
bench('parse complex program', () => {
|
|
70
|
-
parser.parse(COMPLEX_PROGRAM);
|
|
71
|
-
});
|
|
72
|
-
bench('parse 20 functions', () => {
|
|
73
|
-
parser.parse(FUNCTIONS_PROGRAM);
|
|
74
|
-
});
|
|
75
|
-
bench('tokenize simple orb', () => {
|
|
76
|
-
// @ts-expect-error - accessing private method for benchmark
|
|
77
|
-
parser.tokenize(SIMPLE_ORB);
|
|
78
|
-
});
|
|
79
|
-
bench('tokenize complex program', () => {
|
|
80
|
-
// @ts-expect-error - accessing private method for benchmark
|
|
81
|
-
parser.tokenize(COMPLEX_PROGRAM);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe('Runtime Performance', () => {
|
|
85
|
-
let parser;
|
|
86
|
-
let runtime;
|
|
87
|
-
let simpleAST;
|
|
88
|
-
let complexAST;
|
|
89
|
-
beforeAll(() => {
|
|
90
|
-
parser = new HoloScriptCodeParser();
|
|
91
|
-
runtime = new HoloScriptRuntime();
|
|
92
|
-
const simpleResult = parser.parse(SIMPLE_ORB);
|
|
93
|
-
simpleAST = simpleResult.ast;
|
|
94
|
-
const complexResult = parser.parse(COMPLEX_PROGRAM);
|
|
95
|
-
complexAST = complexResult.ast;
|
|
96
|
-
});
|
|
97
|
-
bench('execute simple orb', async () => {
|
|
98
|
-
runtime.reset();
|
|
99
|
-
await runtime.executeProgram(simpleAST);
|
|
100
|
-
});
|
|
101
|
-
bench('execute complex program', async () => {
|
|
102
|
-
runtime.reset();
|
|
103
|
-
await runtime.executeProgram(complexAST);
|
|
104
|
-
});
|
|
105
|
-
bench('execute single node', async () => {
|
|
106
|
-
if (simpleAST.length > 0) {
|
|
107
|
-
await runtime.executeNode(simpleAST[0]);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
bench('runtime reset', () => {
|
|
111
|
-
runtime.reset();
|
|
112
|
-
});
|
|
113
|
-
bench('get context', () => {
|
|
114
|
-
runtime.getContext();
|
|
115
|
-
});
|
|
116
|
-
bench('set/get variable', () => {
|
|
117
|
-
runtime.setVariable('benchVar', 42);
|
|
118
|
-
runtime.getVariable('benchVar');
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
describe('Type Checker Performance', () => {
|
|
122
|
-
let parser;
|
|
123
|
-
let typeChecker;
|
|
124
|
-
let simpleAST;
|
|
125
|
-
let complexAST;
|
|
126
|
-
let functionsAST;
|
|
127
|
-
beforeAll(() => {
|
|
128
|
-
parser = new HoloScriptCodeParser();
|
|
129
|
-
typeChecker = new HoloScriptTypeChecker();
|
|
130
|
-
const simpleResult = parser.parse(SIMPLE_ORB);
|
|
131
|
-
simpleAST = simpleResult.ast;
|
|
132
|
-
const complexResult = parser.parse(COMPLEX_PROGRAM);
|
|
133
|
-
complexAST = complexResult.ast;
|
|
134
|
-
const functionsResult = parser.parse(FUNCTIONS_PROGRAM);
|
|
135
|
-
functionsAST = functionsResult.ast;
|
|
136
|
-
});
|
|
137
|
-
bench('type check simple orb', () => {
|
|
138
|
-
typeChecker.check(simpleAST);
|
|
139
|
-
});
|
|
140
|
-
bench('type check complex program', () => {
|
|
141
|
-
typeChecker.check(complexAST);
|
|
142
|
-
});
|
|
143
|
-
bench('type check 20 functions', () => {
|
|
144
|
-
typeChecker.check(functionsAST);
|
|
145
|
-
});
|
|
146
|
-
bench('get all types', () => {
|
|
147
|
-
typeChecker.check(complexAST);
|
|
148
|
-
typeChecker.getAllTypes();
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
describe('Full Pipeline Performance', () => {
|
|
152
|
-
let parser;
|
|
153
|
-
let runtime;
|
|
154
|
-
let typeChecker;
|
|
155
|
-
beforeAll(() => {
|
|
156
|
-
parser = new HoloScriptCodeParser();
|
|
157
|
-
runtime = new HoloScriptRuntime();
|
|
158
|
-
typeChecker = new HoloScriptTypeChecker();
|
|
159
|
-
});
|
|
160
|
-
bench('full pipeline: parse -> type check -> execute (simple)', async () => {
|
|
161
|
-
const parseResult = parser.parse(SIMPLE_ORB);
|
|
162
|
-
typeChecker.check(parseResult.ast);
|
|
163
|
-
runtime.reset();
|
|
164
|
-
await runtime.executeProgram(parseResult.ast);
|
|
165
|
-
});
|
|
166
|
-
bench('full pipeline: parse -> type check -> execute (complex)', async () => {
|
|
167
|
-
const parseResult = parser.parse(COMPLEX_PROGRAM);
|
|
168
|
-
typeChecker.check(parseResult.ast);
|
|
169
|
-
runtime.reset();
|
|
170
|
-
await runtime.executeProgram(parseResult.ast);
|
|
171
|
-
});
|
|
172
|
-
bench('parse only (no execution)', () => {
|
|
173
|
-
parser.parse(COMPLEX_PROGRAM);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
describe('Memory and Scalability', () => {
|
|
177
|
-
let parser;
|
|
178
|
-
let runtime;
|
|
179
|
-
beforeAll(() => {
|
|
180
|
-
parser = new HoloScriptCodeParser();
|
|
181
|
-
runtime = new HoloScriptRuntime();
|
|
182
|
-
});
|
|
183
|
-
bench('parse 100 orbs', () => {
|
|
184
|
-
const largeProgram = Array.from({ length: 100 }, (_, i) => `
|
|
185
|
-
orb orb${i} {
|
|
186
|
-
name: "Orb${i}"
|
|
187
|
-
value: ${i}
|
|
188
|
-
}
|
|
189
|
-
`).join('\n');
|
|
190
|
-
parser.parse(largeProgram);
|
|
191
|
-
});
|
|
192
|
-
bench('execute 50 orbs', async () => {
|
|
193
|
-
const program = Array.from({ length: 50 }, (_, i) => `
|
|
194
|
-
orb orb${i} {
|
|
195
|
-
name: "Orb${i}"
|
|
196
|
-
}
|
|
197
|
-
`).join('\n');
|
|
198
|
-
const result = parser.parse(program);
|
|
199
|
-
runtime.reset();
|
|
200
|
-
await runtime.executeProgram(result.ast);
|
|
201
|
-
});
|
|
202
|
-
bench('many connections', () => {
|
|
203
|
-
const program = `
|
|
204
|
-
orb source { name: "Source" }
|
|
205
|
-
orb a { name: "A" }
|
|
206
|
-
orb b { name: "B" }
|
|
207
|
-
orb c { name: "C" }
|
|
208
|
-
orb d { name: "D" }
|
|
209
|
-
orb target { name: "Target" }
|
|
210
|
-
connect source to a as "data"
|
|
211
|
-
connect a to b as "data"
|
|
212
|
-
connect b to c as "data"
|
|
213
|
-
connect c to d as "data"
|
|
214
|
-
connect d to target as "data"
|
|
215
|
-
`;
|
|
216
|
-
parser.parse(program);
|
|
217
|
-
});
|
|
218
|
-
});
|