OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
969 | 969 |
970 function nonstrict(a, b) { | 970 function nonstrict(a, b) { |
971 a = "c"; | 971 a = "c"; |
972 b = "d"; | 972 b = "d"; |
973 return [a, b, arguments[0], arguments[1]]; | 973 return [a, b, arguments[0], arguments[1]]; |
974 } | 974 } |
975 | 975 |
976 assertEquals(["c", "d", "a", "b"], strict("a", "b")); | 976 assertEquals(["c", "d", "a", "b"], strict("a", "b")); |
977 assertEquals(["c", "d", "c", "d"], nonstrict("a", "b")); | 977 assertEquals(["c", "d", "c", "d"], nonstrict("a", "b")); |
978 })(); | 978 })(); |
979 | |
980 | |
981 (function TestStrictFunctionPills() { | |
982 function strict() { | |
983 "use strict"; | |
984 } | |
985 assertThrows(function() { strict.caller; }, TypeError); | |
986 assertThrows(function() { strict.arguments; }, TypeError); | |
987 | |
988 var another = new Function("'use strict'"); | |
989 assertThrows(function() { another.caller; }, TypeError); | |
990 assertThrows(function() { another.arguments; }, TypeError); | |
991 | |
Lasse Reichstein
2011/03/14 12:20:15
How about an inherited strictness:
var athird =
Martin Maly
2011/03/14 16:39:26
Done.
| |
992 function CheckPill(pill) { | |
993 assertEquals("function", typeof pill); | |
994 assertInstanceof(pill, Function); | |
995 assertThrows(function() { pill.property = "value"; }, TypeError); | |
996 assertThrows(pill, TypeError); | |
Lasse Reichstein
2011/03/14 12:20:15
Should you check whether it has a .prototype prope
Martin Maly
2011/03/14 16:39:26
Good suggestion. Turns out there was a bug here. A
| |
997 } | |
998 | |
999 function CheckPillDescriptor(func, name) { | |
1000 var descriptor = Object.getOwnPropertyDescriptor(func, name); | |
1001 CheckPill(descriptor.get) | |
1002 CheckPill(descriptor.set); | |
1003 assertEquals(false, descriptor.enumerable); | |
1004 assertEquals(false, descriptor.configurable); | |
Lasse Reichstein
2011/03/14 12:20:15
I think we have an assertFalse function.
Martin Maly
2011/03/14 16:39:26
Done.
| |
1005 } | |
1006 CheckPillDescriptor(strict, "caller"); | |
1007 CheckPillDescriptor(strict, "arguments"); | |
1008 CheckPillDescriptor(another, "caller"); | |
1009 CheckPillDescriptor(another, "arguments"); | |
1010 })(); | |
OLD | NEW |