-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix eval(<non‑string>)
and eval.length
#306
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,26 @@ test('degenerate-pattern-match-argument', t => { | |
t.end(); | ||
}); | ||
|
||
test('eval-own-properties', t => { | ||
const r = Realm.makeRootRealm(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn’t exist any more. This might be a hard rebase. |
||
|
||
const evalFunc = r.global.eval; | ||
t.equal(evalFunc.name, 'eval', 'eval.name === "eval"'); | ||
t.equal(evalFunc.length, 1, 'eval.length === 1'); | ||
t.equal( | ||
Object.getOwnPropertyDescriptor(evalFunc, 'prototype'), | ||
undefined, | ||
'eval.prototype === undefined' | ||
); | ||
t.equal( | ||
evalFunc.toString(), | ||
'function eval() { [shim code] }', | ||
'eval.toString()' | ||
); | ||
|
||
t.end(); | ||
}); | ||
|
||
test('frozen-eval', t => { | ||
const r = Realm.makeRootRealm(); | ||
|
||
|
@@ -174,7 +194,15 @@ test('frozen-eval', t => { | |
desc.configurable = false; | ||
Object.defineProperty(r.global, 'eval', desc); | ||
|
||
t.equal(r.evaluate('(0,eval)(1)'), 1); | ||
t.equal(r.evaluate('(0,eval)("1")'), 1); | ||
t.equal( | ||
r.evaluate(`\ | ||
const sym = Symbol("foo"); | ||
(0,eval)(sym) === sym; | ||
`), | ||
true, | ||
'eval(<non-string>) returns <non-string>' | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So much time has passed, we will probably want a test that verifies the immutability of the |
||
|
||
t.end(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth making explicit that this property is non-writable, non-enumerable, and non-configurable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property has the defaults of
{ writeable: false, enumerable: false, configurable: true }
, as it’s defined by ECMAScript: