| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | |
| 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | |
| 3 // | |
| 4 // Redistribution and use in source and binary forms, with or without | |
| 5 // modification, are permitted provided that the following conditions | |
| 6 // are met: | |
| 7 // 1. Redistributions of source code must retain the above copyright | |
| 8 // notice, this list of conditions and the following disclaimer. | |
| 9 // 2. Redistributions in binary form must reproduce the above copyright | |
| 10 // notice, this list of conditions and the following disclaimer in the | |
| 11 // documentation and/or other materials provided with the distribution. | |
| 12 // | |
| 13 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | |
| 14 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 15 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 16 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | |
| 17 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 18 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 19 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | |
| 20 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 21 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 22 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 23 | |
| 24 // Flags: --no-harmony-restrictive-declarations | |
| 25 | |
| 26 description( | |
| 27 "This test checks that function declarations are treated as statements." | |
| 28 ); | |
| 29 | |
| 30 function f() | |
| 31 { | |
| 32 return false; | |
| 33 } | |
| 34 | |
| 35 function ifTest() | |
| 36 { | |
| 37 if (true) | |
| 38 function f() | |
| 39 { | |
| 40 return true; | |
| 41 } | |
| 42 | |
| 43 return f(); | |
| 44 } | |
| 45 | |
| 46 shouldBeTrue("ifTest()"); | |
| 47 | |
| 48 function ifElseTest() | |
| 49 { | |
| 50 if (false) | |
| 51 return false; | |
| 52 else | |
| 53 function f() | |
| 54 { | |
| 55 return true; | |
| 56 } | |
| 57 | |
| 58 return f(); | |
| 59 } | |
| 60 | |
| 61 shouldBeTrue("ifElseTest()"); | |
| 62 | |
| 63 function doWhileTest() | |
| 64 { | |
| 65 var i = 0; | |
| 66 do | |
| 67 function f() | |
| 68 { | |
| 69 return true; | |
| 70 } | |
| 71 while (i++ < 10) | |
| 72 | |
| 73 return f(); | |
| 74 } | |
| 75 | |
| 76 shouldBeTrue("doWhileTest()"); | |
| 77 | |
| 78 function whileTest() | |
| 79 { | |
| 80 var i = 0; | |
| 81 while (i++ < 10) | |
| 82 function f() | |
| 83 { | |
| 84 return true; | |
| 85 } | |
| 86 | |
| 87 return f(); | |
| 88 } | |
| 89 | |
| 90 shouldBeTrue("whileTest()"); | |
| 91 | |
| 92 function forTest() | |
| 93 { | |
| 94 var i; | |
| 95 for (i = 0; i < 10; ++i) | |
| 96 function f() | |
| 97 { | |
| 98 return true; | |
| 99 } | |
| 100 | |
| 101 return f(); | |
| 102 } | |
| 103 | |
| 104 shouldBeTrue("forTest()"); | |
| 105 | |
| 106 function forVarTest() | |
| 107 { | |
| 108 for (var i = 0; i < 10; ++i) | |
| 109 function f() | |
| 110 { | |
| 111 return true; | |
| 112 } | |
| 113 | |
| 114 return f(); | |
| 115 } | |
| 116 | |
| 117 shouldBeTrue("forVarTest()"); | |
| 118 | |
| 119 function forInTest() | |
| 120 { | |
| 121 var a; | |
| 122 for (a in { field: false }) | |
| 123 function f() | |
| 124 { | |
| 125 return true; | |
| 126 } | |
| 127 | |
| 128 return f(); | |
| 129 } | |
| 130 | |
| 131 shouldBeTrue("forInTest()"); | |
| 132 | |
| 133 function forInVarTest() | |
| 134 { | |
| 135 var a; | |
| 136 for (var a in { field: false }) | |
| 137 function f() | |
| 138 { | |
| 139 return true; | |
| 140 } | |
| 141 | |
| 142 return f(); | |
| 143 } | |
| 144 | |
| 145 shouldBeTrue("forInVarTest()"); | |
| 146 | |
| 147 function forInVarInitTest() | |
| 148 { | |
| 149 var a; | |
| 150 for (var a in { field: false }) | |
| 151 function f() | |
| 152 { | |
| 153 return true; | |
| 154 } | |
| 155 | |
| 156 return f(); | |
| 157 } | |
| 158 | |
| 159 shouldBeTrue("forInVarInitTest()"); | |
| 160 | |
| 161 function withTest() | |
| 162 { | |
| 163 with ({ }) | |
| 164 function f() | |
| 165 { | |
| 166 return true; | |
| 167 } | |
| 168 | |
| 169 return f(); | |
| 170 } | |
| 171 | |
| 172 shouldBeTrue("withTest()"); | |
| 173 | |
| 174 function labelTest() | |
| 175 { | |
| 176 label: | |
| 177 function f() | |
| 178 { | |
| 179 return true; | |
| 180 } | |
| 181 | |
| 182 return f(); | |
| 183 } | |
| 184 | |
| 185 shouldBeTrue("labelTest()"); | |
| OLD | NEW |