mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 02:05:07 +00:00

https://tc39.es/ecma262/#sec-directive-prologues-and-the-use-strict-directive A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either of the exact code point sequences "use strict" or 'use strict'. A Use Strict Directive may not contain an EscapeSequence or LineContinuation.
48 lines
972 B
JavaScript
48 lines
972 B
JavaScript
test("valid 'use strict; directive", () => {
|
|
expect(
|
|
(() => {
|
|
"use strict";
|
|
return isStrictMode();
|
|
})()
|
|
).toBeTrue();
|
|
expect(
|
|
(() => {
|
|
'use strict';
|
|
return isStrictMode();
|
|
})()
|
|
).toBeTrue();
|
|
});
|
|
|
|
test("invalid 'use strict; directive", () => {
|
|
expect(
|
|
(() => {
|
|
" use strict ";
|
|
return isStrictMode();
|
|
})()
|
|
).toBeFalse();
|
|
expect(
|
|
(() => {
|
|
`use strict`;
|
|
return isStrictMode();
|
|
})()
|
|
).toBeFalse();
|
|
expect(
|
|
(() => {
|
|
"use\
|
|
strict";
|
|
return isStrictMode();
|
|
})()
|
|
).toBeFalse();
|
|
expect(
|
|
(() => {
|
|
"use\ strict";
|
|
return isStrictMode();
|
|
})()
|
|
).toBeFalse();
|
|
expect(
|
|
(() => {
|
|
"use \163trict";
|
|
return isStrictMode();
|
|
})()
|
|
).toBeFalse();
|
|
});
|