A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/767e88cbc3 below:

unwrap WebAssembly.Global on Wasm Namespaces · nodejs/node@767e88c · GitHub

@@ -52,7 +52,154 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>

52 52

[

53 53

'import { strictEqual } from "node:assert";',

54 54

`import * as wasmExports from ${JSON.stringify(fixtures.fileURL('es-modules/export-name-syntax-error.wasm'))};`,

55 -

'assert.strictEqual(wasmExports["?f!o:o<b>a[r]"]?.value, 12682);',

55 +

'assert.strictEqual(wasmExports["?f!o:o<b>a[r]"], 12682);',

56 +

].join('\n'),

57 +

]);

58 + 59 +

strictEqual(stderr, '');

60 +

strictEqual(stdout, '');

61 +

strictEqual(code, 0);

62 +

});

63 + 64 +

it('should properly handle all WebAssembly global types', async () => {

65 +

const { code, stderr, stdout } = await spawnPromisified(execPath, [

66 +

'--no-warnings',

67 +

'--experimental-wasm-modules',

68 +

'--input-type=module',

69 +

'--eval',

70 +

[

71 +

'import { strictEqual, deepStrictEqual, ok } from "node:assert";',

72 + 73 +

// SIMD is not supported on rhel8-ppc64le

74 +

'let wasmExports;',

75 +

'try {',

76 +

` wasmExports = await import(${JSON.stringify(fixtures.fileURL('es-modules/globals.wasm'))});`,

77 +

'} catch (e) {',

78 +

' ok(e instanceof WebAssembly.CompileError);',

79 +

' ok(e.message.includes("SIMD unsupported"));',

80 +

'}',

81 + 82 +

'if (wasmExports) {',

83 + 84 +

// Test imported globals using direct access

85 +

' strictEqual(wasmExports.importedI32, 42);',

86 +

' strictEqual(wasmExports.importedMutI32, 100);',

87 +

' strictEqual(wasmExports.importedI64, 9223372036854775807n);',

88 +

' strictEqual(wasmExports.importedMutI64, 200n);',

89 +

' strictEqual(Math.round(wasmExports.importedF32 * 100000) / 100000, 3.14159);',

90 +

' strictEqual(Math.round(wasmExports.importedMutF32 * 100000) / 100000, 2.71828);',

91 +

' strictEqual(wasmExports.importedF64, 3.141592653589793);',

92 +

' strictEqual(wasmExports.importedMutF64, 2.718281828459045);',

93 +

' strictEqual(wasmExports.importedExternref !== null, true);',

94 +

' strictEqual(wasmExports.importedMutExternref !== null, true);',

95 +

' strictEqual(wasmExports.importedNullExternref, null);',

96 + 97 +

// Test local globals exported directly

98 +

' strictEqual(wasmExports[\'🚀localI32\'], 42);',

99 +

' strictEqual(wasmExports.localMutI32, 100);',

100 +

' strictEqual(wasmExports.localI64, 9223372036854775807n);',

101 +

' strictEqual(wasmExports.localMutI64, 200n);',

102 +

' strictEqual(Math.round(wasmExports.localF32 * 100000) / 100000, 3.14159);',

103 +

' strictEqual(Math.round(wasmExports.localMutF32 * 100000) / 100000, 2.71828);',

104 +

' strictEqual(wasmExports.localF64, 2.718281828459045);',

105 +

' strictEqual(wasmExports.localMutF64, 3.141592653589793);',

106 + 107 +

// Test imported globals using getter functions

108 +

' strictEqual(wasmExports.getImportedMutI32(), 100);',

109 +

' strictEqual(wasmExports.getImportedMutI64(), 200n);',

110 +

' strictEqual(Math.round(wasmExports.getImportedMutF32() * 100000) / 100000, 2.71828);',

111 +

' strictEqual(wasmExports.getImportedMutF64(), 2.718281828459045);',

112 +

' strictEqual(wasmExports.getImportedMutExternref() !== null, true);',

113 + 114 +

// Test local globals using getter functions

115 +

' strictEqual(wasmExports.getLocalMutI32(), 100);',

116 +

' strictEqual(wasmExports.getLocalMutI64(), 200n);',

117 +

' strictEqual(Math.round(wasmExports.getLocalMutF32() * 100000) / 100000, 2.71828);',

118 +

' strictEqual(wasmExports.getLocalMutF64(), 3.141592653589793);',

119 +

' strictEqual(wasmExports.getLocalMutExternref(), null);',

120 + 121 +

' assert.throws(wasmExports.getLocalMutV128);',

122 + 123 +

// Pending TDZ support

124 +

' strictEqual(wasmExports.depV128, undefined);',

125 + 126 +

// Test modifying mutable globals and reading the new values

127 +

' wasmExports.setImportedMutI32(999);',

128 +

' strictEqual(wasmExports.getImportedMutI32(), 999);',

129 + 130 +

' wasmExports.setImportedMutI64(888n);',

131 +

' strictEqual(wasmExports.getImportedMutI64(), 888n);',

132 + 133 +

' wasmExports.setImportedMutF32(7.77);',

134 +

' strictEqual(Math.round(wasmExports.getImportedMutF32() * 100) / 100, 7.77);',

135 + 136 +

' wasmExports.setImportedMutF64(6.66);',

137 +

' strictEqual(wasmExports.getImportedMutF64(), 6.66);',

138 + 139 +

// Test modifying mutable externref

140 +

' const testObj = { test: "object" };',

141 +

' wasmExports.setImportedMutExternref(testObj);',

142 +

' strictEqual(wasmExports.getImportedMutExternref(), testObj);',

143 + 144 +

// Test modifying local mutable globals

145 +

' wasmExports.setLocalMutI32(555);',

146 +

' strictEqual(wasmExports.getLocalMutI32(), 555);',

147 + 148 +

' wasmExports.setLocalMutI64(444n);',

149 +

' strictEqual(wasmExports.getLocalMutI64(), 444n);',

150 + 151 +

' wasmExports.setLocalMutF32(3.33);',

152 +

' strictEqual(Math.round(wasmExports.getLocalMutF32() * 100) / 100, 3.33);',

153 + 154 +

' wasmExports.setLocalMutF64(2.22);',

155 +

' strictEqual(wasmExports.getLocalMutF64(), 2.22);',

156 + 157 +

// These mutating pending live bindings support

158 +

' strictEqual(wasmExports.localMutI32, 100);',

159 +

' strictEqual(wasmExports.localMutI64, 200n);',

160 +

' strictEqual(Math.round(wasmExports.localMutF32 * 100) / 100, 2.72);',

161 +

' strictEqual(wasmExports.localMutF64, 3.141592653589793);',

162 + 163 +

// Test modifying local mutable externref

164 +

' const anotherTestObj = { another: "test object" };',

165 +

' wasmExports.setLocalMutExternref(anotherTestObj);',

166 +

' strictEqual(wasmExports.getLocalMutExternref(), anotherTestObj);',

167 +

' strictEqual(wasmExports.localMutExternref, null);',

168 + 169 +

// Test dep.wasm imports

170 +

' strictEqual(wasmExports.depI32, 1001);',

171 +

' strictEqual(wasmExports.depMutI32, 2001);',

172 +

' strictEqual(wasmExports.getDepMutI32(), 2001);',

173 +

' strictEqual(wasmExports.depI64, 10000000001n);',

174 +

' strictEqual(wasmExports.depMutI64, 20000000001n);',

175 +

' strictEqual(wasmExports.getDepMutI64(), 20000000001n);',

176 +

' strictEqual(Math.round(wasmExports.depF32 * 100) / 100, 10.01);',

177 +

' strictEqual(Math.round(wasmExports.depMutF32 * 100) / 100, 20.01);',

178 +

' strictEqual(Math.round(wasmExports.getDepMutF32() * 100) / 100, 20.01);',

179 +

' strictEqual(wasmExports.depF64, 100.0001);',

180 +

' strictEqual(wasmExports.depMutF64, 200.0001);',

181 +

' strictEqual(wasmExports.getDepMutF64(), 200.0001);',

182 + 183 +

// Test modifying dep.wasm mutable globals

184 +

' wasmExports.setDepMutI32(3001);',

185 +

' strictEqual(wasmExports.getDepMutI32(), 3001);',

186 + 187 +

' wasmExports.setDepMutI64(30000000001n);',

188 +

' strictEqual(wasmExports.getDepMutI64(), 30000000001n);',

189 + 190 +

' wasmExports.setDepMutF32(30.01);',

191 +

' strictEqual(Math.round(wasmExports.getDepMutF32() * 100) / 100, 30.01);',

192 + 193 +

' wasmExports.setDepMutF64(300.0001);',

194 +

' strictEqual(wasmExports.getDepMutF64(), 300.0001);',

195 + 196 +

// These pending live bindings support

197 +

' strictEqual(wasmExports.depMutI32, 2001);',

198 +

' strictEqual(wasmExports.depMutI64, 20000000001n);',

199 +

' strictEqual(Math.round(wasmExports.depMutF32 * 100) / 100, 20.01);',

200 +

' strictEqual(wasmExports.depMutF64, 200.0001);',

201 + 202 +

'}',

56 203

].join('\n'),

57 204

]);

58 205

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4