zexus 1.6.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 +0 -0
- package/README.md +2513 -0
- package/bin/zexus +2 -0
- package/bin/zpics +2 -0
- package/bin/zpm +2 -0
- package/bin/zx +2 -0
- package/bin/zx-deploy +2 -0
- package/bin/zx-dev +2 -0
- package/bin/zx-run +2 -0
- package/package.json +66 -0
- package/scripts/README.md +24 -0
- package/scripts/postinstall.js +44 -0
- package/shared_config.json +24 -0
- package/src/README.md +1525 -0
- package/src/tests/run_zexus_tests.py +117 -0
- package/src/tests/test_all_phases.zx +346 -0
- package/src/tests/test_blockchain_features.zx +306 -0
- package/src/tests/test_complexity_features.zx +321 -0
- package/src/tests/test_core_integration.py +185 -0
- package/src/tests/test_phase10_ecosystem.zx +177 -0
- package/src/tests/test_phase1_modifiers.zx +87 -0
- package/src/tests/test_phase2_plugins.zx +80 -0
- package/src/tests/test_phase3_security.zx +97 -0
- package/src/tests/test_phase4_vfs.zx +116 -0
- package/src/tests/test_phase5_types.zx +117 -0
- package/src/tests/test_phase6_metaprogramming.zx +125 -0
- package/src/tests/test_phase7_optimization.zx +132 -0
- package/src/tests/test_phase9_advanced_types.zx +157 -0
- package/src/tests/test_security_features.py +419 -0
- package/src/tests/test_security_features.zx +276 -0
- package/src/tests/test_simple_zx.zx +1 -0
- package/src/tests/test_verification_simple.zx +69 -0
- package/src/zexus/__init__.py +28 -0
- package/src/zexus/__main__.py +5 -0
- package/src/zexus/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/advanced_types.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/builtin_modules.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/capability_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/complexity_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/concurrency_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/config.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/dependency_injection.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/ecosystem.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/environment.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/error_reporter.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/hybrid_orchestrator.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/metaprogramming.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/module_cache.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/object.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/optimization.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/plugin_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/policy_engine.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/security.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/stdlib_integration.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/strategy_recovery.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/syntax_validator.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/type_system.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/virtual_filesystem.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/__pycache__/zexus_token.cpython-312.pyc +0 -0
- package/src/zexus/advanced_types.py +401 -0
- package/src/zexus/blockchain/__init__.py +40 -0
- package/src/zexus/blockchain/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/crypto.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/ledger.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/__pycache__/transaction.cpython-312.pyc +0 -0
- package/src/zexus/blockchain/crypto.py +463 -0
- package/src/zexus/blockchain/ledger.py +255 -0
- package/src/zexus/blockchain/transaction.py +267 -0
- package/src/zexus/builtin_modules.py +284 -0
- package/src/zexus/builtin_plugins.py +317 -0
- package/src/zexus/capability_system.py +372 -0
- package/src/zexus/cli/__init__.py +2 -0
- package/src/zexus/cli/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/cli/__pycache__/main.cpython-312.pyc +0 -0
- package/src/zexus/cli/main.py +707 -0
- package/src/zexus/cli/zpm.py +203 -0
- package/src/zexus/compare_interpreter_compiler.py +146 -0
- package/src/zexus/compiler/__init__.py +169 -0
- package/src/zexus/compiler/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/lexer.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/compiler/__pycache__/zexus_ast.cpython-312.pyc +0 -0
- package/src/zexus/compiler/bytecode.py +266 -0
- package/src/zexus/compiler/compat_runtime.py +277 -0
- package/src/zexus/compiler/lexer.py +257 -0
- package/src/zexus/compiler/parser.py +779 -0
- package/src/zexus/compiler/semantic.py +118 -0
- package/src/zexus/compiler/zexus_ast.py +454 -0
- package/src/zexus/complexity_system.py +575 -0
- package/src/zexus/concurrency_system.py +493 -0
- package/src/zexus/config.py +201 -0
- package/src/zexus/crypto_bridge.py +19 -0
- package/src/zexus/dependency_injection.py +423 -0
- package/src/zexus/ecosystem.py +434 -0
- package/src/zexus/environment.py +101 -0
- package/src/zexus/environment_manager.py +119 -0
- package/src/zexus/error_reporter.py +314 -0
- package/src/zexus/evaluator/__init__.py +12 -0
- package/src/zexus/evaluator/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/bytecode_compiler.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/core.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/expressions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/functions.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/integration.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/statements.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/__pycache__/utils.cpython-312.pyc +0 -0
- package/src/zexus/evaluator/bytecode_compiler.py +700 -0
- package/src/zexus/evaluator/core.py +891 -0
- package/src/zexus/evaluator/expressions.py +827 -0
- package/src/zexus/evaluator/functions.py +3989 -0
- package/src/zexus/evaluator/integration.py +396 -0
- package/src/zexus/evaluator/statements.py +4303 -0
- package/src/zexus/evaluator/utils.py +126 -0
- package/src/zexus/evaluator_original.py +2041 -0
- package/src/zexus/external_bridge.py +16 -0
- package/src/zexus/find_affected_imports.sh +155 -0
- package/src/zexus/hybrid_orchestrator.py +152 -0
- package/src/zexus/input_validation.py +259 -0
- package/src/zexus/lexer.py +571 -0
- package/src/zexus/logging.py +89 -0
- package/src/zexus/lsp/__init__.py +9 -0
- package/src/zexus/lsp/completion_provider.py +207 -0
- package/src/zexus/lsp/definition_provider.py +22 -0
- package/src/zexus/lsp/hover_provider.py +71 -0
- package/src/zexus/lsp/server.py +269 -0
- package/src/zexus/lsp/symbol_provider.py +31 -0
- package/src/zexus/metaprogramming.py +321 -0
- package/src/zexus/module_cache.py +89 -0
- package/src/zexus/module_manager.py +107 -0
- package/src/zexus/object.py +973 -0
- package/src/zexus/optimization.py +424 -0
- package/src/zexus/parser/__init__.py +31 -0
- package/src/zexus/parser/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/parser.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_context.cpython-312.pyc +0 -0
- package/src/zexus/parser/__pycache__/strategy_structural.cpython-312.pyc +0 -0
- package/src/zexus/parser/integration.py +86 -0
- package/src/zexus/parser/parser.py +3977 -0
- package/src/zexus/parser/strategy_context.py +7254 -0
- package/src/zexus/parser/strategy_structural.py +1033 -0
- package/src/zexus/persistence.py +391 -0
- package/src/zexus/plugin_system.py +290 -0
- package/src/zexus/policy_engine.py +365 -0
- package/src/zexus/profiler/__init__.py +5 -0
- package/src/zexus/profiler/profiler.py +233 -0
- package/src/zexus/purity_system.py +398 -0
- package/src/zexus/runtime/__init__.py +20 -0
- package/src/zexus/runtime/async_runtime.py +324 -0
- package/src/zexus/search_old_imports.sh +65 -0
- package/src/zexus/security.py +1407 -0
- package/src/zexus/stack_trace.py +233 -0
- package/src/zexus/stdlib/__init__.py +27 -0
- package/src/zexus/stdlib/blockchain.py +341 -0
- package/src/zexus/stdlib/compression.py +167 -0
- package/src/zexus/stdlib/crypto.py +124 -0
- package/src/zexus/stdlib/datetime.py +163 -0
- package/src/zexus/stdlib/db_mongo.py +199 -0
- package/src/zexus/stdlib/db_mysql.py +162 -0
- package/src/zexus/stdlib/db_postgres.py +163 -0
- package/src/zexus/stdlib/db_sqlite.py +133 -0
- package/src/zexus/stdlib/encoding.py +230 -0
- package/src/zexus/stdlib/fs.py +195 -0
- package/src/zexus/stdlib/http.py +219 -0
- package/src/zexus/stdlib/http_server.py +248 -0
- package/src/zexus/stdlib/json_module.py +61 -0
- package/src/zexus/stdlib/math.py +360 -0
- package/src/zexus/stdlib/os_module.py +265 -0
- package/src/zexus/stdlib/regex.py +148 -0
- package/src/zexus/stdlib/sockets.py +253 -0
- package/src/zexus/stdlib/test_framework.zx +208 -0
- package/src/zexus/stdlib/test_runner.zx +119 -0
- package/src/zexus/stdlib_integration.py +341 -0
- package/src/zexus/strategy_recovery.py +256 -0
- package/src/zexus/syntax_validator.py +356 -0
- package/src/zexus/testing/zpics.py +407 -0
- package/src/zexus/testing/zpics_runtime.py +369 -0
- package/src/zexus/type_system.py +374 -0
- package/src/zexus/validation_system.py +569 -0
- package/src/zexus/virtual_filesystem.py +355 -0
- package/src/zexus/vm/__init__.py +8 -0
- package/src/zexus/vm/__pycache__/__init__.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/async_optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/bytecode.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/cache.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/jit.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/memory_manager.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/memory_pool.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/parallel_vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/peephole_optimizer.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/profiler.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/register_allocator.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/register_vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/ssa_converter.cpython-312.pyc +0 -0
- package/src/zexus/vm/__pycache__/vm.cpython-312.pyc +0 -0
- package/src/zexus/vm/async_optimizer.py +420 -0
- package/src/zexus/vm/bytecode.py +428 -0
- package/src/zexus/vm/bytecode_converter.py +297 -0
- package/src/zexus/vm/cache.py +532 -0
- package/src/zexus/vm/jit.py +720 -0
- package/src/zexus/vm/memory_manager.py +520 -0
- package/src/zexus/vm/memory_pool.py +511 -0
- package/src/zexus/vm/optimizer.py +478 -0
- package/src/zexus/vm/parallel_vm.py +899 -0
- package/src/zexus/vm/peephole_optimizer.py +452 -0
- package/src/zexus/vm/profiler.py +527 -0
- package/src/zexus/vm/register_allocator.py +462 -0
- package/src/zexus/vm/register_vm.py +520 -0
- package/src/zexus/vm/ssa_converter.py +757 -0
- package/src/zexus/vm/vm.py +1392 -0
- package/src/zexus/zexus_ast.py +1782 -0
- package/src/zexus/zexus_token.py +253 -0
- package/src/zexus/zpm/__init__.py +15 -0
- package/src/zexus/zpm/installer.py +116 -0
- package/src/zexus/zpm/package_manager.py +208 -0
- package/src/zexus/zpm/publisher.py +98 -0
- package/src/zexus/zpm/registry.py +110 -0
- package/src/zexus.egg-info/PKG-INFO +2235 -0
- package/src/zexus.egg-info/SOURCES.txt +876 -0
- package/src/zexus.egg-info/dependency_links.txt +1 -0
- package/src/zexus.egg-info/entry_points.txt +3 -0
- package/src/zexus.egg-info/not-zip-safe +1 -0
- package/src/zexus.egg-info/requires.txt +14 -0
- package/src/zexus.egg-info/top_level.txt +2 -0
- package/zexus.json +14 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Test verify_integration with fixes
|
|
2
|
+
|
|
3
|
+
# Core test cases that should always pass
|
|
4
|
+
CORE_TESTS = [
|
|
5
|
+
{
|
|
6
|
+
'code': '''
|
|
7
|
+
action simple() {
|
|
8
|
+
print("inside action")
|
|
9
|
+
}
|
|
10
|
+
simple()
|
|
11
|
+
''',
|
|
12
|
+
'desc': "Basic action execution"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
'code': '''
|
|
16
|
+
action sayHello(name) {
|
|
17
|
+
print("Hello " + name)
|
|
18
|
+
}
|
|
19
|
+
sayHello("World")
|
|
20
|
+
''',
|
|
21
|
+
'desc': "Action with parameters"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
'code': '''
|
|
25
|
+
action async getData() {
|
|
26
|
+
return await async_identity(42)
|
|
27
|
+
}
|
|
28
|
+
let result = getData()
|
|
29
|
+
print(core.string(result))
|
|
30
|
+
''',
|
|
31
|
+
'desc': "Async action execution"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
'code': '''
|
|
35
|
+
let obj = {x: 1}
|
|
36
|
+
obj.y = 2
|
|
37
|
+
print(core.string(obj))
|
|
38
|
+
''',
|
|
39
|
+
'desc': "Object property access/assign"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
'code': '''
|
|
43
|
+
let arr = [1,2,3]
|
|
44
|
+
let doubled = arr.map(x => x * 2)
|
|
45
|
+
print(core.string(doubled))
|
|
46
|
+
''',
|
|
47
|
+
'desc': "Array methods with arrow functions"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
'code': '''
|
|
51
|
+
try {
|
|
52
|
+
throw "oops"
|
|
53
|
+
} catch(err) {
|
|
54
|
+
print("Caught: " + core.string(err))
|
|
55
|
+
}
|
|
56
|
+
''',
|
|
57
|
+
'desc': "Try-catch error handling"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
'code': '''
|
|
61
|
+
let nums = [1,2,3,4,5]
|
|
62
|
+
let sum = nums.reduce((a,b) => a + b)
|
|
63
|
+
print(core.string(sum))
|
|
64
|
+
''',
|
|
65
|
+
'desc': "Chained method calls"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
'code': '''
|
|
69
|
+
let obj = {
|
|
70
|
+
data: {
|
|
71
|
+
users: [
|
|
72
|
+
{ name: "Alice", scores: [10, 20, 30] },
|
|
73
|
+
{ name: "Bob", scores: [15, 25, 35] }
|
|
74
|
+
],
|
|
75
|
+
settings: {
|
|
76
|
+
active: true,
|
|
77
|
+
config: {
|
|
78
|
+
theme: "dark",
|
|
79
|
+
notifications: {
|
|
80
|
+
email: true,
|
|
81
|
+
push: false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
print(core.string(obj.data.users[0].scores[1]))
|
|
88
|
+
print(core.string(obj.data.settings.config.notifications.email))
|
|
89
|
+
''',
|
|
90
|
+
'desc': "Deep nested structure access"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
import os
|
|
95
|
+
import sys
|
|
96
|
+
import time
|
|
97
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src'))
|
|
98
|
+
|
|
99
|
+
from zexus.lexer import Lexer
|
|
100
|
+
from zexus.parser import Parser, UltimateParser
|
|
101
|
+
from zexus.evaluator import evaluate
|
|
102
|
+
from zexus.object import Environment
|
|
103
|
+
from zexus.config import config
|
|
104
|
+
|
|
105
|
+
def run_test(test_case):
|
|
106
|
+
# Add import of core library
|
|
107
|
+
code = '''
|
|
108
|
+
use "zexus-core" as core
|
|
109
|
+
|
|
110
|
+
''' + test_case['code']
|
|
111
|
+
desc = test_case['desc']
|
|
112
|
+
|
|
113
|
+
print(f"\n=== Testing: {desc} ===")
|
|
114
|
+
print(f"Code:\n{code}")
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
# Start timing
|
|
118
|
+
start_time = time.time()
|
|
119
|
+
parse_start = time.time()
|
|
120
|
+
# Parse with both parsers
|
|
121
|
+
lexer = Lexer(code)
|
|
122
|
+
basic_parser = Parser(lexer)
|
|
123
|
+
basic_prog = basic_parser.parse_program()
|
|
124
|
+
|
|
125
|
+
lexer2 = Lexer(code)
|
|
126
|
+
ultimate_parser = UltimateParser(lexer2)
|
|
127
|
+
ultimate_prog = ultimate_parser.parse_program()
|
|
128
|
+
|
|
129
|
+
# Check parser outputs match
|
|
130
|
+
if str(basic_prog) != str(ultimate_prog):
|
|
131
|
+
print("⚠️ Parser output mismatch!")
|
|
132
|
+
print("Basic parser:")
|
|
133
|
+
print(basic_prog)
|
|
134
|
+
print("\nUltimate parser:")
|
|
135
|
+
print(ultimate_prog)
|
|
136
|
+
return False
|
|
137
|
+
|
|
138
|
+
parse_time = time.time() - parse_start
|
|
139
|
+
print(f"⏱️ Parsing time: {parse_time:.4f}s")
|
|
140
|
+
|
|
141
|
+
# Evaluate program
|
|
142
|
+
eval_start = time.time()
|
|
143
|
+
env = Environment()
|
|
144
|
+
config.enable_debug('minimal') # Show important logs only
|
|
145
|
+
result = evaluate(ultimate_prog, env)
|
|
146
|
+
config.disable_debug()
|
|
147
|
+
|
|
148
|
+
eval_time = time.time() - eval_start
|
|
149
|
+
total_time = time.time() - start_time
|
|
150
|
+
|
|
151
|
+
print(f"⏱️ Evaluation time: {eval_time:.4f}s")
|
|
152
|
+
print(f"⏱️ Total time: {total_time:.4f}s")
|
|
153
|
+
|
|
154
|
+
print("✅ Test passed!")
|
|
155
|
+
return True
|
|
156
|
+
|
|
157
|
+
except Exception as e:
|
|
158
|
+
print(f"❌ Test failed: {str(e)}")
|
|
159
|
+
import traceback
|
|
160
|
+
traceback.print_exc()
|
|
161
|
+
return False
|
|
162
|
+
|
|
163
|
+
def main():
|
|
164
|
+
print("🔬 Running core integration tests...")
|
|
165
|
+
failed = []
|
|
166
|
+
|
|
167
|
+
for test in CORE_TESTS:
|
|
168
|
+
if not run_test(test):
|
|
169
|
+
failed.append(test['desc'])
|
|
170
|
+
|
|
171
|
+
print("\n=== Summary ===")
|
|
172
|
+
print(f"Total tests: {len(CORE_TESTS)}")
|
|
173
|
+
print(f"Passed: {len(CORE_TESTS) - len(failed)}")
|
|
174
|
+
print(f"Failed: {len(failed)}")
|
|
175
|
+
|
|
176
|
+
if failed:
|
|
177
|
+
print("\nFailed tests:")
|
|
178
|
+
for f in failed:
|
|
179
|
+
print(f" - {f}")
|
|
180
|
+
sys.exit(1)
|
|
181
|
+
else:
|
|
182
|
+
print("\n✨ All tests passed!")
|
|
183
|
+
|
|
184
|
+
if __name__ == "__main__":
|
|
185
|
+
main()
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Zexus Phase 10: Ecosystem Test Suite
|
|
2
|
+
// Tests package management, marketplace, and profiling
|
|
3
|
+
|
|
4
|
+
// Test 1: Package registry
|
|
5
|
+
function registerPackage(name, version, metadata) {
|
|
6
|
+
print("Registering package: " + name + "@" + version);
|
|
7
|
+
return {
|
|
8
|
+
"name": name,
|
|
9
|
+
"version": version,
|
|
10
|
+
"installed": true,
|
|
11
|
+
"metadata": metadata
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Test 2: Package installation
|
|
16
|
+
function installPackage(packageName, version) {
|
|
17
|
+
print("Installing package: " + packageName + "@" + version);
|
|
18
|
+
return {
|
|
19
|
+
"name": packageName,
|
|
20
|
+
"version": version,
|
|
21
|
+
"status": "installed"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Test 3: Package dependencies
|
|
26
|
+
function resolveDependencies(packageName) {
|
|
27
|
+
print("Resolving dependencies for: " + packageName);
|
|
28
|
+
let deps = [];
|
|
29
|
+
if (packageName == "web-framework") {
|
|
30
|
+
deps = ["express", "router", "middleware"];
|
|
31
|
+
}
|
|
32
|
+
if (packageName == "database") {
|
|
33
|
+
deps = ["connection", "query", "transaction"];
|
|
34
|
+
}
|
|
35
|
+
return deps;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Test 4: Plugin marketplace
|
|
39
|
+
function searchMarketplace(query) {
|
|
40
|
+
print("Searching marketplace for: " + query);
|
|
41
|
+
let results = ["plugin1", "plugin2", "plugin3"];
|
|
42
|
+
return results;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getMarketplaceStats() {
|
|
46
|
+
print("Getting marketplace statistics");
|
|
47
|
+
return {
|
|
48
|
+
"total_plugins": 1000,
|
|
49
|
+
"total_packages": 5000,
|
|
50
|
+
"downloads_today": 50000
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Test 5: Performance profiler
|
|
55
|
+
function profileFunction(name, func) {
|
|
56
|
+
print("Profiling function: " + name);
|
|
57
|
+
// Simulate timing
|
|
58
|
+
let startTime = 0;
|
|
59
|
+
let result = func();
|
|
60
|
+
let endTime = 1000;
|
|
61
|
+
return {
|
|
62
|
+
"name": name,
|
|
63
|
+
"time_ms": endTime - startTime,
|
|
64
|
+
"result": result
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Test 6: Performance metrics
|
|
69
|
+
function recordMetric(metricName, value) {
|
|
70
|
+
print("Recording metric: " + metricName + " = " + value);
|
|
71
|
+
return {
|
|
72
|
+
"name": metricName,
|
|
73
|
+
"value": value,
|
|
74
|
+
"timestamp": 12345
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Test 7: Version management
|
|
79
|
+
function checkVersionCompatibility(required, installed) {
|
|
80
|
+
print("Checking compatibility: required=" + required + ", installed=" + installed);
|
|
81
|
+
return required == installed;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function upgradePackage(name, fromVersion, toVersion) {
|
|
85
|
+
print("Upgrading " + name + " from " + fromVersion + " to " + toVersion);
|
|
86
|
+
return {
|
|
87
|
+
"name": name,
|
|
88
|
+
"from": fromVersion,
|
|
89
|
+
"to": toVersion,
|
|
90
|
+
"status": "upgraded"
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Test 8: Package uninstall
|
|
95
|
+
function uninstallPackage(name) {
|
|
96
|
+
print("Uninstalling package: " + name);
|
|
97
|
+
return {
|
|
98
|
+
"name": name,
|
|
99
|
+
"status": "uninstalled"
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Test suite execution
|
|
104
|
+
print("Phase 10: Ecosystem Test Suite");
|
|
105
|
+
print("===============================");
|
|
106
|
+
|
|
107
|
+
// Test package registration
|
|
108
|
+
print("\nTesting package registration:");
|
|
109
|
+
let pkg1 = registerPackage("json-utils", "1.0.0", {"author": "user", "license": "MIT"});
|
|
110
|
+
print("Package registered: " + pkg1["name"]);
|
|
111
|
+
|
|
112
|
+
let pkg2 = registerPackage("crypto-lib", "2.1.0", {"author": "dev", "license": "Apache"});
|
|
113
|
+
print("Package registered: " + pkg2["name"]);
|
|
114
|
+
|
|
115
|
+
// Test package installation
|
|
116
|
+
print("\nTesting package installation:");
|
|
117
|
+
let inst1 = installPackage("lodash", "4.17.21");
|
|
118
|
+
print("Installation status: " + inst1["status"]);
|
|
119
|
+
|
|
120
|
+
let inst2 = installPackage("moment", "2.29.4");
|
|
121
|
+
print("Installation status: " + inst2["status"]);
|
|
122
|
+
|
|
123
|
+
// Test dependency resolution
|
|
124
|
+
print("\nTesting dependency resolution:");
|
|
125
|
+
let deps1 = resolveDependencies("web-framework");
|
|
126
|
+
print("Dependencies: " + deps1);
|
|
127
|
+
|
|
128
|
+
let deps2 = resolveDependencies("database");
|
|
129
|
+
print("Dependencies: " + deps2);
|
|
130
|
+
|
|
131
|
+
// Test marketplace search
|
|
132
|
+
print("\nTesting marketplace search:");
|
|
133
|
+
let results = searchMarketplace("parser");
|
|
134
|
+
print("Search results: " + results);
|
|
135
|
+
|
|
136
|
+
let results2 = searchMarketplace("compiler");
|
|
137
|
+
print("Search results: " + results2);
|
|
138
|
+
|
|
139
|
+
// Test marketplace stats
|
|
140
|
+
print("\nTesting marketplace statistics:");
|
|
141
|
+
let stats = getMarketplaceStats();
|
|
142
|
+
print("Total plugins: " + stats["total_plugins"]);
|
|
143
|
+
print("Total packages: " + stats["total_packages"]);
|
|
144
|
+
print("Downloads today: " + stats["downloads_today"]);
|
|
145
|
+
|
|
146
|
+
// Test performance profiling
|
|
147
|
+
print("\nTesting performance profiling:");
|
|
148
|
+
let prof1 = profileFunction("quicksort", function() {
|
|
149
|
+
return "sorted";
|
|
150
|
+
});
|
|
151
|
+
print("Function profiled: " + prof1["name"] + " took " + prof1["time_ms"] + "ms");
|
|
152
|
+
|
|
153
|
+
let prof2 = profileFunction("fibonacci", function() {
|
|
154
|
+
return 100;
|
|
155
|
+
});
|
|
156
|
+
print("Function profiled: " + prof2["name"] + " returned " + prof2["result"]);
|
|
157
|
+
|
|
158
|
+
// Test performance metrics
|
|
159
|
+
print("\nTesting performance metrics:");
|
|
160
|
+
recordMetric("cpu_usage", 45.5);
|
|
161
|
+
recordMetric("memory_usage", 512);
|
|
162
|
+
recordMetric("disk_io", 1024);
|
|
163
|
+
|
|
164
|
+
// Test version management
|
|
165
|
+
print("\nTesting version management:");
|
|
166
|
+
checkVersionCompatibility("1.0.0", "1.0.0");
|
|
167
|
+
checkVersionCompatibility("2.0.0", "1.5.0");
|
|
168
|
+
|
|
169
|
+
let upgrade = upgradePackage("framework", "1.0.0", "2.0.0");
|
|
170
|
+
print("Upgrade result: " + upgrade["status"]);
|
|
171
|
+
|
|
172
|
+
// Test package uninstall
|
|
173
|
+
print("\nTesting package uninstall:");
|
|
174
|
+
let uninstall = uninstallPackage("old-plugin");
|
|
175
|
+
print("Uninstall status: " + uninstall["status"]);
|
|
176
|
+
|
|
177
|
+
print("\n✓ All ecosystem tests completed");
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Zexus Phase 1: Modifiers Test Suite
|
|
2
|
+
// Tests semantic tagging of code elements
|
|
3
|
+
|
|
4
|
+
// Test 1: Basic modifier attachment
|
|
5
|
+
inline function add(a, b) {
|
|
6
|
+
return a + b;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Test 2: Multiple modifiers
|
|
10
|
+
pure function fibonacci(n) {
|
|
11
|
+
if (n <= 1) {
|
|
12
|
+
return n;
|
|
13
|
+
}
|
|
14
|
+
return fibonacci(n - 1) + fibonacci(n - 2);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Test 3: Async modifier (simulated)
|
|
18
|
+
// In real execution, would run in background
|
|
19
|
+
async function slowComputation() {
|
|
20
|
+
let result = 0;
|
|
21
|
+
let i = 0;
|
|
22
|
+
while (i < 100000) {
|
|
23
|
+
result = result + i;
|
|
24
|
+
i = i + 1;
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Test 4: Secure modifier for sensitive operations
|
|
30
|
+
secure function encryptData(data) {
|
|
31
|
+
// Simulated encryption
|
|
32
|
+
return data + "_encrypted";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Test 5: Native modifier (system-level operation)
|
|
36
|
+
native function systemCall() {
|
|
37
|
+
// This would call native code
|
|
38
|
+
return "system_result";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Test 6: Sealed modifier (cannot be overridden)
|
|
42
|
+
sealed function baseImplementation() {
|
|
43
|
+
return 42;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Test 7: Public modifier (default visibility)
|
|
47
|
+
public function publicAPI() {
|
|
48
|
+
return "public";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Test 8: Private modifier (not exported)
|
|
52
|
+
private function privateHelper() {
|
|
53
|
+
return "private";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Test suite execution
|
|
57
|
+
print("Phase 1: Modifiers Test Suite");
|
|
58
|
+
print("==============================");
|
|
59
|
+
|
|
60
|
+
// Test inline function
|
|
61
|
+
let result1 = add(5, 3);
|
|
62
|
+
print("Inline add(5, 3) = " + result1);
|
|
63
|
+
|
|
64
|
+
// Test pure function
|
|
65
|
+
let result2 = fibonacci(5);
|
|
66
|
+
print("Pure fibonacci(5) = " + result2);
|
|
67
|
+
|
|
68
|
+
// Test async function
|
|
69
|
+
let result3 = slowComputation();
|
|
70
|
+
print("Async computation result = " + result3);
|
|
71
|
+
|
|
72
|
+
// Test secure function
|
|
73
|
+
let result4 = encryptData("secret");
|
|
74
|
+
print("Secure encrypt = " + result4);
|
|
75
|
+
|
|
76
|
+
// Test sealed function
|
|
77
|
+
let result5 = baseImplementation();
|
|
78
|
+
print("Sealed base = " + result5);
|
|
79
|
+
|
|
80
|
+
// Test public/private functions
|
|
81
|
+
let result6 = publicAPI();
|
|
82
|
+
print("Public API = " + result6);
|
|
83
|
+
|
|
84
|
+
let result7 = privateHelper();
|
|
85
|
+
print("Private helper = " + result7);
|
|
86
|
+
|
|
87
|
+
print("✓ All modifier tests completed");
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Zexus Phase 2: Plugin System Test Suite
|
|
2
|
+
// Tests plugin hooks and extensibility
|
|
3
|
+
|
|
4
|
+
// Test 1: Hook-like function definitions
|
|
5
|
+
function hookListener(eventName) {
|
|
6
|
+
print("Hook: " + eventName + " triggered");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Test 2: Event emitter simulation
|
|
10
|
+
function emitEvent(eventName, data) {
|
|
11
|
+
print("Emitting event: " + eventName + " with data: " + data);
|
|
12
|
+
hookListener(eventName);
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Test 3: Plugin system with callbacks
|
|
17
|
+
function registerPlugin(pluginName, callback) {
|
|
18
|
+
print("Plugin registered: " + pluginName);
|
|
19
|
+
return callback();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Test 4: Before/After hooks
|
|
23
|
+
function beforeHook(functionName) {
|
|
24
|
+
print("Before hook: executing " + functionName);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function afterHook(functionName, result) {
|
|
28
|
+
print("After hook: " + functionName + " returned " + result);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function executeWithHooks(name, operation) {
|
|
32
|
+
beforeHook(name);
|
|
33
|
+
let result = operation();
|
|
34
|
+
afterHook(name, result);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Test 5: Plugin capability checks
|
|
39
|
+
function checkCapability(capability) {
|
|
40
|
+
print("Checking capability: " + capability);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Test suite execution
|
|
45
|
+
print("Phase 2: Plugin System Test Suite");
|
|
46
|
+
print("=================================");
|
|
47
|
+
|
|
48
|
+
// Test event emission
|
|
49
|
+
print("\nTesting event emission:");
|
|
50
|
+
emitEvent("init", 42);
|
|
51
|
+
emitEvent("process", "data");
|
|
52
|
+
|
|
53
|
+
// Test plugin registration
|
|
54
|
+
print("\nTesting plugin registration:");
|
|
55
|
+
registerPlugin("logging", function() {
|
|
56
|
+
print("Logging plugin initialized");
|
|
57
|
+
return 1;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
registerPlugin("caching", function() {
|
|
61
|
+
print("Caching plugin initialized");
|
|
62
|
+
return 2;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Test hooks
|
|
66
|
+
print("\nTesting before/after hooks:");
|
|
67
|
+
let hookResult = executeWithHooks("testFunc", function() {
|
|
68
|
+
print("Executing main function");
|
|
69
|
+
return 99;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
print("Hook execution result: " + hookResult);
|
|
73
|
+
|
|
74
|
+
// Test capability checks
|
|
75
|
+
print("\nTesting capability checks:");
|
|
76
|
+
checkCapability("io.read");
|
|
77
|
+
checkCapability("io.write");
|
|
78
|
+
checkCapability("network.access");
|
|
79
|
+
|
|
80
|
+
print("\n✓ All plugin system tests completed");
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Zexus Phase 3: Capability Security Test Suite
|
|
2
|
+
// Tests fine-grained access control
|
|
3
|
+
|
|
4
|
+
// Test 1: Permission checking function
|
|
5
|
+
function checkPermission(capability) {
|
|
6
|
+
print("Checking permission: " + capability);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Test 2: Access control wrapper
|
|
11
|
+
function requireCapability(cap, operation) {
|
|
12
|
+
if (checkPermission(cap)) {
|
|
13
|
+
print("Capability granted: " + cap);
|
|
14
|
+
return operation();
|
|
15
|
+
} else {
|
|
16
|
+
print("Capability denied: " + cap);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Test 3: File I/O with capability checks
|
|
22
|
+
function readFile(filename) {
|
|
23
|
+
print("Read capability check for: " + filename);
|
|
24
|
+
return "file_contents";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function writeFile(filename, content) {
|
|
28
|
+
print("Write capability check for: " + filename);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Test 4: Network operations with capabilities
|
|
33
|
+
function httpRequest(url) {
|
|
34
|
+
print("Network capability check for: " + url);
|
|
35
|
+
return "response";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Test 5: Dangerous operations
|
|
39
|
+
function executeCommand(cmd) {
|
|
40
|
+
print("Executing with capability check: " + cmd);
|
|
41
|
+
return "command_output";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Test 6: Selective permission granting
|
|
45
|
+
function createRestrictedContext() {
|
|
46
|
+
print("Creating restricted execution context");
|
|
47
|
+
let permissions = {
|
|
48
|
+
"io.read": true,
|
|
49
|
+
"io.write": false,
|
|
50
|
+
"network": false,
|
|
51
|
+
"execute": false
|
|
52
|
+
};
|
|
53
|
+
return permissions;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Test suite execution
|
|
57
|
+
print("Phase 3: Capability Security Test Suite");
|
|
58
|
+
print("========================================");
|
|
59
|
+
|
|
60
|
+
// Test basic permission checks
|
|
61
|
+
print("\nTesting basic permissions:");
|
|
62
|
+
checkPermission("core.language");
|
|
63
|
+
checkPermission("io.read");
|
|
64
|
+
checkPermission("io.write");
|
|
65
|
+
|
|
66
|
+
// Test with operations
|
|
67
|
+
print("\nTesting capability-gated operations:");
|
|
68
|
+
requireCapability("io.read", function() {
|
|
69
|
+
print("Reading file with permission");
|
|
70
|
+
return readFile("test.txt");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
requireCapability("io.write", function() {
|
|
74
|
+
print("Writing file with permission");
|
|
75
|
+
return writeFile("output.txt", "data");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Test network operations
|
|
79
|
+
print("\nTesting network operations:");
|
|
80
|
+
requireCapability("network.access", function() {
|
|
81
|
+
return httpRequest("https://example.com");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Test dangerous operations
|
|
85
|
+
print("\nTesting dangerous operations:");
|
|
86
|
+
requireCapability("system.execute", function() {
|
|
87
|
+
return executeCommand("ls -la");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Test restricted context
|
|
91
|
+
print("\nTesting restricted context:");
|
|
92
|
+
let context = createRestrictedContext();
|
|
93
|
+
print("Context has io.read: " + context["io.read"]);
|
|
94
|
+
print("Context has io.write: " + context["io.write"]);
|
|
95
|
+
print("Context has network: " + context["network"]);
|
|
96
|
+
|
|
97
|
+
print("\n✓ All capability security tests completed");
|