-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-wasm.html
More file actions
112 lines (99 loc) · 4.34 KB
/
test-wasm.html
File metadata and controls
112 lines (99 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WASM Test</title>
<style>
body {
font-family: monospace;
background: #0d1117;
color: #c9d1d9;
padding: 2rem;
}
pre { background: #161b22; padding: 1rem; border-radius: 4px; overflow-x: auto; }
.success { color: #3fb950; }
.error { color: #f85149; }
</style>
</head>
<body>
<h1>🧪 WASM Module Test</h1>
<pre id="output"></pre>
<script src="lib/agle_wasm.js"></script>
<script>
const output = document.getElementById('output');
function log(msg) {
console.log(msg);
const line = document.createElement('div');
if (msg.includes('✓')) {
line.innerHTML = msg.replace(/✓/g, '<span class="success">✓</span>');
} else if (msg.includes('✗')) {
line.innerHTML = msg.replace(/✗/g, '<span class="error">✗</span>');
} else {
line.textContent = msg;
}
output.appendChild(line);
}
(async () => {
try {
log('=== WASM Module Diagnostics ===');
log('');
log('📋 Environment:');
log(` window.location.href = ${window.location.href}`);
log(` typeof WebAssembly = ${typeof WebAssembly}`);
log(` typeof fetch = ${typeof fetch}`);
log('');
log('🔍 Module Status:');
log(` typeof window.AGLEWasm = ${typeof window.AGLEWasm}`);
if (typeof window.AGLEWasm !== 'undefined') {
log(` typeof AGLEWasm.init = ${typeof window.AGLEWasm.init}`);
log('');
log('⏳ Initializing WASM...');
const adapter = await window.AGLEWasm.init();
if (!adapter) {
log('✗ AGLEWasm.init() returned null/falsy');
log(' This usually means fetch failed or WebAssembly.instantiate failed');
return;
}
log('✓ AGLEWasm.init() succeeded');
log(` Adapter keys: ${Object.keys(adapter).sort().join(', ')}`);
// Test getBytes
if (adapter.getBytes) {
try {
const bytes = adapter.getBytes(8);
const hexStr = Array.from(bytes)
.map(b => b.toString(16).padStart(2, '0'))
.join(' ');
log(`✓ getBytes(8) = ${hexStr}`);
} catch (e) {
log(`✗ getBytes() failed: ${e.message}`);
}
}
// Test fpError
if (adapter.fpError || adapter.agle_fp_error_raw) {
try {
const fpFunc = adapter.fpError || adapter.agle_fp_error_raw;
const errors = [];
for (let i = 0; i < 5; i++) {
errors.push(fpFunc(Math.random()));
}
log(`✓ agle_fp_error_raw() works`);
log(` Sample errors: ${errors.map(e => e.toExponential(2)).join(', ')}`);
} catch (e) {
log(`✗ fpError() failed: ${e.message}`);
}
} else {
log('✗ fpError/agle_fp_error_raw not found in adapter');
}
} else {
log('✗ window.AGLEWasm is not defined');
log(' Check that <script src="lib/agle_wasm.js"></script> is loaded');
}
} catch (e) {
log(`✗ Fatal error: ${e.message}`);
log(e.stack);
}
})();
</script>
</body>
</html>