-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: do not report node-related error
- Loading branch information
Laurent Christophe
committed
Apr 28, 2024
1 parent
5450135
commit f93fa1b
Showing
2 changed files
with
16 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,189 +1,13 @@ | ||
"use strict"; | ||
globalThis._ARAN_INTRINSIC_ = { | ||
"__proto__": null, | ||
"aran.global": globalThis, | ||
"aran.templates": { | ||
__proto__: null, | ||
}, | ||
"aran.record": { | ||
__proto__: null, | ||
}, | ||
"aran.unary": (operator, argument) => { | ||
switch (operator) { | ||
case "+": | ||
return +argument; | ||
case "-": | ||
return -argument; | ||
case "~": | ||
return ~argument; | ||
case "!": | ||
return !argument; | ||
case "typeof": | ||
return typeof argument; | ||
case "void": | ||
return void argument; | ||
case "delete": | ||
return true; | ||
} | ||
}, | ||
"aran.binary": (operator, left, right) => { | ||
switch (operator) { | ||
case "==": | ||
return left == right; | ||
case "!=": | ||
return left != right; | ||
case "===": | ||
return left === right; | ||
case "!==": | ||
return left !== right; | ||
case "<": | ||
return left < right; | ||
case "<=": | ||
return left <= right; | ||
case ">": | ||
return left > right; | ||
case ">=": | ||
return left >= right; | ||
case "<<": | ||
return left << right; | ||
case ">>": | ||
return left >> right; | ||
case ">>>": | ||
return left >>> right; | ||
case "+": | ||
return left + right; | ||
case "-": | ||
return left - right; | ||
case "*": | ||
return left * right; | ||
case "/": | ||
return left / right; | ||
case "%": | ||
return left % right; | ||
case "|": | ||
return left | right; | ||
case "^": | ||
return left ^ right; | ||
case "&": | ||
return left & right; | ||
case "in": | ||
return left in right; | ||
case "instanceof": | ||
return left instanceof right; | ||
case "**": | ||
return left ** right; | ||
} | ||
}, | ||
"aran.throw": (error) => { | ||
throw error; | ||
}, | ||
"aran.get": (object, key) => object[key], | ||
"aran.deadzone": globalThis.Symbol("deadzone"), | ||
"aran.listRest": ((apply) => (iterator, next) => { | ||
const rest = []; | ||
let step = apply(next, iterator, []); | ||
let index = 0; | ||
while (!step.done) { | ||
rest[index] = step.value; | ||
index = index + 1; | ||
step = apply(next, iterator, []); | ||
} | ||
return rest; | ||
})(globalThis.Reflect.apply), | ||
"aran.listForInKey": (target) => { | ||
let length = 0; | ||
const keys = []; | ||
for (const key in target) keys[length++] = key; | ||
return keys; | ||
}, | ||
"aran.toPropertyKey": ( | ||
(listKey) => (key) => | ||
listKey({ | ||
__proto__: null, | ||
[key]: null, | ||
})[0] | ||
)(globalThis.Reflect.ownKeys), | ||
"aran.AsyncGeneratorFunction.prototype.prototype": | ||
globalThis.Reflect.getPrototypeOf(async function* () {}.prototype), | ||
"aran.GeneratorFunction.prototype.prototype": | ||
globalThis.Reflect.getPrototypeOf(function* () {}.prototype), | ||
"globalThis": globalThis.globalThis, | ||
"Object": globalThis.Object, | ||
"Object.hasOwn": globalThis.Object.hasOwn, | ||
"Reflect.defineProperty": globalThis.Reflect.defineProperty, | ||
"eval": globalThis.eval, | ||
"Symbol": globalThis.Symbol, | ||
"Symbol.prototype.description@get": | ||
globalThis.Reflect.getOwnPropertyDescriptor( | ||
globalThis.Symbol.prototype, | ||
"description", | ||
).get, | ||
"Symbol.unscopables": globalThis.Symbol.unscopables, | ||
"Symbol.asyncIterator": globalThis.Symbol.asyncIterator, | ||
"Symbol.iterator": globalThis.Symbol.iterator, | ||
"Symbol.toStringTag": globalThis.Symbol.toStringTag, | ||
"Symbol.isConcatSpreadable": globalThis.Symbol.isConcatSpreadable, | ||
"Function.prototype": globalThis.Function.prototype, | ||
"Function.prototype.arguments@get": | ||
globalThis.Reflect.getOwnPropertyDescriptor( | ||
globalThis.Function.prototype, | ||
"arguments", | ||
).get, | ||
"Function.prototype.arguments@set": | ||
globalThis.Reflect.getOwnPropertyDescriptor( | ||
globalThis.Function.prototype, | ||
"arguments", | ||
).set, | ||
"Array.prototype.values": globalThis.Array.prototype.values, | ||
"Object.prototype": globalThis.Object.prototype, | ||
"String": globalThis.String, | ||
"Number": globalThis.Number, | ||
"Array.from": globalThis.Array.from, | ||
"Array.prototype.flat": globalThis.Array.prototype.flat, | ||
"String.prototype.concat": globalThis.String.prototype.concat, | ||
"Object.create": globalThis.Object.create, | ||
"Array.of": globalThis.Array.of, | ||
"Proxy": globalThis.Proxy, | ||
"RegExp": globalThis.RegExp, | ||
"TypeError": globalThis.TypeError, | ||
"ReferenceError": globalThis.ReferenceError, | ||
"SyntaxError": globalThis.SyntaxError, | ||
"Reflect.get": globalThis.Reflect.get, | ||
"Reflect.has": globalThis.Reflect.has, | ||
"Reflect.construct": globalThis.Reflect.construct, | ||
"Reflect.apply": globalThis.Reflect.apply, | ||
"Reflect.setProtoypeOf": globalThis.Reflect.setProtoypeOf, | ||
"Reflect.getPrototypeOf": globalThis.Reflect.getPrototypeOf, | ||
"Reflect.ownKeys": globalThis.Reflect.ownKeys, | ||
"Reflect.isExtensible": globalThis.Reflect.isExtensible, | ||
"Object.keys": globalThis.Object.keys, | ||
"Array.prototype.concat": globalThis.Array.prototype.concat, | ||
"Array.prototype.includes": globalThis.Array.prototype.includes, | ||
"Array.prototype.slice": globalThis.Array.prototype.slice, | ||
"Reflect.set": globalThis.Reflect.set, | ||
"Reflect.deleteProperty": globalThis.Reflect.deleteProperty, | ||
"Reflect.setPrototypeOf": globalThis.Reflect.setPrototypeOf, | ||
"Reflect.getOwnPropertyDescriptor": | ||
globalThis.Reflect.getOwnPropertyDescriptor, | ||
"Reflect.preventExtensions": globalThis.Reflect.preventExtensions, | ||
"Object.fromEntries": globalThis.Object.fromEntries, | ||
"Object.entries": globalThis.Object.entries, | ||
"Object.assign": globalThis.Object.assign, | ||
"Object.freeze": globalThis.Object.freeze, | ||
"Object.defineProperty": globalThis.Object.defineProperty, | ||
"Object.setPrototypeOf": globalThis.Object.setPrototypeOf, | ||
"Object.preventExtensions": globalThis.Object.preventExtensions, | ||
"Array.prototype.fill": globalThis.Array.prototype.fill, | ||
"Array.prototype.push": globalThis.Array.prototype.push, | ||
"WeakMap": globalThis.WeakMap, | ||
"WeakMap.prototype.get": globalThis.WeakMap.prototype.get, | ||
"WeakMap.prototype.set": globalThis.WeakMap.prototype.set, | ||
"WeakMap.prototype.has": globalThis.WeakMap.prototype.has, | ||
"WeakSet": globalThis.WeakSet, | ||
"WeakSet.prototype.add": globalThis.WeakSet.prototype.add, | ||
"WeakSet.prototype.has": globalThis.WeakSet.prototype.has, | ||
"Map": globalThis.Map, | ||
"Map.prototype.has": globalThis.Map.prototype.has, | ||
"Map.prototype.get": globalThis.Map.prototype.get, | ||
"Map.prototype.set": globalThis.Map.prototype.set, | ||
}; | ||
import { createContext, runInContext } from "vm"; | ||
runInContext( | ||
` | ||
"use strict"; | ||
Reflect.defineProperty(globalThis, "FOO", { | ||
get: () => { | ||
throw new Error("This should not get triggered"); | ||
}, | ||
}); | ||
Reflect.has(globalThis, "FOO"); | ||
`, | ||
createContext(), | ||
); |