From c27a6c2a18f25da3900ed093355fd0c07c2e2172 Mon Sep 17 00:00:00 2001 From: "bob%bclary.com" Date: Fri, 18 Mar 2005 19:09:59 +0000 Subject: [PATCH] Add ability to run js/tests from browsers. Bug 263119 git-svn-id: svn://10.0.0.236/trunk@170902 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/tests/Makefile | 10 +- mozilla/js/tests/e4x/Expressions/browser.js | 0 mozilla/js/tests/e4x/Expressions/shell.js | 0 mozilla/js/tests/e4x/Global/browser.js | 0 mozilla/js/tests/e4x/Global/shell.js | 0 mozilla/js/tests/e4x/Namespace/browser.js | 0 mozilla/js/tests/e4x/Namespace/shell.js | 0 mozilla/js/tests/e4x/QName/browser.js | 0 mozilla/js/tests/e4x/QName/shell.js | 0 mozilla/js/tests/e4x/Regress/browser.js | 0 mozilla/js/tests/e4x/Regress/shell.js | 0 mozilla/js/tests/e4x/Statements/browser.js | 0 mozilla/js/tests/e4x/Statements/shell.js | 0 .../js/tests/e4x/TypeConversion/browser.js | 0 mozilla/js/tests/e4x/TypeConversion/shell.js | 0 mozilla/js/tests/e4x/Types/browser.js | 0 mozilla/js/tests/e4x/Types/shell.js | 0 mozilla/js/tests/e4x/XML/browser.js | 0 mozilla/js/tests/e4x/XML/shell.js | 0 mozilla/js/tests/e4x/XMLList/browser.js | 0 mozilla/js/tests/e4x/XMLList/shell.js | 0 mozilla/js/tests/e4x/browser.js | 182 +++ mozilla/js/tests/e4x/shell.js | 18 +- mozilla/js/tests/e4x/template.js | 49 + mozilla/js/tests/ecma/Array/15.4-1.js | 170 ++- mozilla/js/tests/ecma/Array/15.4-2.js | 110 +- mozilla/js/tests/ecma/Array/15.4.1.1.js | 116 +- mozilla/js/tests/ecma/Array/15.4.1.2.js | 169 ++- mozilla/js/tests/ecma/Array/15.4.1.3.js | 89 +- mozilla/js/tests/ecma/Array/15.4.1.js | 164 ++- mozilla/js/tests/ecma/Array/15.4.2.1-1.js | 111 +- mozilla/js/tests/ecma/Array/15.4.2.1-2.js | 99 +- mozilla/js/tests/ecma/Array/15.4.2.1-3.js | 158 +-- mozilla/js/tests/ecma/Array/15.4.2.2-1.js | 194 ++-- mozilla/js/tests/ecma/Array/15.4.2.2-2.js | 122 +- mozilla/js/tests/ecma/Array/15.4.2.3.js | 98 +- mozilla/js/tests/ecma/Array/15.4.3.1-2.js | 68 +- mozilla/js/tests/ecma/Array/15.4.3.2.js | 48 +- mozilla/js/tests/ecma/Array/15.4.3.js | 55 +- mozilla/js/tests/ecma/Array/15.4.4.1.js | 49 +- mozilla/js/tests/ecma/Array/15.4.4.2.js | 108 +- mozilla/js/tests/ecma/Array/15.4.4.3-1.js | 219 ++-- mozilla/js/tests/ecma/Array/15.4.4.4-1.js | 398 +++---- mozilla/js/tests/ecma/Array/15.4.4.4-2.js | 205 ++-- mozilla/js/tests/ecma/Array/15.4.4.5-1.js | 317 +++--- mozilla/js/tests/ecma/Array/15.4.4.5-2.js | 324 +++--- mozilla/js/tests/ecma/Array/15.4.4.5-3.js | 250 ++-- mozilla/js/tests/ecma/Array/15.4.4.js | 68 +- mozilla/js/tests/ecma/Array/15.4.5.1-1.js | 243 ++-- mozilla/js/tests/ecma/Array/15.4.5.1-2.js | 185 ++- mozilla/js/tests/ecma/Array/15.4.5.2-1.js | 108 +- mozilla/js/tests/ecma/Array/15.4.5.2-2.js | 135 +-- mozilla/js/tests/ecma/Array/browser.js | 0 mozilla/js/tests/ecma/Array/shell.js | 0 mozilla/js/tests/ecma/Boolean/15.6.1.js | 107 +- mozilla/js/tests/ecma/Boolean/15.6.2.js | 244 ++-- mozilla/js/tests/ecma/Boolean/15.6.3.1-1.js | 63 +- mozilla/js/tests/ecma/Boolean/15.6.3.1-2.js | 61 +- mozilla/js/tests/ecma/Boolean/15.6.3.1-3.js | 61 +- mozilla/js/tests/ecma/Boolean/15.6.3.1-4.js | 73 +- mozilla/js/tests/ecma/Boolean/15.6.3.1-5.js | 48 +- mozilla/js/tests/ecma/Boolean/15.6.3.1.js | 60 +- mozilla/js/tests/ecma/Boolean/15.6.3.js | 55 +- mozilla/js/tests/ecma/Boolean/15.6.4-1.js | 64 +- mozilla/js/tests/ecma/Boolean/15.6.4-2.js | 52 +- mozilla/js/tests/ecma/Boolean/15.6.4.1.js | 56 +- mozilla/js/tests/ecma/Boolean/15.6.4.2-1.js | 111 +- mozilla/js/tests/ecma/Boolean/15.6.4.2-2.js | 81 +- mozilla/js/tests/ecma/Boolean/15.6.4.2-3.js | 57 +- mozilla/js/tests/ecma/Boolean/15.6.4.2-4-n.js | 64 +- mozilla/js/tests/ecma/Boolean/15.6.4.3-1.js | 98 +- mozilla/js/tests/ecma/Boolean/15.6.4.3-2.js | 57 +- mozilla/js/tests/ecma/Boolean/15.6.4.3-3.js | 64 +- mozilla/js/tests/ecma/Boolean/15.6.4.3-4-n.js | 65 +- mozilla/js/tests/ecma/Boolean/15.6.4.3.js | 99 +- mozilla/js/tests/ecma/Boolean/15.6.4.js | 78 +- mozilla/js/tests/ecma/Boolean/browser.js | 0 mozilla/js/tests/ecma/Boolean/shell.js | 0 mozilla/js/tests/ecma/Date/15.9.1.1-1.js | 89 +- mozilla/js/tests/ecma/Date/15.9.1.1-2.js | 89 +- mozilla/js/tests/ecma/Date/15.9.2.1.js | 123 +- mozilla/js/tests/ecma/Date/15.9.2.2-1.js | 116 +- mozilla/js/tests/ecma/Date/15.9.2.2-2.js | 108 +- mozilla/js/tests/ecma/Date/15.9.2.2-3.js | 96 +- mozilla/js/tests/ecma/Date/15.9.2.2-4.js | 86 +- mozilla/js/tests/ecma/Date/15.9.2.2-5.js | 76 +- mozilla/js/tests/ecma/Date/15.9.2.2-6.js | 70 +- mozilla/js/tests/ecma/Date/15.9.3.1-1.js | 368 +++--- mozilla/js/tests/ecma/Date/15.9.3.1-2.js | 305 +++-- mozilla/js/tests/ecma/Date/15.9.3.1-3.js | 273 +++-- mozilla/js/tests/ecma/Date/15.9.3.1-4.js | 252 ++--- mozilla/js/tests/ecma/Date/15.9.3.1-5.js | 219 ++-- mozilla/js/tests/ecma/Date/15.9.3.2-1.js | 317 +++--- mozilla/js/tests/ecma/Date/15.9.3.2-2.js | 286 +++-- mozilla/js/tests/ecma/Date/15.9.3.2-3.js | 266 ++--- mozilla/js/tests/ecma/Date/15.9.3.2-4.js | 241 ++-- mozilla/js/tests/ecma/Date/15.9.3.2-5.js | 216 ++-- mozilla/js/tests/ecma/Date/15.9.3.8-1.js | 383 +++---- mozilla/js/tests/ecma/Date/15.9.3.8-2.js | 352 +++--- mozilla/js/tests/ecma/Date/15.9.3.8-3.js | 323 +++--- mozilla/js/tests/ecma/Date/15.9.3.8-4.js | 285 +++-- mozilla/js/tests/ecma/Date/15.9.3.8-5.js | 243 ++-- mozilla/js/tests/ecma/Date/15.9.4.2-1.js | 39 +- mozilla/js/tests/ecma/Date/15.9.4.2.js | 287 +++-- mozilla/js/tests/ecma/Date/15.9.4.3.js | 308 +++-- mozilla/js/tests/ecma/Date/15.9.5.1.js | 53 +- mozilla/js/tests/ecma/Date/15.9.5.10-1.js | 132 +-- mozilla/js/tests/ecma/Date/15.9.5.10-10.js | 108 +- mozilla/js/tests/ecma/Date/15.9.5.10-11.js | 106 +- mozilla/js/tests/ecma/Date/15.9.5.10-12.js | 104 +- mozilla/js/tests/ecma/Date/15.9.5.10-13.js | 100 +- mozilla/js/tests/ecma/Date/15.9.5.10-2.js | 124 +- mozilla/js/tests/ecma/Date/15.9.5.10-3.js | 122 +- mozilla/js/tests/ecma/Date/15.9.5.10-4.js | 118 +- mozilla/js/tests/ecma/Date/15.9.5.10-5.js | 119 +- mozilla/js/tests/ecma/Date/15.9.5.10-6.js | 116 +- mozilla/js/tests/ecma/Date/15.9.5.10-7.js | 114 +- mozilla/js/tests/ecma/Date/15.9.5.10-8.js | 112 +- mozilla/js/tests/ecma/Date/15.9.5.10-9.js | 110 +- mozilla/js/tests/ecma/Date/15.9.5.11-1.js | 97 +- mozilla/js/tests/ecma/Date/15.9.5.11-2.js | 100 +- mozilla/js/tests/ecma/Date/15.9.5.11-3.js | 92 +- mozilla/js/tests/ecma/Date/15.9.5.11-4.js | 92 +- mozilla/js/tests/ecma/Date/15.9.5.11-5.js | 92 +- mozilla/js/tests/ecma/Date/15.9.5.11-6.js | 95 +- mozilla/js/tests/ecma/Date/15.9.5.11-7.js | 96 +- mozilla/js/tests/ecma/Date/15.9.5.12-1.js | 118 +- mozilla/js/tests/ecma/Date/15.9.5.12-2.js | 116 +- mozilla/js/tests/ecma/Date/15.9.5.12-3.js | 114 +- mozilla/js/tests/ecma/Date/15.9.5.12-4.js | 112 +- mozilla/js/tests/ecma/Date/15.9.5.12-5.js | 110 +- mozilla/js/tests/ecma/Date/15.9.5.12-6.js | 108 +- mozilla/js/tests/ecma/Date/15.9.5.12-7.js | 106 +- mozilla/js/tests/ecma/Date/15.9.5.12-8.js | 102 +- mozilla/js/tests/ecma/Date/15.9.5.13-1.js | 64 +- mozilla/js/tests/ecma/Date/15.9.5.13-2.js | 68 +- mozilla/js/tests/ecma/Date/15.9.5.13-3.js | 60 +- mozilla/js/tests/ecma/Date/15.9.5.13-4.js | 60 +- mozilla/js/tests/ecma/Date/15.9.5.13-5.js | 60 +- mozilla/js/tests/ecma/Date/15.9.5.13-6.js | 64 +- mozilla/js/tests/ecma/Date/15.9.5.13-7.js | 66 +- mozilla/js/tests/ecma/Date/15.9.5.13-8.js | 96 +- mozilla/js/tests/ecma/Date/15.9.5.14.js | 114 +- mozilla/js/tests/ecma/Date/15.9.5.15.js | 112 +- mozilla/js/tests/ecma/Date/15.9.5.16.js | 114 +- mozilla/js/tests/ecma/Date/15.9.5.17.js | 112 +- mozilla/js/tests/ecma/Date/15.9.5.18.js | 112 +- mozilla/js/tests/ecma/Date/15.9.5.19.js | 112 +- mozilla/js/tests/ecma/Date/15.9.5.2-1.js | 195 ++-- mozilla/js/tests/ecma/Date/15.9.5.2-2-n.js | 74 +- mozilla/js/tests/ecma/Date/15.9.5.2.js | 195 ++-- mozilla/js/tests/ecma/Date/15.9.5.20.js | 112 +- mozilla/js/tests/ecma/Date/15.9.5.21-1.js | 107 +- mozilla/js/tests/ecma/Date/15.9.5.21-2.js | 107 +- mozilla/js/tests/ecma/Date/15.9.5.21-3.js | 79 +- mozilla/js/tests/ecma/Date/15.9.5.21-4.js | 78 +- mozilla/js/tests/ecma/Date/15.9.5.21-5.js | 79 +- mozilla/js/tests/ecma/Date/15.9.5.21-6.js | 78 +- mozilla/js/tests/ecma/Date/15.9.5.21-7.js | 78 +- mozilla/js/tests/ecma/Date/15.9.5.21-8.js | 92 +- mozilla/js/tests/ecma/Date/15.9.5.22-1.js | 114 +- mozilla/js/tests/ecma/Date/15.9.5.22-2.js | 114 +- mozilla/js/tests/ecma/Date/15.9.5.22-3.js | 112 +- mozilla/js/tests/ecma/Date/15.9.5.22-4.js | 110 +- mozilla/js/tests/ecma/Date/15.9.5.22-5.js | 108 +- mozilla/js/tests/ecma/Date/15.9.5.22-6.js | 106 +- mozilla/js/tests/ecma/Date/15.9.5.22-7.js | 104 +- mozilla/js/tests/ecma/Date/15.9.5.22-8.js | 100 +- mozilla/js/tests/ecma/Date/15.9.5.23-1.js | 190 ++-- mozilla/js/tests/ecma/Date/15.9.5.23-10.js | 188 ++- mozilla/js/tests/ecma/Date/15.9.5.23-11.js | 185 ++- mozilla/js/tests/ecma/Date/15.9.5.23-12.js | 184 ++- mozilla/js/tests/ecma/Date/15.9.5.23-13.js | 180 ++- mozilla/js/tests/ecma/Date/15.9.5.23-14.js | 178 ++- mozilla/js/tests/ecma/Date/15.9.5.23-15.js | 173 ++- mozilla/js/tests/ecma/Date/15.9.5.23-16.js | 171 ++- mozilla/js/tests/ecma/Date/15.9.5.23-17.js | 169 ++- mozilla/js/tests/ecma/Date/15.9.5.23-18.js | 166 ++- mozilla/js/tests/ecma/Date/15.9.5.23-2.js | 128 +-- mozilla/js/tests/ecma/Date/15.9.5.23-3-n.js | 66 +- mozilla/js/tests/ecma/Date/15.9.5.23-4.js | 147 ++- mozilla/js/tests/ecma/Date/15.9.5.23-5.js | 148 ++- mozilla/js/tests/ecma/Date/15.9.5.23-6.js | 147 ++- mozilla/js/tests/ecma/Date/15.9.5.23-7.js | 148 ++- mozilla/js/tests/ecma/Date/15.9.5.23-8.js | 132 +-- mozilla/js/tests/ecma/Date/15.9.5.23-9.js | 132 +-- mozilla/js/tests/ecma/Date/15.9.5.24-1.js | 172 ++- mozilla/js/tests/ecma/Date/15.9.5.24-2.js | 170 ++- mozilla/js/tests/ecma/Date/15.9.5.24-3.js | 168 ++- mozilla/js/tests/ecma/Date/15.9.5.24-4.js | 166 ++- mozilla/js/tests/ecma/Date/15.9.5.24-5.js | 164 ++- mozilla/js/tests/ecma/Date/15.9.5.24-6.js | 162 ++- mozilla/js/tests/ecma/Date/15.9.5.24-7.js | 160 ++- mozilla/js/tests/ecma/Date/15.9.5.24-8.js | 154 ++- mozilla/js/tests/ecma/Date/15.9.5.25-1.js | 64 +- mozilla/js/tests/ecma/Date/15.9.5.26-1.js | 266 ++--- mozilla/js/tests/ecma/Date/15.9.5.27-1.js | 259 ++--- mozilla/js/tests/ecma/Date/15.9.5.28-1.js | 278 +++-- mozilla/js/tests/ecma/Date/15.9.5.29-1.js | 274 +++-- mozilla/js/tests/ecma/Date/15.9.5.3-1-n.js | 64 +- mozilla/js/tests/ecma/Date/15.9.5.3-2.js | 118 +- mozilla/js/tests/ecma/Date/15.9.5.30-1.js | 275 +++-- mozilla/js/tests/ecma/Date/15.9.5.31-1.js | 262 ++--- mozilla/js/tests/ecma/Date/15.9.5.32-1.js | 192 ++-- mozilla/js/tests/ecma/Date/15.9.5.33-1.js | 192 ++-- mozilla/js/tests/ecma/Date/15.9.5.34-1.js | 285 +++-- mozilla/js/tests/ecma/Date/15.9.5.35-1.js | 165 ++- mozilla/js/tests/ecma/Date/15.9.5.36-1.js | 308 +++-- mozilla/js/tests/ecma/Date/15.9.5.36-2.js | 288 +++-- mozilla/js/tests/ecma/Date/15.9.5.36-3.js | 268 +++-- mozilla/js/tests/ecma/Date/15.9.5.36-4.js | 248 ++-- mozilla/js/tests/ecma/Date/15.9.5.36-5.js | 229 ++-- mozilla/js/tests/ecma/Date/15.9.5.36-6.js | 208 ++-- mozilla/js/tests/ecma/Date/15.9.5.36-7.js | 183 ++- mozilla/js/tests/ecma/Date/15.9.5.37-1.js | 284 +++-- mozilla/js/tests/ecma/Date/15.9.5.37-2.js | 246 ++-- mozilla/js/tests/ecma/Date/15.9.5.37-3.js | 226 ++-- mozilla/js/tests/ecma/Date/15.9.5.37-4.js | 202 ++-- mozilla/js/tests/ecma/Date/15.9.5.37-5.js | 176 ++- mozilla/js/tests/ecma/Date/15.9.5.4-1.js | 108 +- mozilla/js/tests/ecma/Date/15.9.5.4-2-n.js | 62 +- mozilla/js/tests/ecma/Date/15.9.5.5.js | 148 ++- mozilla/js/tests/ecma/Date/15.9.5.6.js | 133 +-- mozilla/js/tests/ecma/Date/15.9.5.7.js | 140 ++- mozilla/js/tests/ecma/Date/15.9.5.8.js | 142 ++- mozilla/js/tests/ecma/Date/15.9.5.9.js | 142 ++- mozilla/js/tests/ecma/Date/15.9.5.js | 85 +- mozilla/js/tests/ecma/Date/browser.js | 0 mozilla/js/tests/ecma/Date/shell.js | 0 .../tests/ecma/ExecutionContexts/10.1.3-1.js | 133 +-- .../js/tests/ecma/ExecutionContexts/10.1.3.js | 245 ++-- .../tests/ecma/ExecutionContexts/10.1.4-1.js | 116 +- .../tests/ecma/ExecutionContexts/10.1.4-10.js | 110 +- .../tests/ecma/ExecutionContexts/10.1.4-2.js | 120 +- .../tests/ecma/ExecutionContexts/10.1.4-3.js | 116 +- .../tests/ecma/ExecutionContexts/10.1.4-4.js | 121 +- .../tests/ecma/ExecutionContexts/10.1.4-5.js | 126 +-- .../tests/ecma/ExecutionContexts/10.1.4-6.js | 98 +- .../tests/ecma/ExecutionContexts/10.1.4-7.js | 119 +- .../tests/ecma/ExecutionContexts/10.1.4-8.js | 119 +- .../tests/ecma/ExecutionContexts/10.1.4-9.js | 115 +- .../tests/ecma/ExecutionContexts/10.1.5-1.js | 25 +- .../tests/ecma/ExecutionContexts/10.1.5-2.js | 24 +- .../tests/ecma/ExecutionContexts/10.1.5-3.js | 12 +- .../tests/ecma/ExecutionContexts/10.1.5-4.js | 28 +- .../js/tests/ecma/ExecutionContexts/10.1.6.js | 130 +-- .../tests/ecma/ExecutionContexts/10.1.8-1.js | 144 ++- .../tests/ecma/ExecutionContexts/10.1.8-2.js | 140 ++- .../js/tests/ecma/ExecutionContexts/10.2.1.js | 84 +- .../tests/ecma/ExecutionContexts/10.2.2-1.js | 154 ++- .../tests/ecma/ExecutionContexts/10.2.2-2.js | 149 +-- .../tests/ecma/ExecutionContexts/10.2.3-1.js | 78 +- .../tests/ecma/ExecutionContexts/10.2.3-2.js | 86 +- .../tests/ecma/ExecutionContexts/browser.js | 0 .../js/tests/ecma/ExecutionContexts/shell.js | 0 mozilla/js/tests/ecma/Expressions/11.1.1.js | 159 ++- mozilla/js/tests/ecma/Expressions/11.10-1.js | 330 +++--- mozilla/js/tests/ecma/Expressions/11.10-2.js | 326 +++--- mozilla/js/tests/ecma/Expressions/11.10-3.js | 326 +++--- mozilla/js/tests/ecma/Expressions/11.12-1.js | 107 +- .../js/tests/ecma/Expressions/11.12-2-n.js | 66 +- mozilla/js/tests/ecma/Expressions/11.12-3.js | 65 +- mozilla/js/tests/ecma/Expressions/11.12-4.js | 65 +- mozilla/js/tests/ecma/Expressions/11.13.1.js | 64 +- .../js/tests/ecma/Expressions/11.13.2-1.js | 273 +++-- .../js/tests/ecma/Expressions/11.13.2-2.js | 277 +++-- .../js/tests/ecma/Expressions/11.13.2-3.js | 331 ++++-- .../js/tests/ecma/Expressions/11.13.2-4.js | 160 ++- .../js/tests/ecma/Expressions/11.13.2-5.js | 160 ++- mozilla/js/tests/ecma/Expressions/11.13.js | 86 +- mozilla/js/tests/ecma/Expressions/11.14-1.js | 67 +- mozilla/js/tests/ecma/Expressions/11.2.1-1.js | 410 ++++--- mozilla/js/tests/ecma/Expressions/11.2.1-2.js | 151 ++- .../js/tests/ecma/Expressions/11.2.1-3-n.js | 147 ++- .../js/tests/ecma/Expressions/11.2.1-4-n.js | 129 +-- mozilla/js/tests/ecma/Expressions/11.2.1-5.js | 153 ++- .../js/tests/ecma/Expressions/11.2.2-1-n.js | 79 +- mozilla/js/tests/ecma/Expressions/11.2.2-1.js | 78 +- .../js/tests/ecma/Expressions/11.2.2-10-n.js | 77 +- .../js/tests/ecma/Expressions/11.2.2-11.js | 82 +- .../js/tests/ecma/Expressions/11.2.2-2-n.js | 79 +- .../js/tests/ecma/Expressions/11.2.2-3-n.js | 81 +- .../js/tests/ecma/Expressions/11.2.2-4-n.js | 79 +- .../js/tests/ecma/Expressions/11.2.2-5-n.js | 79 +- .../js/tests/ecma/Expressions/11.2.2-6-n.js | 65 +- .../js/tests/ecma/Expressions/11.2.2-7-n.js | 79 +- .../js/tests/ecma/Expressions/11.2.2-8-n.js | 79 +- .../js/tests/ecma/Expressions/11.2.2-9-n.js | 79 +- mozilla/js/tests/ecma/Expressions/11.2.3-1.js | 143 ++- .../js/tests/ecma/Expressions/11.2.3-2-n.js | 99 +- .../js/tests/ecma/Expressions/11.2.3-3-n.js | 89 +- .../js/tests/ecma/Expressions/11.2.3-4-n.js | 89 +- mozilla/js/tests/ecma/Expressions/11.2.3-5.js | 85 +- mozilla/js/tests/ecma/Expressions/11.3.1.js | 194 ++-- mozilla/js/tests/ecma/Expressions/11.3.2.js | 194 ++-- mozilla/js/tests/ecma/Expressions/11.4.1.js | 88 +- mozilla/js/tests/ecma/Expressions/11.4.2.js | 73 +- mozilla/js/tests/ecma/Expressions/11.4.3.js | 143 ++- mozilla/js/tests/ecma/Expressions/11.4.4.js | 197 ++-- mozilla/js/tests/ecma/Expressions/11.4.5.js | 193 ++-- mozilla/js/tests/ecma/Expressions/11.4.6.js | 434 ++++--- mozilla/js/tests/ecma/Expressions/11.4.8.js | 252 ++--- mozilla/js/tests/ecma/Expressions/11.4.9.js | 103 +- mozilla/js/tests/ecma/Expressions/11.5.1.js | 137 +-- mozilla/js/tests/ecma/Expressions/11.5.2.js | 115 +- mozilla/js/tests/ecma/Expressions/11.5.3.js | 124 +- mozilla/js/tests/ecma/Expressions/11.6.1-1.js | 61 +- mozilla/js/tests/ecma/Expressions/11.6.1-2.js | 267 ++--- mozilla/js/tests/ecma/Expressions/11.6.1-3.js | 233 ++-- mozilla/js/tests/ecma/Expressions/11.6.2-1.js | 259 ++--- mozilla/js/tests/ecma/Expressions/11.6.3.js | 136 +-- mozilla/js/tests/ecma/Expressions/11.7.1.js | 34 +- mozilla/js/tests/ecma/Expressions/11.7.2.js | 41 +- mozilla/js/tests/ecma/Expressions/11.7.3.js | 279 +++-- mozilla/js/tests/ecma/Expressions/11.8.1.js | 135 +-- mozilla/js/tests/ecma/Expressions/11.8.2.js | 136 +-- mozilla/js/tests/ecma/Expressions/11.8.3.js | 133 +-- mozilla/js/tests/ecma/Expressions/11.8.4.js | 136 +-- mozilla/js/tests/ecma/Expressions/11.9.1.js | 210 ++-- mozilla/js/tests/ecma/Expressions/11.9.2.js | 185 ++- mozilla/js/tests/ecma/Expressions/11.9.3.js | 185 ++- mozilla/js/tests/ecma/Expressions/browser.js | 0 mozilla/js/tests/ecma/Expressions/shell.js | 0 .../tests/ecma/FunctionObjects/15.3.1.1-1.js | 144 ++- .../tests/ecma/FunctionObjects/15.3.1.1-2.js | 210 ++-- .../tests/ecma/FunctionObjects/15.3.1.1-3.js | 112 +- .../tests/ecma/FunctionObjects/15.3.2.1-1.js | 171 +-- .../tests/ecma/FunctionObjects/15.3.2.1-2.js | 160 ++- .../tests/ecma/FunctionObjects/15.3.2.1-3.js | 106 +- .../tests/ecma/FunctionObjects/15.3.3.1-1.js | 50 +- .../tests/ecma/FunctionObjects/15.3.3.1-2.js | 63 +- .../tests/ecma/FunctionObjects/15.3.3.1-3.js | 75 +- .../tests/ecma/FunctionObjects/15.3.3.1-4.js | 63 +- .../js/tests/ecma/FunctionObjects/15.3.3.2.js | 62 +- .../js/tests/ecma/FunctionObjects/15.3.4-1.js | 114 +- .../js/tests/ecma/FunctionObjects/15.3.4.1.js | 63 +- .../js/tests/ecma/FunctionObjects/15.3.4.js | 100 +- .../js/tests/ecma/FunctionObjects/15.3.5-1.js | 142 +-- .../js/tests/ecma/FunctionObjects/15.3.5-2.js | 93 +- .../js/tests/ecma/FunctionObjects/15.3.5.1.js | 74 +- .../js/tests/ecma/FunctionObjects/15.3.5.3.js | 68 +- .../js/tests/ecma/FunctionObjects/browser.js | 0 .../js/tests/ecma/FunctionObjects/shell.js | 0 .../js/tests/ecma/GlobalObject/15.1-1-n.js | 54 +- .../js/tests/ecma/GlobalObject/15.1-2-n.js | 70 +- .../js/tests/ecma/GlobalObject/15.1.1.1.js | 51 +- .../js/tests/ecma/GlobalObject/15.1.1.2.js | 53 +- .../js/tests/ecma/GlobalObject/15.1.2.1-1.js | 98 +- .../js/tests/ecma/GlobalObject/15.1.2.1-2.js | 60 +- .../js/tests/ecma/GlobalObject/15.1.2.2-1.js | 568 ++++++---- .../js/tests/ecma/GlobalObject/15.1.2.2-2.js | 280 +++-- .../js/tests/ecma/GlobalObject/15.1.2.3-1.js | 707 ++++++------ .../js/tests/ecma/GlobalObject/15.1.2.3-2.js | 416 ++++--- .../js/tests/ecma/GlobalObject/15.1.2.4.js | 280 +++-- .../js/tests/ecma/GlobalObject/15.1.2.5-1.js | 302 +++-- .../js/tests/ecma/GlobalObject/15.1.2.5-2.js | 307 +++-- .../js/tests/ecma/GlobalObject/15.1.2.5-3.js | 354 +++--- .../js/tests/ecma/GlobalObject/15.1.2.6.js | 157 ++- .../js/tests/ecma/GlobalObject/15.1.2.7.js | 160 ++- mozilla/js/tests/ecma/GlobalObject/browser.js | 0 mozilla/js/tests/ecma/GlobalObject/shell.js | 0 .../js/tests/ecma/LexicalConventions/7.1-1.js | 87 +- .../js/tests/ecma/LexicalConventions/7.1-2.js | 72 +- .../js/tests/ecma/LexicalConventions/7.1-3.js | 100 +- .../js/tests/ecma/LexicalConventions/7.2-1.js | 73 +- .../tests/ecma/LexicalConventions/7.2-2-n.js | 75 +- .../tests/ecma/LexicalConventions/7.2-3-n.js | 76 +- .../tests/ecma/LexicalConventions/7.2-4-n.js | 78 +- .../tests/ecma/LexicalConventions/7.2-5-n.js | 82 +- .../js/tests/ecma/LexicalConventions/7.2-6.js | 65 +- .../js/tests/ecma/LexicalConventions/7.3-1.js | 76 +- .../tests/ecma/LexicalConventions/7.3-10.js | 55 +- .../tests/ecma/LexicalConventions/7.3-11.js | 53 +- .../tests/ecma/LexicalConventions/7.3-12.js | 55 +- .../tests/ecma/LexicalConventions/7.3-13-n.js | 55 +- .../js/tests/ecma/LexicalConventions/7.3-2.js | 55 +- .../js/tests/ecma/LexicalConventions/7.3-3.js | 57 +- .../js/tests/ecma/LexicalConventions/7.3-4.js | 55 +- .../js/tests/ecma/LexicalConventions/7.3-5.js | 54 +- .../js/tests/ecma/LexicalConventions/7.3-6.js | 58 +- .../js/tests/ecma/LexicalConventions/7.3-7.js | 57 +- .../js/tests/ecma/LexicalConventions/7.3-8.js | 55 +- .../js/tests/ecma/LexicalConventions/7.3-9.js | 54 +- .../ecma/LexicalConventions/7.4.1-1-n.js | 61 +- .../ecma/LexicalConventions/7.4.1-2-n.js | 60 +- .../ecma/LexicalConventions/7.4.1-3-n.js | 30 +- .../ecma/LexicalConventions/7.4.2-1-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-10-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-11-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-12-n.js | 71 +- .../ecma/LexicalConventions/7.4.2-13-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-14-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-15-n.js | 71 +- .../ecma/LexicalConventions/7.4.2-16-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-2-n.js | 69 +- .../ecma/LexicalConventions/7.4.2-3-n.js | 69 +- .../ecma/LexicalConventions/7.4.2-4-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-5-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-6-n.js | 70 +- .../ecma/LexicalConventions/7.4.2-7-n.js | 67 +- .../ecma/LexicalConventions/7.4.2-8-n.js | 28 +- .../ecma/LexicalConventions/7.4.2-9-n.js | 70 +- .../ecma/LexicalConventions/7.4.3-1-n.js | 65 +- .../ecma/LexicalConventions/7.4.3-10-n.js | 65 +- .../ecma/LexicalConventions/7.4.3-11-n.js | 64 +- .../ecma/LexicalConventions/7.4.3-12-n.js | 66 +- .../ecma/LexicalConventions/7.4.3-13-n.js | 66 +- .../ecma/LexicalConventions/7.4.3-14-n.js | 66 +- .../ecma/LexicalConventions/7.4.3-15-n.js | 68 +- .../ecma/LexicalConventions/7.4.3-16-n.js | 80 +- .../ecma/LexicalConventions/7.4.3-2-n.js | 66 +- .../ecma/LexicalConventions/7.4.3-3-n.js | 66 +- .../ecma/LexicalConventions/7.4.3-4-n.js | 68 +- .../ecma/LexicalConventions/7.4.3-5-n.js | 66 +- .../ecma/LexicalConventions/7.4.3-6-n.js | 64 +- .../ecma/LexicalConventions/7.4.3-7-n.js | 63 +- .../ecma/LexicalConventions/7.4.3-8-n.js | 64 +- .../ecma/LexicalConventions/7.4.3-9-n.js | 64 +- .../js/tests/ecma/LexicalConventions/7.5-1.js | 56 +- .../tests/ecma/LexicalConventions/7.5-10-n.js | 61 +- .../tests/ecma/LexicalConventions/7.5-2-n.js | 56 +- .../tests/ecma/LexicalConventions/7.5-3-n.js | 56 +- .../tests/ecma/LexicalConventions/7.5-4-n.js | 56 +- .../tests/ecma/LexicalConventions/7.5-5-n.js | 56 +- .../js/tests/ecma/LexicalConventions/7.5-6.js | 55 +- .../js/tests/ecma/LexicalConventions/7.5-7.js | 55 +- .../tests/ecma/LexicalConventions/7.5-8-n.js | 56 +- .../tests/ecma/LexicalConventions/7.5-9-n.js | 35 +- .../js/tests/ecma/LexicalConventions/7.6.js | 492 ++++---- .../js/tests/ecma/LexicalConventions/7.7.1.js | 59 +- .../js/tests/ecma/LexicalConventions/7.7.2.js | 65 +- .../tests/ecma/LexicalConventions/7.7.3-1.js | 253 ++--- .../tests/ecma/LexicalConventions/7.7.3-2.js | 96 +- .../js/tests/ecma/LexicalConventions/7.7.3.js | 548 +++++---- .../js/tests/ecma/LexicalConventions/7.7.4.js | 420 ++++--- .../tests/ecma/LexicalConventions/7.8.2-n.js | 35 +- .../tests/ecma/LexicalConventions/browser.js | 0 .../js/tests/ecma/LexicalConventions/shell.js | 0 mozilla/js/tests/ecma/Math/15.8-1.js | 108 +- mozilla/js/tests/ecma/Math/15.8-2-n.js | 105 +- mozilla/js/tests/ecma/Math/15.8-3-n.js | 75 +- mozilla/js/tests/ecma/Math/15.8.1.1-1.js | 66 +- mozilla/js/tests/ecma/Math/15.8.1.1-2.js | 61 +- mozilla/js/tests/ecma/Math/15.8.1.2-1.js | 66 +- mozilla/js/tests/ecma/Math/15.8.1.2-2.js | 58 +- mozilla/js/tests/ecma/Math/15.8.1.3-1.js | 68 +- mozilla/js/tests/ecma/Math/15.8.1.3-2.js | 81 +- mozilla/js/tests/ecma/Math/15.8.1.4-1.js | 30 +- mozilla/js/tests/ecma/Math/15.8.1.4-2.js | 72 +- mozilla/js/tests/ecma/Math/15.8.1.5-1.js | 73 +- mozilla/js/tests/ecma/Math/15.8.1.5-2.js | 59 +- mozilla/js/tests/ecma/Math/15.8.1.6-1.js | 68 +- mozilla/js/tests/ecma/Math/15.8.1.6-2.js | 57 +- mozilla/js/tests/ecma/Math/15.8.1.7-1.js | 69 +- mozilla/js/tests/ecma/Math/15.8.1.7-2.js | 74 +- mozilla/js/tests/ecma/Math/15.8.1.8-1.js | 54 +- mozilla/js/tests/ecma/Math/15.8.1.8-2.js | 72 +- mozilla/js/tests/ecma/Math/15.8.1.8-3.js | 64 +- mozilla/js/tests/ecma/Math/15.8.1.js | 156 ++- mozilla/js/tests/ecma/Math/15.8.2.1.js | 242 ++-- mozilla/js/tests/ecma/Math/15.8.2.10.js | 157 ++- mozilla/js/tests/ecma/Math/15.8.2.11.js | 214 ++-- mozilla/js/tests/ecma/Math/15.8.2.12.js | 183 ++- mozilla/js/tests/ecma/Math/15.8.2.13.js | 429 +++++-- mozilla/js/tests/ecma/Math/15.8.2.14.js | 102 +- mozilla/js/tests/ecma/Math/15.8.2.15.js | 219 ++-- mozilla/js/tests/ecma/Math/15.8.2.16.js | 127 ++- mozilla/js/tests/ecma/Math/15.8.2.17.js | 233 ++-- mozilla/js/tests/ecma/Math/15.8.2.18.js | 172 ++- mozilla/js/tests/ecma/Math/15.8.2.2.js | 177 +-- mozilla/js/tests/ecma/Math/15.8.2.3.js | 161 ++- mozilla/js/tests/ecma/Math/15.8.2.4.js | 135 ++- mozilla/js/tests/ecma/Math/15.8.2.5.js | 257 +++-- mozilla/js/tests/ecma/Math/15.8.2.6.js | 280 +++-- mozilla/js/tests/ecma/Math/15.8.2.7.js | 305 +++-- mozilla/js/tests/ecma/Math/15.8.2.8.js | 133 ++- mozilla/js/tests/ecma/Math/15.8.2.9.js | 199 ++-- mozilla/js/tests/ecma/Math/browser.js | 0 mozilla/js/tests/ecma/Math/shell.js | 0 mozilla/js/tests/ecma/NativeObjects/15-1.js | 98 +- mozilla/js/tests/ecma/NativeObjects/15-2.js | 44 +- .../js/tests/ecma/NativeObjects/browser.js | 0 mozilla/js/tests/ecma/NativeObjects/shell.js | 0 mozilla/js/tests/ecma/Number/15.7.1.js | 95 +- mozilla/js/tests/ecma/Number/15.7.2.js | 116 +- mozilla/js/tests/ecma/Number/15.7.3.1-1.js | 54 +- mozilla/js/tests/ecma/Number/15.7.3.1-2.js | 67 +- mozilla/js/tests/ecma/Number/15.7.3.1-3.js | 62 +- mozilla/js/tests/ecma/Number/15.7.3.2-1.js | 53 +- mozilla/js/tests/ecma/Number/15.7.3.2-2.js | 57 +- mozilla/js/tests/ecma/Number/15.7.3.2-3.js | 56 +- mozilla/js/tests/ecma/Number/15.7.3.2-4.js | 59 +- mozilla/js/tests/ecma/Number/15.7.3.3-1.js | 53 +- mozilla/js/tests/ecma/Number/15.7.3.3-2.js | 58 +- mozilla/js/tests/ecma/Number/15.7.3.3-3.js | 58 +- mozilla/js/tests/ecma/Number/15.7.3.3-4.js | 58 +- mozilla/js/tests/ecma/Number/15.7.3.4-1.js | 52 +- mozilla/js/tests/ecma/Number/15.7.3.4-2.js | 59 +- mozilla/js/tests/ecma/Number/15.7.3.4-3.js | 61 +- mozilla/js/tests/ecma/Number/15.7.3.4-4.js | 62 +- mozilla/js/tests/ecma/Number/15.7.3.5-1.js | 52 +- mozilla/js/tests/ecma/Number/15.7.3.5-2.js | 65 +- mozilla/js/tests/ecma/Number/15.7.3.5-3.js | 57 +- mozilla/js/tests/ecma/Number/15.7.3.5-4.js | 59 +- mozilla/js/tests/ecma/Number/15.7.3.6-1.js | 50 +- mozilla/js/tests/ecma/Number/15.7.3.6-2.js | 58 +- mozilla/js/tests/ecma/Number/15.7.3.6-3.js | 58 +- mozilla/js/tests/ecma/Number/15.7.3.6-4.js | 57 +- mozilla/js/tests/ecma/Number/15.7.3.js | 63 +- mozilla/js/tests/ecma/Number/15.7.4-1.js | 34 +- mozilla/js/tests/ecma/Number/15.7.4.1.js | 55 +- mozilla/js/tests/ecma/Number/15.7.4.2-1.js | 108 +- mozilla/js/tests/ecma/Number/15.7.4.2-2-n.js | 67 +- mozilla/js/tests/ecma/Number/15.7.4.2-3-n.js | 64 +- mozilla/js/tests/ecma/Number/15.7.4.2-4.js | 63 +- mozilla/js/tests/ecma/Number/15.7.4.3-1.js | 88 +- mozilla/js/tests/ecma/Number/15.7.4.3-2.js | 55 +- mozilla/js/tests/ecma/Number/15.7.4.3-3-n.js | 59 +- mozilla/js/tests/ecma/Number/15.7.4.js | 89 +- mozilla/js/tests/ecma/Number/browser.js | 0 mozilla/js/tests/ecma/Number/shell.js | 0 .../js/tests/ecma/ObjectObjects/15.2.1.1.js | 184 ++- .../js/tests/ecma/ObjectObjects/15.2.1.2.js | 87 +- .../js/tests/ecma/ObjectObjects/15.2.2.1.js | 194 ++-- .../js/tests/ecma/ObjectObjects/15.2.2.2.js | 74 +- .../js/tests/ecma/ObjectObjects/15.2.3-1.js | 53 +- .../js/tests/ecma/ObjectObjects/15.2.3.1-1.js | 58 +- .../js/tests/ecma/ObjectObjects/15.2.3.1-2.js | 59 +- .../js/tests/ecma/ObjectObjects/15.2.3.1-3.js | 58 +- .../js/tests/ecma/ObjectObjects/15.2.3.1-4.js | 59 +- mozilla/js/tests/ecma/ObjectObjects/15.2.3.js | 56 +- .../js/tests/ecma/ObjectObjects/15.2.4.1.js | 52 +- .../js/tests/ecma/ObjectObjects/15.2.4.2.js | 147 ++- .../js/tests/ecma/ObjectObjects/15.2.4.3.js | 149 ++- mozilla/js/tests/ecma/ObjectObjects/15.2.4.js | 47 +- .../js/tests/ecma/ObjectObjects/browser.js | 0 mozilla/js/tests/ecma/ObjectObjects/shell.js | 0 mozilla/js/tests/ecma/README | 1 + mozilla/js/tests/ecma/SourceText/6-1.js | 153 ++- mozilla/js/tests/ecma/SourceText/6-2.js | 155 ++- mozilla/js/tests/ecma/SourceText/browser.js | 0 mozilla/js/tests/ecma/SourceText/shell.js | 0 mozilla/js/tests/ecma/Statements/12.10-1.js | 207 ++-- mozilla/js/tests/ecma/Statements/12.10.js | 54 +- mozilla/js/tests/ecma/Statements/12.2-1.js | 67 +- mozilla/js/tests/ecma/Statements/12.5-1.js | 107 +- mozilla/js/tests/ecma/Statements/12.5-2.js | 108 +- mozilla/js/tests/ecma/Statements/12.6.1-1.js | 61 +- mozilla/js/tests/ecma/Statements/12.6.2-1.js | 61 +- mozilla/js/tests/ecma/Statements/12.6.2-2.js | 65 +- mozilla/js/tests/ecma/Statements/12.6.2-3.js | 54 +- mozilla/js/tests/ecma/Statements/12.6.2-4.js | 51 +- mozilla/js/tests/ecma/Statements/12.6.2-5.js | 59 +- mozilla/js/tests/ecma/Statements/12.6.2-6.js | 63 +- mozilla/js/tests/ecma/Statements/12.6.2-7.js | 58 +- mozilla/js/tests/ecma/Statements/12.6.2-8.js | 55 +- .../js/tests/ecma/Statements/12.6.2-9-n.js | 56 +- mozilla/js/tests/ecma/Statements/12.6.3-1.js | 61 +- mozilla/js/tests/ecma/Statements/12.6.3-10.js | 142 ++- mozilla/js/tests/ecma/Statements/12.6.3-11.js | 104 +- mozilla/js/tests/ecma/Statements/12.6.3-12.js | 119 +- mozilla/js/tests/ecma/Statements/12.6.3-19.js | 142 ++- mozilla/js/tests/ecma/Statements/12.6.3-2.js | 54 +- mozilla/js/tests/ecma/Statements/12.6.3-3.js | 60 +- mozilla/js/tests/ecma/Statements/12.6.3-4.js | 314 +++-- .../js/tests/ecma/Statements/12.6.3-5-n.js | 128 +-- .../js/tests/ecma/Statements/12.6.3-6-n.js | 129 +-- .../js/tests/ecma/Statements/12.6.3-7-n.js | 128 +-- .../js/tests/ecma/Statements/12.6.3-8-n.js | 128 +-- .../js/tests/ecma/Statements/12.6.3-9-n.js | 129 +-- mozilla/js/tests/ecma/Statements/12.7-1-n.js | 58 +- mozilla/js/tests/ecma/Statements/12.8-1-n.js | 59 +- mozilla/js/tests/ecma/Statements/12.9-1-n.js | 54 +- mozilla/js/tests/ecma/Statements/browser.js | 0 mozilla/js/tests/ecma/Statements/shell.js | 0 mozilla/js/tests/ecma/String/15.5.1.js | 165 ++- mozilla/js/tests/ecma/String/15.5.2.js | 162 ++- mozilla/js/tests/ecma/String/15.5.3.1-1.js | 63 +- mozilla/js/tests/ecma/String/15.5.3.1-2.js | 79 +- mozilla/js/tests/ecma/String/15.5.3.1-3.js | 73 +- mozilla/js/tests/ecma/String/15.5.3.1-4.js | 55 +- mozilla/js/tests/ecma/String/15.5.3.2-1.js | 298 +++-- mozilla/js/tests/ecma/String/15.5.3.2-2.js | 97 +- mozilla/js/tests/ecma/String/15.5.3.2-3.js | 158 ++- mozilla/js/tests/ecma/String/15.5.3.js | 65 +- mozilla/js/tests/ecma/String/15.5.4.1.js | 69 +- mozilla/js/tests/ecma/String/15.5.4.10-1.js | 284 +++-- mozilla/js/tests/ecma/String/15.5.4.11-1.js | 915 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.11-2.js | 911 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.11-3.js | 910 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.11-4.js | 903 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.11-5.js | 915 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.11-6.js | 910 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.12-1.js | 916 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.12-2.js | 915 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.12-3.js | 976 ++++++++-------- mozilla/js/tests/ecma/String/15.5.4.12-4.js | 911 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.12-5.js | 911 ++++++++------- mozilla/js/tests/ecma/String/15.5.4.2-1.js | 65 +- mozilla/js/tests/ecma/String/15.5.4.2-2-n.js | 68 +- mozilla/js/tests/ecma/String/15.5.4.2-3.js | 91 +- mozilla/js/tests/ecma/String/15.5.4.2.js | 120 +- mozilla/js/tests/ecma/String/15.5.4.3-1.js | 63 +- mozilla/js/tests/ecma/String/15.5.4.3-2.js | 119 +- mozilla/js/tests/ecma/String/15.5.4.3-3-n.js | 63 +- mozilla/js/tests/ecma/String/15.5.4.4-1.js | 96 +- mozilla/js/tests/ecma/String/15.5.4.4-2.js | 217 ++-- mozilla/js/tests/ecma/String/15.5.4.4-3.js | 169 ++- mozilla/js/tests/ecma/String/15.5.4.4-4.js | 211 ++-- mozilla/js/tests/ecma/String/15.5.4.5-1.js | 116 +- mozilla/js/tests/ecma/String/15.5.4.5-2.js | 189 ++-- mozilla/js/tests/ecma/String/15.5.4.5-3.js | 186 ++- mozilla/js/tests/ecma/String/15.5.4.5-4.js | 95 +- mozilla/js/tests/ecma/String/15.5.4.5-5.js | 134 +-- mozilla/js/tests/ecma/String/15.5.4.5-6.js | 110 +- mozilla/js/tests/ecma/String/15.5.4.6-1.js | 253 ++--- mozilla/js/tests/ecma/String/15.5.4.6-2.js | 414 ++++--- mozilla/js/tests/ecma/String/15.5.4.7-1.js | 301 +++-- mozilla/js/tests/ecma/String/15.5.4.7-2.js | 288 +++-- mozilla/js/tests/ecma/String/15.5.4.7-3.js | 188 ++- mozilla/js/tests/ecma/String/15.5.4.8-1.js | 406 ++++--- mozilla/js/tests/ecma/String/15.5.4.8-2.js | 380 +++---- mozilla/js/tests/ecma/String/15.5.4.8-3.js | 264 ++--- mozilla/js/tests/ecma/String/15.5.4.9-1.js | 345 +++--- mozilla/js/tests/ecma/String/15.5.4.js | 68 +- mozilla/js/tests/ecma/String/15.5.5.1.js | 119 +- mozilla/js/tests/ecma/String/browser.js | 0 mozilla/js/tests/ecma/String/shell.js | 0 mozilla/js/tests/ecma/TypeConversion/9.2.js | 135 +-- mozilla/js/tests/ecma/TypeConversion/9.3-1.js | 126 +-- .../js/tests/ecma/TypeConversion/9.3.1-1.js | 505 ++++----- .../js/tests/ecma/TypeConversion/9.3.1-2.js | 93 +- .../js/tests/ecma/TypeConversion/9.3.1-3.js | 1008 ++++++++--------- mozilla/js/tests/ecma/TypeConversion/9.3.js | 97 +- mozilla/js/tests/ecma/TypeConversion/9.4-1.js | 135 +-- mozilla/js/tests/ecma/TypeConversion/9.4-2.js | 135 +-- mozilla/js/tests/ecma/TypeConversion/9.5-2.js | 253 ++--- mozilla/js/tests/ecma/TypeConversion/9.6.js | 180 ++- mozilla/js/tests/ecma/TypeConversion/9.7.js | 203 ++-- mozilla/js/tests/ecma/TypeConversion/9.8.1.js | 228 ++-- mozilla/js/tests/ecma/TypeConversion/9.9-1.js | 172 ++- .../js/tests/ecma/TypeConversion/browser.js | 0 mozilla/js/tests/ecma/TypeConversion/shell.js | 0 mozilla/js/tests/ecma/Types/8.1.js | 67 +- mozilla/js/tests/ecma/Types/8.4.js | 158 ++- mozilla/js/tests/ecma/Types/8.6.2.1-1.js | 107 +- mozilla/js/tests/ecma/Types/browser.js | 0 mozilla/js/tests/ecma/Types/shell.js | 0 mozilla/js/tests/ecma/browser.js | 109 +- mozilla/js/tests/ecma/shell.js | 860 +++++++------- mozilla/js/tests/ecma/template.js | 53 + .../js/tests/ecma_2/Exceptions/boolean-001.js | 65 +- .../js/tests/ecma_2/Exceptions/boolean-002.js | 69 +- mozilla/js/tests/ecma_2/Exceptions/browser.js | 0 .../js/tests/ecma_2/Exceptions/date-001.js | 84 +- .../js/tests/ecma_2/Exceptions/date-002.js | 76 +- .../js/tests/ecma_2/Exceptions/date-003.js | 74 +- .../js/tests/ecma_2/Exceptions/date-004.js | 70 +- .../tests/ecma_2/Exceptions/exception-001.js | 50 +- .../tests/ecma_2/Exceptions/exception-002.js | 50 +- .../tests/ecma_2/Exceptions/exception-003.js | 58 +- .../tests/ecma_2/Exceptions/exception-004.js | 50 +- .../tests/ecma_2/Exceptions/exception-005.js | 50 +- .../tests/ecma_2/Exceptions/exception-006.js | 66 +- .../tests/ecma_2/Exceptions/exception-007.js | 68 +- .../tests/ecma_2/Exceptions/exception-008.js | 50 +- .../tests/ecma_2/Exceptions/exception-009.js | 62 +- .../ecma_2/Exceptions/exception-010-n.js | 25 +- .../ecma_2/Exceptions/exception-011-n.js | 25 +- .../tests/ecma_2/Exceptions/expression-001.js | 72 +- .../tests/ecma_2/Exceptions/expression-002.js | 80 +- .../tests/ecma_2/Exceptions/expression-003.js | 74 +- .../tests/ecma_2/Exceptions/expression-004.js | 68 +- .../tests/ecma_2/Exceptions/expression-005.js | 56 +- .../tests/ecma_2/Exceptions/expression-006.js | 64 +- .../tests/ecma_2/Exceptions/expression-007.js | 60 +- .../tests/ecma_2/Exceptions/expression-008.js | 60 +- .../tests/ecma_2/Exceptions/expression-009.js | 60 +- .../tests/ecma_2/Exceptions/expression-010.js | 60 +- .../tests/ecma_2/Exceptions/expression-011.js | 60 +- .../tests/ecma_2/Exceptions/expression-012.js | 64 +- .../tests/ecma_2/Exceptions/expression-013.js | 62 +- .../tests/ecma_2/Exceptions/expression-014.js | 62 +- .../tests/ecma_2/Exceptions/expression-015.js | 58 +- .../tests/ecma_2/Exceptions/expression-016.js | 58 +- .../tests/ecma_2/Exceptions/expression-017.js | 58 +- .../tests/ecma_2/Exceptions/expression-019.js | 62 +- .../tests/ecma_2/Exceptions/function-001.js | 19 +- .../js/tests/ecma_2/Exceptions/global-001.js | 63 +- .../js/tests/ecma_2/Exceptions/global-002.js | 63 +- .../js/tests/ecma_2/Exceptions/lexical-001.js | 76 +- .../js/tests/ecma_2/Exceptions/lexical-002.js | 76 +- .../js/tests/ecma_2/Exceptions/lexical-003.js | 59 +- .../js/tests/ecma_2/Exceptions/lexical-004.js | 70 +- .../js/tests/ecma_2/Exceptions/lexical-005.js | 71 +- .../js/tests/ecma_2/Exceptions/lexical-006.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-007.js | 70 +- .../js/tests/ecma_2/Exceptions/lexical-008.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-009.js | 73 +- .../js/tests/ecma_2/Exceptions/lexical-010.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-012.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-013.js | 73 +- .../js/tests/ecma_2/Exceptions/lexical-015.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-017.js | 73 +- .../js/tests/ecma_2/Exceptions/lexical-018.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-019.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-020.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-022.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-023.js | 74 +- .../js/tests/ecma_2/Exceptions/lexical-024.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-025.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-026.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-027.js | 82 +- .../js/tests/ecma_2/Exceptions/lexical-028.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-029.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-030.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-031.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-032.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-033.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-034.js | 78 +- .../js/tests/ecma_2/Exceptions/lexical-035.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-036.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-037.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-038.js | 80 +- .../js/tests/ecma_2/Exceptions/lexical-039.js | 64 +- .../js/tests/ecma_2/Exceptions/lexical-040.js | 64 +- .../js/tests/ecma_2/Exceptions/lexical-041.js | 68 +- .../js/tests/ecma_2/Exceptions/lexical-042.js | 68 +- .../js/tests/ecma_2/Exceptions/lexical-047.js | 70 +- .../js/tests/ecma_2/Exceptions/lexical-048.js | 62 +- .../js/tests/ecma_2/Exceptions/lexical-049.js | 72 +- .../js/tests/ecma_2/Exceptions/lexical-050.js | 60 +- .../js/tests/ecma_2/Exceptions/lexical-051.js | 56 +- .../js/tests/ecma_2/Exceptions/lexical-052.js | 64 +- .../js/tests/ecma_2/Exceptions/lexical-053.js | 64 +- .../js/tests/ecma_2/Exceptions/lexical-054.js | 68 +- .../js/tests/ecma_2/Exceptions/number-001.js | 80 +- .../js/tests/ecma_2/Exceptions/number-002.js | 70 +- .../js/tests/ecma_2/Exceptions/number-003.js | 72 +- mozilla/js/tests/ecma_2/Exceptions/shell.js | 0 .../tests/ecma_2/Exceptions/statement-001.js | 62 +- .../tests/ecma_2/Exceptions/statement-002.js | 112 +- .../tests/ecma_2/Exceptions/statement-003.js | 126 +-- .../tests/ecma_2/Exceptions/statement-004.js | 70 +- .../tests/ecma_2/Exceptions/statement-005.js | 72 +- .../tests/ecma_2/Exceptions/statement-006.js | 74 +- .../tests/ecma_2/Exceptions/statement-007.js | 58 +- .../tests/ecma_2/Exceptions/statement-008.js | 58 +- .../tests/ecma_2/Exceptions/statement-009.js | 56 +- .../js/tests/ecma_2/Exceptions/string-001.js | 76 +- .../js/tests/ecma_2/Exceptions/string-002.js | 72 +- .../ecma_2/Expressions/StrictEquality-001.js | 74 +- .../js/tests/ecma_2/Expressions/browser.js | 0 .../ecma_2/Expressions/instanceof-001.js | 161 ++- .../ecma_2/Expressions/instanceof-002.js | 156 ++- .../ecma_2/Expressions/instanceof-003-n.js | 126 +-- .../ecma_2/Expressions/instanceof-004-n.js | 125 +- .../ecma_2/Expressions/instanceof-005-n.js | 116 +- .../ecma_2/Expressions/instanceof-006.js | 114 +- mozilla/js/tests/ecma_2/Expressions/shell.js | 0 .../ecma_2/FunctionObjects/apply-001-n.js | 22 +- .../tests/ecma_2/FunctionObjects/browser.js | 0 .../js/tests/ecma_2/FunctionObjects/call-1.js | 55 +- .../js/tests/ecma_2/FunctionObjects/shell.js | 0 .../ecma_2/LexicalConventions/browser.js | 0 .../LexicalConventions/regexp-literals-001.js | 43 +- .../LexicalConventions/regexp-literals-002.js | 21 +- .../tests/ecma_2/LexicalConventions/shell.js | 0 mozilla/js/tests/ecma_2/README | 1 + mozilla/js/tests/ecma_2/RegExp/browser.js | 0 .../js/tests/ecma_2/RegExp/constructor-001.js | 95 +- mozilla/js/tests/ecma_2/RegExp/exec-001.js | 41 +- mozilla/js/tests/ecma_2/RegExp/exec-002.js | 267 ++--- .../js/tests/ecma_2/RegExp/function-001.js | 95 +- mozilla/js/tests/ecma_2/RegExp/hex-001.js | 85 +- .../js/tests/ecma_2/RegExp/multiline-001.js | 81 +- mozilla/js/tests/ecma_2/RegExp/octal-001.js | 95 +- mozilla/js/tests/ecma_2/RegExp/octal-002.js | 123 +- mozilla/js/tests/ecma_2/RegExp/octal-003.js | 89 +- .../js/tests/ecma_2/RegExp/properties-001.js | 105 +- .../js/tests/ecma_2/RegExp/properties-002.js | 71 +- .../ecma_2/RegExp/regexp-enumerate-001.js | 129 +-- mozilla/js/tests/ecma_2/RegExp/regress-001.js | 43 +- mozilla/js/tests/ecma_2/RegExp/shell.js | 0 mozilla/js/tests/ecma_2/RegExp/unicode-001.js | 71 +- mozilla/js/tests/ecma_2/Statements/browser.js | 0 .../js/tests/ecma_2/Statements/dowhile-001.js | 46 +- .../js/tests/ecma_2/Statements/dowhile-002.js | 82 +- .../js/tests/ecma_2/Statements/dowhile-003.js | 68 +- .../js/tests/ecma_2/Statements/dowhile-004.js | 80 +- .../js/tests/ecma_2/Statements/dowhile-005.js | 86 +- .../js/tests/ecma_2/Statements/dowhile-006.js | 116 +- .../js/tests/ecma_2/Statements/dowhile-007.js | 134 ++- .../js/tests/ecma_2/Statements/forin-001.js | 46 +- .../js/tests/ecma_2/Statements/forin-002.js | 108 +- mozilla/js/tests/ecma_2/Statements/if-001.js | 40 +- .../js/tests/ecma_2/Statements/label-001.js | 42 +- .../js/tests/ecma_2/Statements/label-002.js | 60 +- mozilla/js/tests/ecma_2/Statements/shell.js | 0 .../js/tests/ecma_2/Statements/switch-001.js | 88 +- .../js/tests/ecma_2/Statements/switch-002.js | 84 +- .../js/tests/ecma_2/Statements/switch-003.js | 70 +- .../js/tests/ecma_2/Statements/switch-004.js | 128 ++- mozilla/js/tests/ecma_2/Statements/try-001.js | 112 +- mozilla/js/tests/ecma_2/Statements/try-003.js | 120 +- mozilla/js/tests/ecma_2/Statements/try-004.js | 62 +- mozilla/js/tests/ecma_2/Statements/try-005.js | 68 +- mozilla/js/tests/ecma_2/Statements/try-006.js | 134 ++- mozilla/js/tests/ecma_2/Statements/try-007.js | 100 +- mozilla/js/tests/ecma_2/Statements/try-008.js | 70 +- mozilla/js/tests/ecma_2/Statements/try-009.js | 84 +- mozilla/js/tests/ecma_2/Statements/try-010.js | 98 +- mozilla/js/tests/ecma_2/Statements/try-012.js | 140 ++- .../js/tests/ecma_2/Statements/while-001.js | 42 +- .../js/tests/ecma_2/Statements/while-002.js | 116 +- .../js/tests/ecma_2/Statements/while-003.js | 118 +- .../js/tests/ecma_2/Statements/while-004.js | 368 +++--- mozilla/js/tests/ecma_2/String/browser.js | 0 mozilla/js/tests/ecma_2/String/match-001.js | 99 +- mozilla/js/tests/ecma_2/String/match-002.js | 201 ++-- mozilla/js/tests/ecma_2/String/match-003.js | 121 +- mozilla/js/tests/ecma_2/String/match-004.js | 197 ++-- mozilla/js/tests/ecma_2/String/replace-001.js | 93 +- mozilla/js/tests/ecma_2/String/shell.js | 0 mozilla/js/tests/ecma_2/String/split-001.js | 125 +- mozilla/js/tests/ecma_2/String/split-002.js | 343 +++--- mozilla/js/tests/ecma_2/String/split-003.js | 149 +-- mozilla/js/tests/ecma_2/browser.js | 107 +- mozilla/js/tests/ecma_2/instanceof/browser.js | 0 .../tests/ecma_2/instanceof/instanceof-002.js | 56 +- mozilla/js/tests/ecma_2/instanceof/shell.js | 0 mozilla/js/tests/ecma_2/shell.js | 304 ++--- mozilla/js/tests/ecma_2/template.js | 14 +- mozilla/js/tests/ecma_3/Array/browser.js | 0 mozilla/js/tests/ecma_3/Array/shell.js | 0 mozilla/js/tests/ecma_3/Date/15.9.5.3.js | 4 +- mozilla/js/tests/ecma_3/Date/15.9.5.4.js | 2 +- mozilla/js/tests/ecma_3/Date/15.9.5.5.js | 4 +- mozilla/js/tests/ecma_3/Date/15.9.5.6.js | 4 +- mozilla/js/tests/ecma_3/Date/15.9.5.7.js | 2 +- mozilla/js/tests/ecma_3/Date/browser.js | 98 ++ mozilla/js/tests/ecma_3/Date/shell.js | 835 +++++++------- .../tests/ecma_3/Exceptions/15.11.7.6-002.js | 9 +- .../tests/ecma_3/Exceptions/15.11.7.6-003.js | 9 +- .../js/tests/ecma_3/Exceptions/binding-001.js | 3 +- mozilla/js/tests/ecma_3/Exceptions/browser.js | 0 mozilla/js/tests/ecma_3/Exceptions/shell.js | 0 .../ecma_3/ExecutionContexts/10.1.3-1.js | 1 + .../tests/ecma_3/ExecutionContexts/browser.js | 0 .../tests/ecma_3/ExecutionContexts/shell.js | 0 .../js/tests/ecma_3/Expressions/browser.js | 0 mozilla/js/tests/ecma_3/Expressions/shell.js | 0 mozilla/js/tests/ecma_3/FunExpr/browser.js | 0 mozilla/js/tests/ecma_3/FunExpr/fe-001-n.js | 5 +- mozilla/js/tests/ecma_3/FunExpr/shell.js | 0 mozilla/js/tests/ecma_3/Function/browser.js | 0 mozilla/js/tests/ecma_3/Function/call-001.js | 1 + .../tests/ecma_3/Function/regress-104584.js | 5 +- mozilla/js/tests/ecma_3/Function/shell.js | 7 + mozilla/js/tests/ecma_3/Number/browser.js | 0 mozilla/js/tests/ecma_3/Number/shell.js | 0 .../tests/ecma_3/NumberFormatting/browser.js | 0 .../js/tests/ecma_3/NumberFormatting/shell.js | 0 mozilla/js/tests/ecma_3/Object/browser.js | 7 + mozilla/js/tests/ecma_3/Object/class-001.js | 2 +- mozilla/js/tests/ecma_3/Object/shell.js | 3 +- mozilla/js/tests/ecma_3/Operators/browser.js | 0 mozilla/js/tests/ecma_3/Operators/shell.js | 0 mozilla/js/tests/ecma_3/README | 1 + .../js/tests/ecma_3/RegExp/15.10.4.1-5-n.js | 48 +- mozilla/js/tests/ecma_3/RegExp/browser.js | 0 .../js/tests/ecma_3/RegExp/regress-228087.js | 353 ++++-- mozilla/js/tests/ecma_3/RegExp/shell.js | 27 +- mozilla/js/tests/ecma_3/Statements/browser.js | 0 .../tests/ecma_3/Statements/regress-121744.js | 8 +- .../tests/ecma_3/Statements/regress-131348.js | 8 +- mozilla/js/tests/ecma_3/Statements/shell.js | 0 mozilla/js/tests/ecma_3/String/browser.js | 0 mozilla/js/tests/ecma_3/String/shell.js | 0 mozilla/js/tests/ecma_3/Unicode/browser.js | 0 mozilla/js/tests/ecma_3/Unicode/shell.js | 0 mozilla/js/tests/ecma_3/Unicode/uc-002-n.js | 19 +- mozilla/js/tests/ecma_3/browser.js | 118 ++ mozilla/js/tests/ecma_3/shell.js | 19 +- mozilla/js/tests/ecma_3/template.js | 57 + mozilla/js/tests/importList.html | 50 +- mozilla/js/tests/importList.js | 50 + mozilla/js/tests/js-test-driver-begin.js | 99 ++ mozilla/js/tests/js-test-driver-end.js | 5 + mozilla/js/tests/js-test-driver-quirks.html | 18 + .../js/tests/js-test-driver-standards.html | 22 + mozilla/js/tests/js1_1/README | 1 + mozilla/js/tests/js1_1/browser.js | 102 +- mozilla/js/tests/js1_1/regress/browser.js | 0 .../js/tests/js1_1/regress/function-001.js | 59 +- mozilla/js/tests/js1_1/regress/shell.js | 0 mozilla/js/tests/js1_1/shell.js | 216 ++-- mozilla/js/tests/js1_2/Array/array_split_1.js | 64 +- mozilla/js/tests/js1_2/Array/browser.js | 0 mozilla/js/tests/js1_2/Array/general1.js | 62 +- mozilla/js/tests/js1_2/Array/general2.js | 87 +- mozilla/js/tests/js1_2/Array/shell.js | 0 mozilla/js/tests/js1_2/Array/slice.js | 167 ++- mozilla/js/tests/js1_2/Array/splice1.js | 214 ++-- mozilla/js/tests/js1_2/Array/splice2.js | 205 ++-- mozilla/js/tests/js1_2/Array/tostring_1.js | 170 ++- mozilla/js/tests/js1_2/Array/tostring_2.js | 83 +- mozilla/js/tests/js1_2/Objects/browser.js | 0 mozilla/js/tests/js1_2/Objects/shell.js | 0 .../js/tests/js1_2/Objects/toString-001.js | 93 +- mozilla/js/tests/js1_2/README | 1 + mozilla/js/tests/js1_2/String/browser.js | 0 mozilla/js/tests/js1_2/String/charCodeAt.js | 68 +- mozilla/js/tests/js1_2/String/concat.js | 86 +- mozilla/js/tests/js1_2/String/match.js | 50 +- mozilla/js/tests/js1_2/String/shell.js | 0 mozilla/js/tests/js1_2/String/slice.js | 168 ++- mozilla/js/tests/js1_2/browser.js | 110 +- .../tests/js1_2/function/Function_object.js | 79 +- mozilla/js/tests/js1_2/function/Number.js | 93 +- mozilla/js/tests/js1_2/function/String.js | 73 +- mozilla/js/tests/js1_2/function/browser.js | 0 .../js/tests/js1_2/function/definition-1.js | 69 +- .../js/tests/js1_2/function/function-001-n.js | 18 +- mozilla/js/tests/js1_2/function/length.js | 94 +- mozilla/js/tests/js1_2/function/nesting-1.js | 51 +- mozilla/js/tests/js1_2/function/nesting.js | 88 +- .../js/tests/js1_2/function/regexparg-1.js | 106 +- .../js/tests/js1_2/function/regexparg-2-n.js | 56 +- mozilla/js/tests/js1_2/function/shell.js | 0 mozilla/js/tests/js1_2/function/tostring-1.js | 114 +- mozilla/js/tests/js1_2/function/tostring-2.js | 161 ++- mozilla/js/tests/js1_2/operator/browser.js | 0 mozilla/js/tests/js1_2/operator/equality.js | 63 +- mozilla/js/tests/js1_2/operator/shell.js | 0 .../js/tests/js1_2/operator/strictEquality.js | 90 +- .../js1_2/regexp/RegExp_dollar_number.js | 48 +- mozilla/js/tests/js1_2/regexp/RegExp_input.js | 117 +- .../js1_2/regexp/RegExp_input_as_array.js | 118 +- .../js/tests/js1_2/regexp/RegExp_lastIndex.js | 87 +- .../js/tests/js1_2/regexp/RegExp_lastMatch.js | 90 +- .../js1_2/regexp/RegExp_lastMatch_as_array.js | 90 +- .../js/tests/js1_2/regexp/RegExp_lastParen.js | 115 +- .../js1_2/regexp/RegExp_lastParen_as_array.js | 115 +- .../tests/js1_2/regexp/RegExp_leftContext.js | 99 +- .../regexp/RegExp_leftContext_as_array.js | 99 +- .../js/tests/js1_2/regexp/RegExp_multiline.js | 155 ++- .../js1_2/regexp/RegExp_multiline_as_array.js | 154 ++- .../js/tests/js1_2/regexp/RegExp_object.js | 91 +- .../tests/js1_2/regexp/RegExp_rightContext.js | 99 +- .../regexp/RegExp_rightContext_as_array.js | 99 +- mozilla/js/tests/js1_2/regexp/alphanumeric.js | 161 ++- mozilla/js/tests/js1_2/regexp/asterisk.js | 119 +- mozilla/js/tests/js1_2/regexp/backslash.js | 81 +- mozilla/js/tests/js1_2/regexp/backspace.js | 79 +- mozilla/js/tests/js1_2/regexp/beginLine.js | 80 +- mozilla/js/tests/js1_2/regexp/browser.js | 0 .../js/tests/js1_2/regexp/character_class.js | 120 +- mozilla/js/tests/js1_2/regexp/compile.js | 97 +- .../tests/js1_2/regexp/control_characters.js | 68 +- mozilla/js/tests/js1_2/regexp/digit.js | 146 ++- mozilla/js/tests/js1_2/regexp/dot.js | 102 +- mozilla/js/tests/js1_2/regexp/endLine.js | 80 +- mozilla/js/tests/js1_2/regexp/everything.js | 76 +- mozilla/js/tests/js1_2/regexp/exec.js | 77 +- mozilla/js/tests/js1_2/regexp/flags.js | 96 +- mozilla/js/tests/js1_2/regexp/global.js | 103 +- mozilla/js/tests/js1_2/regexp/hexadecimal.js | 112 +- mozilla/js/tests/js1_2/regexp/ignoreCase.js | 126 +-- mozilla/js/tests/js1_2/regexp/interval.js | 133 +-- mozilla/js/tests/js1_2/regexp/octal.js | 112 +- mozilla/js/tests/js1_2/regexp/parentheses.js | 121 +- mozilla/js/tests/js1_2/regexp/plus.js | 91 +- .../js/tests/js1_2/regexp/question_mark.js | 109 +- mozilla/js/tests/js1_2/regexp/regress-6359.js | 67 +- mozilla/js/tests/js1_2/regexp/regress-9141.js | 72 +- mozilla/js/tests/js1_2/regexp/shell.js | 0 mozilla/js/tests/js1_2/regexp/simple_form.js | 97 +- mozilla/js/tests/js1_2/regexp/source.js | 90 +- .../tests/js1_2/regexp/special_characters.js | 178 ++- .../js/tests/js1_2/regexp/string_replace.js | 90 +- .../js/tests/js1_2/regexp/string_search.js | 91 +- mozilla/js/tests/js1_2/regexp/string_split.js | 96 +- mozilla/js/tests/js1_2/regexp/test.js | 91 +- mozilla/js/tests/js1_2/regexp/toString.js | 80 +- mozilla/js/tests/js1_2/regexp/vertical_bar.js | 102 +- mozilla/js/tests/js1_2/regexp/whitespace.js | 174 ++- .../js/tests/js1_2/regexp/word_boundary.js | 167 ++- mozilla/js/tests/js1_2/regress/browser.js | 0 .../js/tests/js1_2/regress/regress-144834.js | 4 +- .../js/tests/js1_2/regress/regress-7703.js | 90 +- mozilla/js/tests/js1_2/regress/shell.js | 0 mozilla/js/tests/js1_2/shell.js | 179 +-- mozilla/js/tests/js1_2/statements/break.js | 219 ++-- mozilla/js/tests/js1_2/statements/browser.js | 0 mozilla/js/tests/js1_2/statements/continue.js | 237 ++-- mozilla/js/tests/js1_2/statements/do_while.js | 62 +- mozilla/js/tests/js1_2/statements/shell.js | 0 mozilla/js/tests/js1_2/statements/switch.js | 152 ++- mozilla/js/tests/js1_2/statements/switch2.js | 263 ++--- .../js/tests/js1_2/version120/boolean-001.js | 38 +- mozilla/js/tests/js1_2/version120/browser.js | 21 + mozilla/js/tests/js1_2/version120/shell.js | 2 +- mozilla/js/tests/js1_3/Boolean/boolean-001.js | 38 +- mozilla/js/tests/js1_3/Boolean/browser.js | 0 mozilla/js/tests/js1_3/Boolean/shell.js | 0 mozilla/js/tests/js1_3/README | 1 + mozilla/js/tests/js1_3/Script/browser.js | 0 mozilla/js/tests/js1_3/Script/delete-001.js | 85 +- .../js/tests/js1_3/Script/function-001-n.js | 17 +- mozilla/js/tests/js1_3/Script/function-002.js | 69 +- mozilla/js/tests/js1_3/Script/in-001.js | 44 +- mozilla/js/tests/js1_3/Script/new-001.js | 168 ++- mozilla/js/tests/js1_3/Script/script-001.js | 187 ++- mozilla/js/tests/js1_3/Script/shell.js | 0 mozilla/js/tests/js1_3/Script/switch-001.js | 87 +- mozilla/js/tests/js1_3/browser.js | 108 ++ mozilla/js/tests/js1_3/inherit/browser.js | 0 mozilla/js/tests/js1_3/inherit/proto_1.js | 179 ++- mozilla/js/tests/js1_3/inherit/proto_10.js | 143 ++- mozilla/js/tests/js1_3/inherit/proto_11.js | 92 +- mozilla/js/tests/js1_3/inherit/proto_12.js | 125 +- mozilla/js/tests/js1_3/inherit/proto_2.js | 110 +- mozilla/js/tests/js1_3/inherit/proto_3.js | 81 +- mozilla/js/tests/js1_3/inherit/proto_4.js | 160 ++- mozilla/js/tests/js1_3/inherit/proto_5.js | 168 ++- mozilla/js/tests/js1_3/inherit/proto_6.js | 178 ++- mozilla/js/tests/js1_3/inherit/proto_7.js | 127 +-- mozilla/js/tests/js1_3/inherit/proto_8.js | 125 +- mozilla/js/tests/js1_3/inherit/proto_9.js | 97 +- mozilla/js/tests/js1_3/inherit/shell.js | 0 mozilla/js/tests/js1_3/misc/browser.js | 0 mozilla/js/tests/js1_3/misc/shell.js | 0 mozilla/js/tests/js1_3/regress/browser.js | 0 mozilla/js/tests/js1_3/regress/delete-001.js | 85 +- .../js/tests/js1_3/regress/function-001-n.js | 17 +- .../js/tests/js1_3/regress/function-002.js | 69 +- mozilla/js/tests/js1_3/regress/in-001.js | 57 +- mozilla/js/tests/js1_3/regress/new-001.js | 168 ++- mozilla/js/tests/js1_3/regress/shell.js | 0 mozilla/js/tests/js1_3/regress/switch-001.js | 87 +- mozilla/js/tests/js1_3/shell.js | 294 +++-- mozilla/js/tests/js1_4/Eval/browser.js | 0 mozilla/js/tests/js1_4/Eval/eval-001.js | 36 +- mozilla/js/tests/js1_4/Eval/eval-002.js | 29 +- mozilla/js/tests/js1_4/Eval/eval-003.js | 44 +- mozilla/js/tests/js1_4/Eval/shell.js | 0 mozilla/js/tests/js1_4/Functions/browser.js | 0 .../js/tests/js1_4/Functions/function-001.js | 85 +- mozilla/js/tests/js1_4/Functions/shell.js | 0 mozilla/js/tests/js1_4/README | 1 + mozilla/js/tests/js1_4/Regress/browser.js | 0 mozilla/js/tests/js1_4/Regress/date-001-n.js | 41 +- .../js/tests/js1_4/Regress/function-001.js | 67 +- .../js/tests/js1_4/Regress/function-002.js | 115 +- .../js/tests/js1_4/Regress/function-003.js | 77 +- .../js/tests/js1_4/Regress/function-004-n.js | 32 +- .../js/tests/js1_4/Regress/regress-7224.js | 73 +- mozilla/js/tests/js1_4/Regress/shell.js | 0 .../js/tests/js1_4/Regress/toString-001-n.js | 34 +- mozilla/js/tests/js1_4/browser.js | 104 +- mozilla/js/tests/js1_4/shell.js | 268 +++-- mozilla/js/tests/js1_5/Array/browser.js | 0 mozilla/js/tests/js1_5/Array/shell.js | 0 mozilla/js/tests/js1_5/Exceptions/browser.js | 0 .../js1_5/Exceptions/catchguard-001-n.js | 3 + .../js1_5/Exceptions/catchguard-002-n.js | 5 + .../js1_5/Exceptions/catchguard-003-n.js | 3 + mozilla/js/tests/js1_5/Exceptions/shell.js | 0 mozilla/js/tests/js1_5/Expressions/browser.js | 0 mozilla/js/tests/js1_5/Expressions/shell.js | 1 + mozilla/js/tests/js1_5/Function/browser.js | 0 mozilla/js/tests/js1_5/Function/shell.js | 0 mozilla/js/tests/js1_5/GetSet/browser.js | 0 mozilla/js/tests/js1_5/GetSet/shell.js | 0 .../tests/js1_5/LexicalConventions/browser.js | 0 .../tests/js1_5/LexicalConventions/shell.js | 0 mozilla/js/tests/js1_5/Object/browser.js | 0 mozilla/js/tests/js1_5/Object/shell.js | 0 mozilla/js/tests/js1_5/README | 1 + mozilla/js/tests/js1_5/Regress/browser.js | 0 .../js/tests/js1_5/Regress/regress-104077.js | 40 +- .../js/tests/js1_5/Regress/regress-168347.js | 20 +- .../tests/js1_5/Regress/regress-68498-001.js | 5 +- .../js/tests/js1_5/Regress/regress-80981.js | 12 +- .../tests/js1_5/Regress/regress-96526-003.js | 714 ++++++------ mozilla/js/tests/js1_5/Regress/shell.js | 0 mozilla/js/tests/js1_5/Scope/browser.js | 0 mozilla/js/tests/js1_5/Scope/shell.js | 0 mozilla/js/tests/js1_5/String/browser.js | 0 mozilla/js/tests/js1_5/String/shell.js | 0 mozilla/js/tests/js1_5/browser.js | 122 ++ mozilla/js/tests/js1_5/shell.js | 16 +- mozilla/js/tests/js1_5/template.js | 57 + mozilla/js/tests/jsDriver.pl | 16 +- mozilla/js/tests/menuhead.html | 160 +-- mozilla/js/tests/menuhead.js | 748 ++++++++++++ mozilla/js/tests/mklistpage.pl | 148 ++- mozilla/js/tests/runRhinoTests.pl | 2 +- mozilla/js/tests/runtests.pl | 2 +- 1100 files changed, 56679 insertions(+), 62488 deletions(-) create mode 100644 mozilla/js/tests/e4x/Expressions/browser.js create mode 100644 mozilla/js/tests/e4x/Expressions/shell.js create mode 100644 mozilla/js/tests/e4x/Global/browser.js create mode 100644 mozilla/js/tests/e4x/Global/shell.js create mode 100644 mozilla/js/tests/e4x/Namespace/browser.js create mode 100644 mozilla/js/tests/e4x/Namespace/shell.js create mode 100644 mozilla/js/tests/e4x/QName/browser.js create mode 100644 mozilla/js/tests/e4x/QName/shell.js create mode 100644 mozilla/js/tests/e4x/Regress/browser.js create mode 100644 mozilla/js/tests/e4x/Regress/shell.js create mode 100644 mozilla/js/tests/e4x/Statements/browser.js create mode 100644 mozilla/js/tests/e4x/Statements/shell.js create mode 100644 mozilla/js/tests/e4x/TypeConversion/browser.js create mode 100644 mozilla/js/tests/e4x/TypeConversion/shell.js create mode 100644 mozilla/js/tests/e4x/Types/browser.js create mode 100644 mozilla/js/tests/e4x/Types/shell.js create mode 100644 mozilla/js/tests/e4x/XML/browser.js create mode 100644 mozilla/js/tests/e4x/XML/shell.js create mode 100644 mozilla/js/tests/e4x/XMLList/browser.js create mode 100644 mozilla/js/tests/e4x/XMLList/shell.js create mode 100644 mozilla/js/tests/e4x/browser.js create mode 100755 mozilla/js/tests/e4x/template.js create mode 100644 mozilla/js/tests/ecma/Array/browser.js create mode 100644 mozilla/js/tests/ecma/Array/shell.js create mode 100644 mozilla/js/tests/ecma/Boolean/browser.js create mode 100644 mozilla/js/tests/ecma/Boolean/shell.js create mode 100644 mozilla/js/tests/ecma/Date/browser.js create mode 100644 mozilla/js/tests/ecma/Date/shell.js create mode 100644 mozilla/js/tests/ecma/ExecutionContexts/browser.js create mode 100644 mozilla/js/tests/ecma/ExecutionContexts/shell.js create mode 100644 mozilla/js/tests/ecma/Expressions/browser.js create mode 100644 mozilla/js/tests/ecma/Expressions/shell.js create mode 100644 mozilla/js/tests/ecma/FunctionObjects/browser.js create mode 100644 mozilla/js/tests/ecma/FunctionObjects/shell.js create mode 100644 mozilla/js/tests/ecma/GlobalObject/browser.js create mode 100644 mozilla/js/tests/ecma/GlobalObject/shell.js create mode 100644 mozilla/js/tests/ecma/LexicalConventions/browser.js create mode 100644 mozilla/js/tests/ecma/LexicalConventions/shell.js create mode 100644 mozilla/js/tests/ecma/Math/browser.js create mode 100644 mozilla/js/tests/ecma/Math/shell.js create mode 100644 mozilla/js/tests/ecma/NativeObjects/browser.js create mode 100644 mozilla/js/tests/ecma/NativeObjects/shell.js create mode 100644 mozilla/js/tests/ecma/Number/browser.js create mode 100644 mozilla/js/tests/ecma/Number/shell.js create mode 100644 mozilla/js/tests/ecma/ObjectObjects/browser.js create mode 100644 mozilla/js/tests/ecma/ObjectObjects/shell.js create mode 100755 mozilla/js/tests/ecma/README create mode 100644 mozilla/js/tests/ecma/SourceText/browser.js create mode 100644 mozilla/js/tests/ecma/SourceText/shell.js create mode 100644 mozilla/js/tests/ecma/Statements/browser.js create mode 100644 mozilla/js/tests/ecma/Statements/shell.js create mode 100644 mozilla/js/tests/ecma/String/browser.js create mode 100644 mozilla/js/tests/ecma/String/shell.js create mode 100644 mozilla/js/tests/ecma/TypeConversion/browser.js create mode 100644 mozilla/js/tests/ecma/TypeConversion/shell.js create mode 100644 mozilla/js/tests/ecma/Types/browser.js create mode 100644 mozilla/js/tests/ecma/Types/shell.js create mode 100644 mozilla/js/tests/ecma/template.js create mode 100644 mozilla/js/tests/ecma_2/Exceptions/browser.js create mode 100644 mozilla/js/tests/ecma_2/Exceptions/shell.js create mode 100644 mozilla/js/tests/ecma_2/Expressions/browser.js create mode 100644 mozilla/js/tests/ecma_2/Expressions/shell.js create mode 100644 mozilla/js/tests/ecma_2/FunctionObjects/browser.js create mode 100644 mozilla/js/tests/ecma_2/FunctionObjects/shell.js create mode 100644 mozilla/js/tests/ecma_2/LexicalConventions/browser.js create mode 100644 mozilla/js/tests/ecma_2/LexicalConventions/shell.js create mode 100755 mozilla/js/tests/ecma_2/README create mode 100644 mozilla/js/tests/ecma_2/RegExp/browser.js create mode 100644 mozilla/js/tests/ecma_2/RegExp/shell.js create mode 100644 mozilla/js/tests/ecma_2/Statements/browser.js create mode 100644 mozilla/js/tests/ecma_2/Statements/shell.js create mode 100644 mozilla/js/tests/ecma_2/String/browser.js create mode 100644 mozilla/js/tests/ecma_2/String/shell.js create mode 100644 mozilla/js/tests/ecma_2/instanceof/browser.js create mode 100644 mozilla/js/tests/ecma_2/instanceof/shell.js create mode 100644 mozilla/js/tests/ecma_3/Array/browser.js create mode 100644 mozilla/js/tests/ecma_3/Array/shell.js create mode 100644 mozilla/js/tests/ecma_3/Date/browser.js create mode 100644 mozilla/js/tests/ecma_3/Exceptions/browser.js create mode 100644 mozilla/js/tests/ecma_3/Exceptions/shell.js create mode 100644 mozilla/js/tests/ecma_3/ExecutionContexts/browser.js create mode 100644 mozilla/js/tests/ecma_3/ExecutionContexts/shell.js create mode 100644 mozilla/js/tests/ecma_3/Expressions/browser.js create mode 100644 mozilla/js/tests/ecma_3/Expressions/shell.js create mode 100644 mozilla/js/tests/ecma_3/FunExpr/browser.js create mode 100644 mozilla/js/tests/ecma_3/FunExpr/shell.js create mode 100644 mozilla/js/tests/ecma_3/Function/browser.js create mode 100644 mozilla/js/tests/ecma_3/Function/shell.js create mode 100644 mozilla/js/tests/ecma_3/Number/browser.js create mode 100644 mozilla/js/tests/ecma_3/Number/shell.js create mode 100644 mozilla/js/tests/ecma_3/NumberFormatting/browser.js create mode 100644 mozilla/js/tests/ecma_3/NumberFormatting/shell.js create mode 100644 mozilla/js/tests/ecma_3/Object/browser.js create mode 100644 mozilla/js/tests/ecma_3/Operators/browser.js create mode 100644 mozilla/js/tests/ecma_3/Operators/shell.js create mode 100755 mozilla/js/tests/ecma_3/README create mode 100644 mozilla/js/tests/ecma_3/RegExp/browser.js create mode 100644 mozilla/js/tests/ecma_3/Statements/browser.js create mode 100644 mozilla/js/tests/ecma_3/Statements/shell.js create mode 100644 mozilla/js/tests/ecma_3/String/browser.js create mode 100644 mozilla/js/tests/ecma_3/String/shell.js create mode 100644 mozilla/js/tests/ecma_3/Unicode/browser.js create mode 100644 mozilla/js/tests/ecma_3/Unicode/shell.js create mode 100755 mozilla/js/tests/ecma_3/browser.js create mode 100755 mozilla/js/tests/ecma_3/template.js create mode 100644 mozilla/js/tests/importList.js create mode 100644 mozilla/js/tests/js-test-driver-begin.js create mode 100644 mozilla/js/tests/js-test-driver-end.js create mode 100644 mozilla/js/tests/js-test-driver-quirks.html create mode 100644 mozilla/js/tests/js-test-driver-standards.html create mode 100755 mozilla/js/tests/js1_1/README create mode 100644 mozilla/js/tests/js1_1/regress/browser.js create mode 100644 mozilla/js/tests/js1_1/regress/shell.js create mode 100644 mozilla/js/tests/js1_2/Array/browser.js create mode 100644 mozilla/js/tests/js1_2/Array/shell.js create mode 100644 mozilla/js/tests/js1_2/Objects/browser.js create mode 100644 mozilla/js/tests/js1_2/Objects/shell.js create mode 100755 mozilla/js/tests/js1_2/README create mode 100644 mozilla/js/tests/js1_2/String/browser.js create mode 100644 mozilla/js/tests/js1_2/String/shell.js create mode 100644 mozilla/js/tests/js1_2/function/browser.js create mode 100644 mozilla/js/tests/js1_2/function/shell.js create mode 100644 mozilla/js/tests/js1_2/operator/browser.js create mode 100644 mozilla/js/tests/js1_2/operator/shell.js create mode 100644 mozilla/js/tests/js1_2/regexp/browser.js create mode 100644 mozilla/js/tests/js1_2/regexp/shell.js create mode 100644 mozilla/js/tests/js1_2/regress/browser.js create mode 100644 mozilla/js/tests/js1_2/regress/shell.js create mode 100644 mozilla/js/tests/js1_2/statements/browser.js create mode 100644 mozilla/js/tests/js1_2/statements/shell.js create mode 100644 mozilla/js/tests/js1_2/version120/browser.js create mode 100644 mozilla/js/tests/js1_3/Boolean/browser.js create mode 100644 mozilla/js/tests/js1_3/Boolean/shell.js create mode 100755 mozilla/js/tests/js1_3/README create mode 100644 mozilla/js/tests/js1_3/Script/browser.js create mode 100644 mozilla/js/tests/js1_3/Script/shell.js create mode 100644 mozilla/js/tests/js1_3/browser.js create mode 100644 mozilla/js/tests/js1_3/inherit/browser.js create mode 100644 mozilla/js/tests/js1_3/inherit/shell.js create mode 100644 mozilla/js/tests/js1_3/misc/browser.js create mode 100644 mozilla/js/tests/js1_3/misc/shell.js create mode 100644 mozilla/js/tests/js1_3/regress/browser.js create mode 100644 mozilla/js/tests/js1_3/regress/shell.js create mode 100644 mozilla/js/tests/js1_4/Eval/browser.js create mode 100644 mozilla/js/tests/js1_4/Eval/shell.js create mode 100644 mozilla/js/tests/js1_4/Functions/browser.js create mode 100644 mozilla/js/tests/js1_4/Functions/shell.js create mode 100755 mozilla/js/tests/js1_4/README create mode 100644 mozilla/js/tests/js1_4/Regress/browser.js create mode 100644 mozilla/js/tests/js1_4/Regress/shell.js create mode 100644 mozilla/js/tests/js1_5/Array/browser.js create mode 100644 mozilla/js/tests/js1_5/Array/shell.js create mode 100644 mozilla/js/tests/js1_5/Exceptions/browser.js create mode 100644 mozilla/js/tests/js1_5/Exceptions/shell.js create mode 100644 mozilla/js/tests/js1_5/Expressions/browser.js create mode 100644 mozilla/js/tests/js1_5/Function/browser.js create mode 100644 mozilla/js/tests/js1_5/Function/shell.js create mode 100644 mozilla/js/tests/js1_5/GetSet/browser.js create mode 100644 mozilla/js/tests/js1_5/GetSet/shell.js create mode 100644 mozilla/js/tests/js1_5/LexicalConventions/browser.js create mode 100644 mozilla/js/tests/js1_5/LexicalConventions/shell.js create mode 100644 mozilla/js/tests/js1_5/Object/browser.js create mode 100644 mozilla/js/tests/js1_5/Object/shell.js create mode 100755 mozilla/js/tests/js1_5/README create mode 100644 mozilla/js/tests/js1_5/Regress/browser.js create mode 100644 mozilla/js/tests/js1_5/Regress/shell.js create mode 100644 mozilla/js/tests/js1_5/Scope/browser.js create mode 100644 mozilla/js/tests/js1_5/Scope/shell.js create mode 100644 mozilla/js/tests/js1_5/String/browser.js create mode 100644 mozilla/js/tests/js1_5/String/shell.js create mode 100755 mozilla/js/tests/js1_5/browser.js create mode 100755 mozilla/js/tests/js1_5/template.js create mode 100644 mozilla/js/tests/menuhead.js diff --git a/mozilla/js/tests/Makefile b/mozilla/js/tests/Makefile index 9c11ef2c32b..13a3360c454 100644 --- a/mozilla/js/tests/Makefile +++ b/mozilla/js/tests/Makefile @@ -1,8 +1,10 @@ +JS = $(shell find . -name '*.js' -print) -testmenu: +all: menu.html + +menu.html: menuhead.html menufoot.html $(JS) Makefile exec perl mklistpage.pl > menubody.html cat menuhead.html menubody.html menufoot.html > menu.html -testmenu_dos: - perl mklistpage.pl > menubody.html - type menuhead.html menubody.html menufoot.html > menu.html +clean: + rm -f menubody.html menu.html diff --git a/mozilla/js/tests/e4x/Expressions/browser.js b/mozilla/js/tests/e4x/Expressions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Expressions/shell.js b/mozilla/js/tests/e4x/Expressions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Global/browser.js b/mozilla/js/tests/e4x/Global/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Global/shell.js b/mozilla/js/tests/e4x/Global/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Namespace/browser.js b/mozilla/js/tests/e4x/Namespace/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Namespace/shell.js b/mozilla/js/tests/e4x/Namespace/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/QName/browser.js b/mozilla/js/tests/e4x/QName/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/QName/shell.js b/mozilla/js/tests/e4x/QName/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Regress/browser.js b/mozilla/js/tests/e4x/Regress/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Regress/shell.js b/mozilla/js/tests/e4x/Regress/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Statements/browser.js b/mozilla/js/tests/e4x/Statements/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Statements/shell.js b/mozilla/js/tests/e4x/Statements/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/TypeConversion/browser.js b/mozilla/js/tests/e4x/TypeConversion/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/TypeConversion/shell.js b/mozilla/js/tests/e4x/TypeConversion/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Types/browser.js b/mozilla/js/tests/e4x/Types/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/Types/shell.js b/mozilla/js/tests/e4x/Types/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/XML/browser.js b/mozilla/js/tests/e4x/XML/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/XML/shell.js b/mozilla/js/tests/e4x/XML/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/XMLList/browser.js b/mozilla/js/tests/e4x/XMLList/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/XMLList/shell.js b/mozilla/js/tests/e4x/XMLList/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/e4x/browser.js b/mozilla/js/tests/e4x/browser.js new file mode 100644 index 00000000000..3b3935f8b97 --- /dev/null +++ b/mozilla/js/tests/e4x/browser.js @@ -0,0 +1,182 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ +function writeLineToLog( string ) { + document.write( string + "
\n"); +} + +function print( string ) { + writeLineToLog( string ); +} + +var testcases = new Array(); +var tc = testcases.length; +var BUGSTR = ''; +var SUMMARY = ''; +var DESCRIPTION = ''; +var EXPECTED = ''; +var ACTUAL = ''; +var MSG = ''; +var SECTION = ''; + +function TestCase(n, d, e, a) +{ + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = ( e == a ); + this.reason = ''; + this.bugnumber = typeof(BUGSTR) != 'undefined' ? BUGSTR : ''; + testcases[tc++] = this; +} + +function reportSuccess(section, expected, actual) +{ + var testcase = new TestCase(gTestName, SUMMARY + DESCRIPTION + ' Section ' + section, expected, actual); + testcase.passed = true; +}; + +function reportError(msg, page, line) +{ + var testcase; + + if (typeof SUMMARY == 'undefined') + { + SUMMARY = 'Unknown'; + } + if (typeof SECTION == 'undefined') + { + SECTION = 'Unknown'; + } + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + + testcase = new TestCase(gTestName, SUMMARY + DESCRIPTION + ' Section ' + SECTION, EXPECTED, "error"); + + testcase.passed = false; + testcase.reason += msg; + + if (typeof(page) != 'undefined') + { + testcase.reason += ' Page: ' + page; + } + if (typeof(line) != 'undefined') + { + testcase.reason += ' Line: ' + line; + } + reportFailure(SECTION, msg); + +}; + + +var _reportFailure = reportFailure; +reportFailure = function (section, msg) +{ + var testcase; + + testcase = new TestCase(gTestName, SUMMARY + DESCRIPTION + ' Section ' + section, EXPECTED, ACTUAL); + + testcase.passed = false; + testcase.reason += msg; + + _reportFailure(section, msg); + +}; + + +var _printBugNumber = printBugNumber; +printBugNumber = function (num) +{ + BUGSTR = BUGNUMBER + num; + _printBugNumber(num); +} + +var _START = START; +START = function (summary) +{ + SUMMARY = summary; + printStatus(summary); +} + +var _TEST = TEST; +TEST = function (section, expected, actual) +{ + SECTION = section; + EXPECTED = expected; + ACTUAL = actual; + if (_TEST(section, expected, actual)) + { + reportSuccess(section, expected, actual); + } +} + +var _TEST_XML = TEST_XML; +TEST_XML = function (section, expected, actual) +{ + SECTION = section; + EXPECTED = expected; + ACTUAL = actual; + if (_TEST_XML(section, expected, actual)) + { + reportSuccess(section, expected, actual); + } +} + +function gc() +{ +} + +function quit() +{ +} + +// override NL from shell.js. +// assume running either on unix with \n line endings +// or on windows under cygwin with \n line endings. + +function NL() +{ + return '\n'; +} + +window.onerror = reportError; diff --git a/mozilla/js/tests/e4x/shell.js b/mozilla/js/tests/e4x/shell.js index 65d03aac85e..88308554a33 100644 --- a/mozilla/js/tests/e4x/shell.js +++ b/mozilla/js/tests/e4x/shell.js @@ -138,7 +138,9 @@ function TEST(section, expected, actual) if (output != "") { reportFailure (section, output); + return false; } + return true; } function TEST_XML(section, expected, actual) @@ -148,17 +150,19 @@ function TEST_XML(section, expected, actual) if (actual_t != "xml") { // force error on type mismatch - TEST(section, new XML(), actual); - return; + return TEST(section, new XML(), actual); } if (expected_t == "string") { - TEST(section, expected, actual.toXMLString()); - } else if (expected_t == "number") { - TEST(section, String(expected), actual.toXMLString()); - } else { - reportFailure (section, "Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string"); + return TEST(section, expected, actual.toXMLString()); } + + if (expected_t == "number") { + return TEST(section, String(expected), actual.toXMLString()); + } + + reportFailure (section, "Bad TEST_XML usage: type of expected is "+expected_t+", should be number or string"); + return false; } function SHOULD_THROW(section) diff --git a/mozilla/js/tests/e4x/template.js b/mozilla/js/tests/e4x/template.js new file mode 100755 index 00000000000..803345c1155 --- /dev/null +++ b/mozilla/js/tests/e4x/template.js @@ -0,0 +1,49 @@ +/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- *//* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +START("section - description"); + +var bug = 99999; +var summary = ''; +var actual = ''; +var expect = ''; + +printBugNumber (bug); +printStatus (summary); + +// test here + +END(); diff --git a/mozilla/js/tests/ecma/Array/15.4-1.js b/mozilla/js/tests/ecma/Array/15.4-1.js index fab7c85e4b0..733e3ce769d 100644 --- a/mozilla/js/tests/ecma/Array/15.4-1.js +++ b/mozilla/js/tests/ecma/Array/15.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,108 +35,97 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4-1.js - ECMA Section: 15.4 Array Objects + File Name: 15.4-1.js + ECMA Section: 15.4 Array Objects - Description: Every Array object has a length property whose value - is always an integer with positive sign and less than - Math.pow(2,32). + Description: Every Array object has a length property whose value + is always an integer with positive sign and less than + Math.pow(2,32). - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array Objects"; +var SECTION = "15.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Objects"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]") + ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length", + (Math.pow(2,32)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length") + ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]", - "hi", - eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr[Math.pow(2,32)-2]") - ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length", - (Math.pow(2,32)-1), - eval("var myarr = new Array(); myarr[Math.pow(2,32)-2]='hi'; myarr.length") - ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]", - "hi", - eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]") - ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length", - (Math.pow(2,32)-2), - eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length") - ); +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr[Math.pow(2,32)-3]") + ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]", - "hi", - eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]") - ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length", - (Math.pow(2,31)-1), - eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length") - ); +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length", + (Math.pow(2,32)-2), + eval("var myarr = new Array(); myarr[Math.pow(2,32)-3]='hi'; myarr.length") + ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]", - "hi", - eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]") - ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length", - (Math.pow(2,31)), - eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length") - ); +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr[Math.pow(2,31)-2]") + ); +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length", + (Math.pow(2,31)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,31)-2]='hi'; myarr.length") + ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]", - "hi", - eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]") - ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length", - (Math.pow(2,31)+1), - eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length") - ); +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr[Math.pow(2,31)-1]") + ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]", - "hi", - eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]") - ); - array[item++] = new TestCase( SECTION, - "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length", - (Math.pow(2,30)-1), - eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length") - ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length", + (Math.pow(2,31)), + eval("var myarr = new Array(); myarr[Math.pow(2,31)-1]='hi'; myarr.length") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr[Math.pow(2,31)]") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length", + (Math.pow(2,31)+1), + eval("var myarr = new Array(); myarr[Math.pow(2,31)]='hi'; myarr.length") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]", + "hi", + eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr[Math.pow(2,30)-2]") + ); + +new TestCase(SECTION, + "var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length", + (Math.pow(2,30)-1), + eval("var myarr = new Array(); myarr[Math.pow(2,30)-2]='hi'; myarr.length") + ); + +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Array/15.4-2.js b/mozilla/js/tests/ecma/Array/15.4-2.js index 54f36305965..ad216f3c004 100644 --- a/mozilla/js/tests/ecma/Array/15.4-2.js +++ b/mozilla/js/tests/ecma/Array/15.4-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,78 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4-2.js - ECMA Section: 15.4 Array Objects +File Name: 15.4-2.js +ECMA Section: 15.4 Array Objects - Description: Whenever a property is added whose name is an array - index, the length property is changed, if necessary, - to be one more than the numeric value of that array - index; and whenever the length property is changed, - every property whose name is an array index whose value - is not smaller than the new length is automatically - deleted. This constraint applies only to the Array - object itself, and is unaffected by length or array - index properties that may be inherited from its - prototype. +Description: Whenever a property is added whose name is an array +index, the length property is changed, if necessary, +to be one more than the numeric value of that array +index; and whenever the length property is changed, +every property whose name is an array index whose value +is not smaller than the new length is automatically +deleted. This constraint applies only to the Array +object itself, and is unaffected by length or array +index properties that may be inherited from its +prototype. - Author: christine@netscape.com - Date: 28 october 1997 +Author: christine@netscape.com +Date: 28 october 1997 */ - var SECTION = "15.4-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array Objects"; +var SECTION = "15.4-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Objects"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length", + Math.pow(2,16)+1, + eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length", + Math.pow(2,30)-1, + eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") ); - array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length", Math.pow(2,16)+1, eval("var arr=new Array(); arr[Math.pow(2,16)] = 'hi'; arr.length") ); +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length", + Math.pow(2,30), + eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") ); - array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length", Math.pow(2,30)-1, eval("var arr=new Array(); arr[Math.pow(2,30)-2] = 'hi'; arr.length") ); - array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length", Math.pow(2,30), eval("var arr=new Array(); arr[Math.pow(2,30)-1] = 'hi'; arr.length") ); - array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length", Math.pow(2,30)+1, eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") ); +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length", + Math.pow(2,30)+1, + eval("var arr=new Array(); arr[Math.pow(2,30)] = 'hi'; arr.length") ); - array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length", Math.pow(2,31)-1, eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") ); - array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length", Math.pow(2,31), eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") ); - array[item++] = new TestCase( SECTION, "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length", Math.pow(2,31)+1, eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") ); - array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)", "0,1", eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") ); - array[item++] = new TestCase( SECTION, "var arr = new Array(0,1); arr.length = 3; String(arr)", "0,1,", eval("var arr = new Array(0,1); arr.length = 3; String(arr)") ); -// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[0]; arr.length") ); -// array[item++] = new TestCase( SECTION, "var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length", 5, eval("var arr = new Array(0,1,2,3,4,5); delete arr[6]; arr.length") ); +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length", + Math.pow(2,31)-1, + eval("var arr=new Array(); arr[Math.pow(2,31)-2] = 'hi'; arr.length") ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length", + Math.pow(2,31), + eval("var arr=new Array(); arr[Math.pow(2,31)-1] = 'hi'; arr.length") ); + +new TestCase( SECTION, + "var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length", + Math.pow(2,31)+1, + eval("var arr=new Array(); arr[Math.pow(2,31)] = 'hi'; arr.length") ); + +new TestCase( SECTION, + "var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)", + "0,1", + eval("var arr = new Array(0,1,2,3,4,5); arr.length = 2; String(arr)") ); + +new TestCase( SECTION, + "var arr = new Array(0,1); arr.length = 3; String(arr)", + "0,1,", + eval("var arr = new Array(0,1); arr.length = 3; String(arr)") ); + +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Array/15.4.1.1.js b/mozilla/js/tests/ecma/Array/15.4.1.1.js index e03ec612e63..824e5b00dbd 100644 --- a/mozilla/js/tests/ecma/Array/15.4.1.1.js +++ b/mozilla/js/tests/ecma/Array/15.4.1.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,70 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.1.1.js - ECMA Section: 15.4.1 Array( item0, item1,... ) + File Name: 15.4.1.1.js + ECMA Section: 15.4.1 Array( item0, item1,... ) - Description: When Array is called as a function rather than as a - constructor, it creates and initializes a new array - object. Thus, the function call Array(...) is - equivalent to the object creation new Array(...) with - the same arguments. + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creation new Array(...) with + the same arguments. - An array is created and returned as if by the expression - new Array( item0, item1, ... ). + An array is created and returned as if by the expression + new Array( item0, item1, ... ). - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.1.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array Constructor Called as a Function"; +var SECTION = "15.4.1.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Constructor Called as a Function"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "typeof Array(1,2)", + "object", + typeof Array(1,2) ); + +new TestCase( SECTION, + "(Array(1,2)).toString", + Array.prototype.toString, + (Array(1,2)).toString ); + +new TestCase( SECTION, + "var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()", + "[object Array]", + eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") ); + +new TestCase( SECTION, + "(Array(1,2)).length", + 2, + (Array(1,2)).length ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); arr[0]", + 1, + eval("var arr = (Array(1,2)); arr[0]") ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); arr[1]", + 2, + eval("var arr = (Array(1,2)); arr[1]") ); + +new TestCase( SECTION, + "var arr = (Array(1,2)); String(arr)", + "1,2", + eval("var arr = (Array(1,2)); String(arr)") ); + +test(); function ToUint32( n ) { - n = Number( n ); - if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY || - n == Number.NEGATIVE_INFINITY ) { - return 0; - } - var sign = n < 0 ? -1 : 1; + n = Number( n ); + if( isNaN(n) || n == 0 || n == Number.POSITIVE_INFINITY || + n == Number.NEGATIVE_INFINITY ) { + return 0; + } + var sign = n < 0 ? -1 : 1; - return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32); + return ( sign * ( n * Math.floor( Math.abs(n) ) ) ) % Math.pow(2, 32); } -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "typeof Array(1,2)", "object", typeof Array(1,2) ); - array[item++] = new TestCase( SECTION, "(Array(1,2)).toString", Array.prototype.toString, (Array(1,2)).toString ); - array[item++] = new TestCase( SECTION, - "var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()", - "[object Array]", - eval("var arr = Array(1,2,3); arr.toString = Object.prototype.toString; arr.toString()") ); - - - array[item++] = new TestCase( SECTION, "(Array(1,2)).length", 2, (Array(1,2)).length ); - array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[0]", 1, eval("var arr = (Array(1,2)); arr[0]") ); - array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); arr[1]", 2, eval("var arr = (Array(1,2)); arr[1]") ); - array[item++] = new TestCase( SECTION, "var arr = (Array(1,2)); String(arr)", "1,2", eval("var arr = (Array(1,2)); String(arr)") ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Array/15.4.1.2.js b/mozilla/js/tests/ecma/Array/15.4.1.2.js index 490b8548045..3c2d2276f50 100644 --- a/mozilla/js/tests/ecma/Array/15.4.1.2.js +++ b/mozilla/js/tests/ecma/Array/15.4.1.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,126 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.1.2.js - ECMA Section: 15.4.1.2 Array(len) + File Name: 15.4.1.2.js + ECMA Section: 15.4.1.2 Array(len) - Description: When Array is called as a function rather than as a - constructor, it creates and initializes a new array - object. Thus, the function call Array(...) is - equivalent to the object creationi new Array(...) with - the same arguments. + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. - An array is created and returned as if by the - expression new Array(len). + An array is created and returned as if by the + expression new Array(len). - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.1.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array Constructor Called as a Function: Array(len)"; +var SECTION = "15.4.1.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Constructor Called as a Function: Array(len)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "(Array()).length", + 0, + (Array()).length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "(Array(0)).length", + 0, + (Array(0)).length ); - array[item++] = new TestCase( SECTION, "(Array()).length", 0, (Array()).length ); - array[item++] = new TestCase( SECTION, "(Array(0)).length", 0, (Array(0)).length ); - array[item++] = new TestCase( SECTION, "(Array(1)).length", 1, (Array(1)).length ); - array[item++] = new TestCase( SECTION, "(Array(10)).length", 10, (Array(10)).length ); - array[item++] = new TestCase( SECTION, "(Array('1')).length", 1, (Array('1')).length ); - array[item++] = new TestCase( SECTION, "(Array(1000)).length", 1000, (Array(1000)).length ); - array[item++] = new TestCase( SECTION, "(Array('1000')).length", 1, (Array('1000')).length ); - array[item++] = new TestCase( SECTION, "(Array(4294967295)).length", ToUint32(4294967295), (Array(4294967295)).length ); - array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)-1)).length", ToUint32(Math.pow(2,31)-1), (Array(Math.pow(2,31)-1)).length ); - array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31))).length", ToUint32(Math.pow(2,31)), (Array(Math.pow(2,31))).length ); - array[item++] = new TestCase( SECTION, "(Array(Math.pow(2,31)+1)).length", ToUint32(Math.pow(2,31)+1), (Array(Math.pow(2,31)+1)).length ); - array[item++] = new TestCase( SECTION, "(Array('8589934592')).length", 1, (Array("8589934592")).length ); - array[item++] = new TestCase( SECTION, "(Array('4294967296')).length", 1, (Array("4294967296")).length ); - array[item++] = new TestCase( SECTION, "(Array(1073741823)).length", ToUint32(1073741823), (Array(1073741823)).length ); - array[item++] = new TestCase( SECTION, "(Array(1073741824)).length", ToUint32(1073741824), (Array(1073741824)).length ); - array[item++] = new TestCase( SECTION, "(Array('a string')).length", 1, (Array("a string")).length ); +new TestCase( SECTION, + "(Array(1)).length", + 1, + (Array(1)).length ); + +new TestCase( SECTION, + "(Array(10)).length", + 10, + (Array(10)).length ); + +new TestCase( SECTION, + "(Array('1')).length", + 1, + (Array('1')).length ); + +new TestCase( SECTION, + "(Array(1000)).length", + 1000, + (Array(1000)).length ); + +new TestCase( SECTION, + "(Array('1000')).length", + 1, + (Array('1000')).length ); + +new TestCase( SECTION, + "(Array(4294967295)).length", + ToUint32(4294967295), + (Array(4294967295)).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31)-1)).length", + ToUint32(Math.pow(2,31)-1), + (Array(Math.pow(2,31)-1)).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31))).length", + ToUint32(Math.pow(2,31)), + (Array(Math.pow(2,31))).length ); + +new TestCase( SECTION, + "(Array(Math.pow(2,31)+1)).length", + ToUint32(Math.pow(2,31)+1), + (Array(Math.pow(2,31)+1)).length ); + +new TestCase( SECTION, + "(Array('8589934592')).length", + 1, + (Array("8589934592")).length ); + +new TestCase( SECTION, + "(Array('4294967296')).length", + 1, + (Array("4294967296")).length ); + +new TestCase( SECTION, + "(Array(1073741823)).length", + ToUint32(1073741823), + (Array(1073741823)).length ); + +new TestCase( SECTION, + "(Array(1073741824)).length", + ToUint32(1073741824), + (Array(1073741824)).length ); + +new TestCase( SECTION, + "(Array('a string')).length", + 1, + (Array("a string")).length ); + +test(); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); -} \ No newline at end of file + return ( n ); +} diff --git a/mozilla/js/tests/ecma/Array/15.4.1.3.js b/mozilla/js/tests/ecma/Array/15.4.1.3.js index d4988acc0ec..ee821716d82 100644 --- a/mozilla/js/tests/ecma/Array/15.4.1.3.js +++ b/mozilla/js/tests/ecma/Array/15.4.1.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,68 +35,48 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.1.3.js - ECMA Section: 15.4.1.3 Array() + File Name: 15.4.1.3.js + ECMA Section: 15.4.1.3 Array() - Description: When Array is called as a function rather than as a - constructor, it creates and initializes a new array - object. Thus, the function call Array(...) is - equivalent to the object creationi new Array(...) with - the same arguments. + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. - An array is created and returned as if by the - expression new Array(len). + An array is created and returned as if by the + expression new Array(len). - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.1.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array Constructor Called as a Function: Array()"; +var SECTION = "15.4.1.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array Constructor Called as a Function: Array()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); +new TestCase( SECTION, + "MYARR = new Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()", + "[object Array]", + eval("MYARR = Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()") ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "(Array()).length", + 0, + (Array()).length ); - array[item++] = new TestCase( SECTION, - "typeof Array()", - "object", - typeof Array() ); +new TestCase( SECTION, + "Array().toString()", + "", + Array().toString() ); - array[item++] = new TestCase( SECTION, - "MYARR = new Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()", - "[object Array]", - eval("MYARR = Array();MYARR.getClass = Object.prototype.toString;MYARR.getClass()") ); - - array[item++] = new TestCase( SECTION, - "(Array()).length", - 0, ( - Array()).length ); - - array[item++] = new TestCase( SECTION, - "Array().toString()", - "", - Array().toString() ); - - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.1.js b/mozilla/js/tests/ecma/Array/15.4.1.js index 1fb7b3c02f6..355aca504a3 100644 --- a/mozilla/js/tests/ecma/Array/15.4.1.js +++ b/mozilla/js/tests/ecma/Array/15.4.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,115 +35,96 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.1.js - ECMA Section: 15.4.1 The Array Constructor Called as a Function + File Name: 15.4.1.js + ECMA Section: 15.4.1 The Array Constructor Called as a Function - Description: When Array is called as a function rather than as a - constructor, it creates and initializes a new array - object. Thus, the function call Array(...) is - equivalent to the object creationi new Array(...) with - the same arguments. + Description: When Array is called as a function rather than as a + constructor, it creates and initializes a new array + object. Thus, the function call Array(...) is + equivalent to the object creationi new Array(...) with + the same arguments. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Array Constructor Called as a Function"; +var SECTION = "15.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor Called as a Function"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Array() +''", + "", + Array() +"" ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "typeof Array()", + "object", + typeof Array() ); - array[item++] = new TestCase( SECTION, - "Array() +''", - "", - Array() +"" ); +new TestCase( SECTION, + "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); - array[item++] = new TestCase( SECTION, - "typeof Array()", - "object", - typeof Array() ); +new TestCase( SECTION, + "var arr = Array(); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(); arr.toString == Array.prototype.toString") ); - array[item++] = new TestCase( SECTION, - "var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()", - "[object Array]", - eval("var arr = Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); +new TestCase( SECTION, + "Array().length", + 0, + Array().length ); - array[item++] = new TestCase( SECTION, - "var arr = Array(); arr.toString == Array.prototype.toString", - true, - eval("var arr = Array(); arr.toString == Array.prototype.toString") ); +new TestCase( SECTION, + "Array(1,2,3) +''", + "1,2,3", + Array(1,2,3) +"" ); - array[item++] = new TestCase( SECTION, - "Array().length", - 0, - Array().length ); +new TestCase( SECTION, + "typeof Array(1,2,3)", + "object", + typeof Array(1,2,3) ); +new TestCase( SECTION, + "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); - array[item++] = new TestCase( SECTION, - "Array(1,2,3) +''", - "1,2,3", - Array(1,2,3) +"" ); +new TestCase( SECTION, + "var arr = Array(1,2,3); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") ); - array[item++] = new TestCase( SECTION, - "typeof Array(1,2,3)", - "object", - typeof Array(1,2,3) ); +new TestCase( SECTION, + "Array(1,2,3).length", + 3, + Array(1,2,3).length ); - array[item++] = new TestCase( SECTION, - "var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", - "[object Array]", - eval("var arr = Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); +new TestCase( SECTION, + "typeof Array(12345)", + "object", + typeof Array(12345) ); - array[item++] = new TestCase( SECTION, - "var arr = Array(1,2,3); arr.toString == Array.prototype.toString", - true, - eval("var arr = Array(1,2,3); arr.toString == Array.prototype.toString") ); +new TestCase( SECTION, + "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") ); - array[item++] = new TestCase( SECTION, - "Array(1,2,3).length", - 3, - Array(1,2,3).length ); +new TestCase( SECTION, + "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString", + true, + eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") ); - array[item++] = new TestCase( SECTION, - "typeof Array(12345)", - "object", - typeof Array(12345) ); +new TestCase( SECTION, + "Array(12345).length", + 12345, + Array(12345).length ); - array[item++] = new TestCase( SECTION, - "var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()", - "[object Array]", - eval("var arr = Array(12345); arr.getClass = Object.prototype.toString; arr.getClass()") ); - - array[item++] = new TestCase( SECTION, - "var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString", - true, - eval("var arr = Array(1,2,3,4,5); arr.toString == Array.prototype.toString") ); - - array[item++] = new TestCase( SECTION, - "Array(12345).length", - 12345, - Array(12345).length ); - - return ( array ); -} -function test() { - for (tc=0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.2.1-1.js b/mozilla/js/tests/ecma/Array/15.4.2.1-1.js index 446210c3929..1d81e57a099 100644 --- a/mozilla/js/tests/ecma/Array/15.4.2.1-1.js +++ b/mozilla/js/tests/ecma/Array/15.4.2.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,74 +35,76 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.2.1-1.js - ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) - Description: This description only applies of the constructor is - given two or more arguments. + File Name: 15.4.2.1-1.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. - The [[Prototype]] property of the newly constructed - object is set to the original Array prototype object, - the one that is the initial value of Array.prototype - (15.4.3.1). + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). - The [[Class]] property of the newly constructed object - is set to "Array". + The [[Class]] property of the newly constructed object + is set to "Array". - The length property of the newly constructed object is - set to the number of arguments. + The length property of the newly constructed object is + set to the number of arguments. - The 0 property of the newly constructed object is set - to item0... in general, for as many arguments as there - are, the k property of the newly constructed object is - set to argument k, where the first argument is - considered to be argument number 0. + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. - This file tests the typeof the newly constructed object. + This file tests the typeof the newly constructed object. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.2.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; +var SECTION = "15.4.2.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "typeof new Array(1,2)", + "object", + typeof new Array(1,2) ); +new TestCase( SECTION, + "(new Array(1,2)).toString", + Array.prototype.toString, + (new Array(1,2)).toString ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); - array[item++] = new TestCase( SECTION, "typeof new Array(1,2)", "object", typeof new Array(1,2) ); - array[item++] = new TestCase( SECTION, "(new Array(1,2)).toString", Array.prototype.toString, (new Array(1,2)).toString ); - array[item++] = new TestCase( SECTION, - "var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()", - "[object Array]", - eval("var arr = new Array(1,2,3); arr.getClass = Object.prototype.toString; arr.getClass()") ); +new TestCase( SECTION, + "(new Array(1,2)).length", + 2, + (new Array(1,2)).length ); - array[item++] = new TestCase( SECTION, "(new Array(1,2)).length", 2, (new Array(1,2)).length ); - array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[0]", 1, eval("var arr = (new Array(1,2)); arr[0]") ); - array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); arr[1]", 2, eval("var arr = (new Array(1,2)); arr[1]") ); - array[item++] = new TestCase( SECTION, "var arr = (new Array(1,2)); String(arr)", "1,2", eval("var arr = (new Array(1,2)); String(arr)") ); +new TestCase( SECTION, + "var arr = (new Array(1,2)); arr[0]", + 1, + eval("var arr = (new Array(1,2)); arr[0]") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "var arr = (new Array(1,2)); arr[1]", + 2, + eval("var arr = (new Array(1,2)); arr[1]") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "var arr = (new Array(1,2)); String(arr)", + "1,2", + eval("var arr = (new Array(1,2)); String(arr)") ); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.2.1-2.js b/mozilla/js/tests/ecma/Array/15.4.2.1-2.js index 202afbbdbf9..d71c6cd8006 100644 --- a/mozilla/js/tests/ecma/Array/15.4.2.1-2.js +++ b/mozilla/js/tests/ecma/Array/15.4.2.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,65 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.2.1-2.js - ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) - Description: This description only applies of the constructor is - given two or more arguments. + File Name: 15.4.2.1-2.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. - The [[Prototype]] property of the newly constructed - object is set to the original Array prototype object, - the one that is the initial value of Array.prototype - (15.4.3.1). + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). - The [[Class]] property of the newly constructed object - is set to "Array". + The [[Class]] property of the newly constructed object + is set to "Array". - The length property of the newly constructed object is - set to the number of arguments. + The length property of the newly constructed object is + set to the number of arguments. - The 0 property of the newly constructed object is set - to item0... in general, for as many arguments as there - are, the k property of the newly constructed object is - set to argument k, where the first argument is - considered to be argument number 0. + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.2.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; +var SECTION = "15.4.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - testcases = getTestCases(); - test(); +var TEST_STRING = "new Array("; +var ARGUMENTS = "" +var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); -function getTestCases() { - var array = new Array(); - - var TEST_STRING = "new Array("; - var ARGUMENTS = "" - var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); - - for ( var index = 0; index < TEST_LENGTH; index++ ) { - ARGUMENTS += index; - ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; - } - - TEST_STRING += ARGUMENTS + ")"; - - TEST_ARRAY = eval( TEST_STRING ); - - for ( item = 0; item < TEST_LENGTH; item++ ) { - array[item] = new TestCase( SECTION, "["+item+"]", item, TEST_ARRAY[item] ); - } - - array[item++ ] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" ); - - return ( array ); +for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; } + +TEST_STRING += ARGUMENTS + ")"; + +TEST_ARRAY = eval( TEST_STRING ); + +for ( var item = 0; item < TEST_LENGTH; item++ ) { + new TestCase( SECTION, + "["+item+"]", + item, + TEST_ARRAY[item] ); +} + +new TestCase( SECTION, + "new Array( ["+TEST_LENGTH+" arguments] ) +''", + ARGUMENTS, + TEST_ARRAY +"" ); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.2.1-3.js b/mozilla/js/tests/ecma/Array/15.4.2.1-3.js index aebc165cc5c..75fa8dcb0f5 100644 --- a/mozilla/js/tests/ecma/Array/15.4.2.1-3.js +++ b/mozilla/js/tests/ecma/Array/15.4.2.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,94 +35,101 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.2.1-3.js - ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) - Description: This description only applies of the constructor is - given two or more arguments. + File Name: 15.4.2.1-3.js + ECMA Section: 15.4.2.1 new Array( item0, item1, ... ) + Description: This description only applies of the constructor is + given two or more arguments. - The [[Prototype]] property of the newly constructed - object is set to the original Array prototype object, - the one that is the initial value of Array.prototype - (15.4.3.1). + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype + (15.4.3.1). - The [[Class]] property of the newly constructed object - is set to "Array". + The [[Class]] property of the newly constructed object + is set to "Array". - The length property of the newly constructed object is - set to the number of arguments. + The length property of the newly constructed object is + set to the number of arguments. - The 0 property of the newly constructed object is set - to item0... in general, for as many arguments as there - are, the k property of the newly constructed object is - set to argument k, where the first argument is - considered to be argument number 0. + The 0 property of the newly constructed object is set + to item0... in general, for as many arguments as there + are, the k property of the newly constructed object is + set to argument k, where the first argument is + considered to be argument number 0. - This test stresses the number of arguments presented to - the Array constructor. Should support up to Math.pow - (2,32) arguments, since that is the maximum length of an - ECMAScript array. + This test stresses the number of arguments presented to + the Array constructor. Should support up to Math.pow + (2,32) arguments, since that is the maximum length of an + ECMAScript array. - ***Change TEST_LENGTH to Math.pow(2,32) when larger array - lengths are supported. + ***Change TEST_LENGTH to Math.pow(2,32) when larger array + lengths are supported. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.2.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; +var SECTION = "15.4.2.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( item0, item1, ...)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var TEST_STRING = "new Array("; +var ARGUMENTS = "" +var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); -function getTestCases() { - var array = new Array(); - - var TEST_STRING = "new Array("; - var ARGUMENTS = "" - var TEST_LENGTH = Math.pow(2,10); //Math.pow(2,32); - - for ( var index = 0; index < TEST_LENGTH; index++ ) { - ARGUMENTS += index; - ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; - } - - TEST_STRING += ARGUMENTS + ")"; - - TEST_ARRAY = eval( TEST_STRING ); - - for ( item = 0; item < TEST_LENGTH; item++ ) { - array[item] = new TestCase( SECTION, "TEST_ARRAY["+item+"]", item, TEST_ARRAY[item] ); - } - - array[item++] = new TestCase( SECTION, "new Array( ["+TEST_LENGTH+" arguments] ) +''", ARGUMENTS, TEST_ARRAY +"" ); - array[item++] = new TestCase( SECTION, "TEST_ARRAY.toString", Array.prototype.toString, TEST_ARRAY.toString ); - array[item++] = new TestCase( SECTION, "TEST_ARRAY.join", Array.prototype.join, TEST_ARRAY.join ); - array[item++] = new TestCase( SECTION, "TEST_ARRAY.sort", Array.prototype.sort, TEST_ARRAY.sort ); - array[item++] = new TestCase( SECTION, "TEST_ARRAY.reverse", Array.prototype.reverse, TEST_ARRAY.reverse ); - array[item++] = new TestCase( SECTION, "TEST_ARRAY.length", TEST_LENGTH, TEST_ARRAY.length ); - array[item++] = new TestCase( SECTION, - "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()", - "[object Array]", - eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") ); - - return ( array ); +for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += (index == (TEST_LENGTH-1) ) ? "" : ","; } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +TEST_STRING += ARGUMENTS + ")"; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +TEST_ARRAY = eval( TEST_STRING ); + +for ( var item = 0; item < TEST_LENGTH; item++ ) { + new TestCase( SECTION, + "TEST_ARRAY["+item+"]", + item, + TEST_ARRAY[item] ); } + +new TestCase( SECTION, + "new Array( ["+TEST_LENGTH+" arguments] ) +''", + ARGUMENTS, + TEST_ARRAY +"" ); + +new TestCase( SECTION, + "TEST_ARRAY.toString", + Array.prototype.toString, + TEST_ARRAY.toString ); + +new TestCase( SECTION, + "TEST_ARRAY.join", + Array.prototype.join, + TEST_ARRAY.join ); + +new TestCase( SECTION, + "TEST_ARRAY.sort", + Array.prototype.sort, + TEST_ARRAY.sort ); + +new TestCase( SECTION, + "TEST_ARRAY.reverse", + Array.prototype.reverse, + TEST_ARRAY.reverse ); + +new TestCase( SECTION, + "TEST_ARRAY.length", + TEST_LENGTH, + TEST_ARRAY.length ); + +new TestCase( SECTION, + "TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()", + "[object Array]", + eval("TEST_ARRAY.toString = Object.prototype.toString; TEST_ARRAY.toString()") ); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.2.2-1.js b/mozilla/js/tests/ecma/Array/15.4.2.2-1.js index 3e2369a62bd..39aa9217eb6 100644 --- a/mozilla/js/tests/ecma/Array/15.4.2.2-1.js +++ b/mozilla/js/tests/ecma/Array/15.4.2.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,106 +35,147 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.2.2-1.js - ECMA Section: 15.4.2.2 new Array(len) + File Name: 15.4.2.2-1.js + ECMA Section: 15.4.2.2 new Array(len) - Description: This description only applies of the constructor is - given two or more arguments. + Description: This description only applies of the constructor is + given two or more arguments. - The [[Prototype]] property of the newly constructed - object is set to the original Array prototype object, - the one that is the initial value of Array.prototype(0) - (15.4.3.1). + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype(0) + (15.4.3.1). - The [[Class]] property of the newly constructed object - is set to "Array". + The [[Class]] property of the newly constructed object + is set to "Array". - If the argument len is a number, then the length - property of the newly constructed object is set to - ToUint32(len). + If the argument len is a number, then the length + property of the newly constructed object is set to + ToUint32(len). - If the argument len is not a number, then the length - property of the newly constructed object is set to 1 - and the 0 property of the newly constructed object is - set to len. + If the argument len is not a number, then the length + property of the newly constructed object is set to 1 + and the 0 property of the newly constructed object is + set to len. - This file tests cases where len is a number. + This file tests cases where len is a number. - The cases in this test need to be updated since the - ToUint32 description has changed. + The cases in this test need to be updated since the + ToUint32 description has changed. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.2.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Array Constructor: new Array( len )"; +var SECTION = "15.4.2.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( len )"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "new Array(0)", + "", + (new Array(0)).toString() ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "typeof new Array(0)", + "object", + (typeof new Array(0)) ); - array[item++] = new TestCase( SECTION, "new Array(0)", "", (new Array(0)).toString() ); - array[item++] = new TestCase( SECTION, "typeof new Array(0)", "object", (typeof new Array(0)) ); - array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length ); - array[item++] = new TestCase( SECTION, "(new Array(0)).toString", Array.prototype.toString, (new Array(0)).toString ); +new TestCase( SECTION, + "(new Array(0)).length", + 0, + (new Array(0)).length ); - array[item++] = new TestCase( SECTION, "new Array(1)", "", (new Array(1)).toString() ); - array[item++] = new TestCase( SECTION, "new Array(1).length", 1, (new Array(1)).length ); - array[item++] = new TestCase( SECTION, "(new Array(1)).toString", Array.prototype.toString, (new Array(1)).toString ); +new TestCase( SECTION, + "(new Array(0)).toString", + Array.prototype.toString, + (new Array(0)).toString ); - array[item++] = new TestCase( SECTION, "(new Array(-0)).length", 0, (new Array(-0)).length ); - array[item++] = new TestCase( SECTION, "(new Array(0)).length", 0, (new Array(0)).length ); +new TestCase( SECTION, + "new Array(1)", + "", + (new Array(1)).toString() ); - array[item++] = new TestCase( SECTION, "(new Array(10)).length", 10, (new Array(10)).length ); - array[item++] = new TestCase( SECTION, "(new Array('1')).length", 1, (new Array('1')).length ); - array[item++] = new TestCase( SECTION, "(new Array(1000)).length", 1000, (new Array(1000)).length ); - array[item++] = new TestCase( SECTION, "(new Array('1000')).length", 1, (new Array('1000')).length ); +new TestCase( SECTION, + "new Array(1).length", + 1, + (new Array(1)).length ); - array[item++] = new TestCase( SECTION, "(new Array(4294967295)).length", ToUint32(4294967295), (new Array(4294967295)).length ); +new TestCase( SECTION, + "(new Array(1)).toString", + Array.prototype.toString, + (new Array(1)).toString ); - array[item++] = new TestCase( SECTION, "(new Array('8589934592')).length", 1, (new Array("8589934592")).length ); - array[item++] = new TestCase( SECTION, "(new Array('4294967296')).length", 1, (new Array("4294967296")).length ); - array[item++] = new TestCase( SECTION, "(new Array(1073741824)).length", ToUint32(1073741824), (new Array(1073741824)).length ); +new TestCase( SECTION, + "(new Array(-0)).length", + 0, + (new Array(-0)).length ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "(new Array(0)).length", + 0, + (new Array(0)).length ); + +new TestCase( SECTION, + "(new Array(10)).length", + 10, + (new Array(10)).length ); + +new TestCase( SECTION, + "(new Array('1')).length", + 1, + (new Array('1')).length ); + +new TestCase( SECTION, + "(new Array(1000)).length", + 1000, + (new Array(1000)).length ); + +new TestCase( SECTION, + "(new Array('1000')).length", + 1, + (new Array('1000')).length ); + +new TestCase( SECTION, + "(new Array(4294967295)).length", + ToUint32(4294967295), + (new Array(4294967295)).length ); + +new TestCase( SECTION, + "(new Array('8589934592')).length", + 1, + (new Array("8589934592")).length ); + +new TestCase( SECTION, + "(new Array('4294967296')).length", + 1, + (new Array("4294967296")).length ); + +new TestCase( SECTION, + "(new Array(1073741824)).length", + ToUint32(1073741824), + (new Array(1073741824)).length ); + +test(); - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value "; - } - stopTest(); - return ( testcases ); -} function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); -} \ No newline at end of file + return ( n ); +} diff --git a/mozilla/js/tests/ecma/Array/15.4.2.2-2.js b/mozilla/js/tests/ecma/Array/15.4.2.2-2.js index baa80751b63..8a92fc5073d 100644 --- a/mozilla/js/tests/ecma/Array/15.4.2.2-2.js +++ b/mozilla/js/tests/ecma/Array/15.4.2.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,71 +35,82 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.2.2-2.js - ECMA Section: 15.4.2.2 new Array(len) + File Name: 15.4.2.2-2.js + ECMA Section: 15.4.2.2 new Array(len) - Description: This description only applies of the constructor is - given two or more arguments. + Description: This description only applies of the constructor is + given two or more arguments. - The [[Prototype]] property of the newly constructed - object is set to the original Array prototype object, - the one that is the initial value of Array.prototype(0) - (15.4.3.1). + The [[Prototype]] property of the newly constructed + object is set to the original Array prototype object, + the one that is the initial value of Array.prototype(0) + (15.4.3.1). - The [[Class]] property of the newly constructed object - is set to "Array". + The [[Class]] property of the newly constructed object + is set to "Array". - If the argument len is a number, then the length - property of the newly constructed object is set to - ToUint32(len). + If the argument len is a number, then the length + property of the newly constructed object is set to + ToUint32(len). - If the argument len is not a number, then the length - property of the newly constructed object is set to 1 - and the 0 property of the newly constructed object is - set to len. + If the argument len is not a number, then the length + property of the newly constructed object is set to 1 + and the 0 property of the newly constructed object is + set to len. - This file tests length of the newly constructed array - when len is not a number. + This file tests length of the newly constructed array + when len is not a number. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.2.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Array Constructor: new Array( len )"; +var SECTION = "15.4.2.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array( len )"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "(new Array(new Number(1073741823))).length", + 1, + (new Array(new Number(1073741823))).length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "(new Array(new Number(0))).length", + 1, + (new Array(new Number(0))).length ); - array[item++] = new TestCase( SECTION, "(new Array(new Number(1073741823))).length", 1, (new Array(new Number(1073741823))).length ); - array[item++] = new TestCase( SECTION, "(new Array(new Number(0))).length", 1, (new Array(new Number(0))).length ); - array[item++] = new TestCase( SECTION, "(new Array(new Number(1000))).length", 1, (new Array(new Number(1000))).length ); - array[item++] = new TestCase( SECTION, "(new Array('mozilla, larryzilla, curlyzilla')).length", 1, (new Array('mozilla, larryzilla, curlyzilla')).length ); - array[item++] = new TestCase( SECTION, "(new Array(true)).length", 1, (new Array(true)).length ); - array[item++] = new TestCase( SECTION, "(new Array(false)).length", 1, (new Array(false)).length); - array[item++] = new TestCase( SECTION, "(new Array(new Boolean(true)).length", 1, (new Array(new Boolean(true))).length ); - array[item++] = new TestCase( SECTION, "(new Array(new Boolean(false)).length", 1, (new Array(new Boolean(false))).length ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "(new Array(new Number(1000))).length", + 1, + (new Array(new Number(1000))).length ); + +new TestCase( SECTION, + "(new Array('mozilla, larryzilla, curlyzilla')).length", + 1, + (new Array('mozilla, larryzilla, curlyzilla')).length ); + +new TestCase( SECTION, + "(new Array(true)).length", + 1, + (new Array(true)).length ); + +new TestCase( SECTION, + "(new Array(false)).length", + 1, + (new Array(false)).length); + +new TestCase( SECTION, + "(new Array(new Boolean(true)).length", + 1, + (new Array(new Boolean(true))).length ); + +new TestCase( SECTION, + "(new Array(new Boolean(false)).length", + 1, + (new Array(new Boolean(false))).length ); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.2.3.js b/mozilla/js/tests/ecma/Array/15.4.2.3.js index 24170913cbd..c17e6d178e7 100644 --- a/mozilla/js/tests/ecma/Array/15.4.2.3.js +++ b/mozilla/js/tests/ecma/Array/15.4.2.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,56 +35,65 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.4.2.3.js - ECMA Section: 15.4.2.3 new Array() - Description: The [[Prototype]] property of the newly constructed - object is set to the origianl Array prototype object, - the one that is the initial value of Array.prototype. - The [[Class]] property of the new object is set to - "Array". The length of the object is set to 0. - Author: christine@netscape.com - Date: 7 october 1997 +/** + File Name: 15.4.2.3.js + ECMA Section: 15.4.2.3 new Array() + Description: The [[Prototype]] property of the newly constructed + object is set to the origianl Array prototype object, + the one that is the initial value of Array.prototype. + The [[Class]] property of the new object is set to + "Array". The length of the object is set to 0. + + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.2.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Array Constructor: new Array()"; +var SECTION = "15.4.2.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Array Constructor: new Array()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "new Array() +''", + "", + (new Array()) +"" ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "new Array() +''", "", (new Array()) +"" ); - array[item++] = new TestCase( SECTION, "typeof new Array()", "object", (typeof new Array()) ); - array[item++] = new TestCase( SECTION, - "var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()", - "[object Array]", - eval("var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); +new TestCase( SECTION, + "typeof new Array()", + "object", + (typeof new Array()) ); - array[item++] = new TestCase( SECTION, "(new Array()).length", 0, (new Array()).length ); - array[item++] = new TestCase( SECTION, "(new Array()).toString == Array.prototype.toString", true, (new Array()).toString == Array.prototype.toString ); - array[item++] = new TestCase( SECTION, "(new Array()).join == Array.prototype.join", true, (new Array()).join == Array.prototype.join ); - array[item++] = new TestCase( SECTION, "(new Array()).reverse == Array.prototype.reverse", true, (new Array()).reverse == Array.prototype.reverse ); - array[item++] = new TestCase( SECTION, "(new Array()).sort == Array.prototype.sort", true, (new Array()).sort == Array.prototype.sort ); +new TestCase( SECTION, + "var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()", + "[object Array]", + eval("var arr = new Array(); arr.getClass = Object.prototype.toString; arr.getClass()") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase( SECTION, + "(new Array()).length", + 0, + (new Array()).length ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "(new Array()).toString == Array.prototype.toString", + true, + (new Array()).toString == Array.prototype.toString ); + +new TestCase( SECTION, + "(new Array()).join == Array.prototype.join", + true, + (new Array()).join == Array.prototype.join ); + +new TestCase( SECTION, + "(new Array()).reverse == Array.prototype.reverse", + true, + (new Array()).reverse == Array.prototype.reverse ); + +new TestCase( SECTION, + "(new Array()).sort == Array.prototype.sort", + true, + (new Array()).sort == Array.prototype.sort ); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.3.1-2.js b/mozilla/js/tests/ecma/Array/15.4.3.1-2.js index 8b5a119a1e6..7f4e25dcd90 100644 --- a/mozilla/js/tests/ecma/Array/15.4.3.1-2.js +++ b/mozilla/js/tests/ecma/Array/15.4.3.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,45 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.4.3.1-1.js - ECMA Section: 15.4.3.1 Array.prototype - Description: The initial value of Array.prototype is the built-in - Array prototype object (15.4.4). - Author: christine@netscape.com - Date: 7 october 1997 +/** + File Name: 15.4.3.1-1.js + ECMA Section: 15.4.3.1 Array.prototype + Description: The initial value of Array.prototype is the built-in + Array prototype object (15.4.4). + + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.3.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.prototype"; +var SECTION = "15.4.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - var ARRAY_PROTO = Array.prototype; +var ARRAY_PROTO = Array.prototype; - array[item++] = new TestCase( SECTION, "var props = ''; for ( p in Array ) { props += p } props", "", eval("var props = ''; for ( p in Array ) { props += p } props") ); +new TestCase( SECTION, + "var props = ''; for ( p in Array ) { props += p } props", + "", + eval("var props = ''; for ( p in Array ) { props += p } props") ); - array[item++] = new TestCase( SECTION, "Array.prototype = null; Array.prototype", ARRAY_PROTO, eval("Array.prototype = null; Array.prototype") ); +new TestCase( SECTION, + "Array.prototype = null; Array.prototype", + ARRAY_PROTO, + eval("Array.prototype = null; Array.prototype") ); - array[item++] = new TestCase( SECTION, "delete Array.prototype", false, delete Array.prototype ); - array[item++] = new TestCase( SECTION, "delete Array.prototype; Array.prototype", ARRAY_PROTO, eval("delete Array.prototype; Array.prototype") ); +new TestCase( SECTION, + "delete Array.prototype", + false, + delete Array.prototype ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "delete Array.prototype; Array.prototype", + ARRAY_PROTO, + eval("delete Array.prototype; Array.prototype") ); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.3.2.js b/mozilla/js/tests/ecma/Array/15.4.3.2.js index ac93ea684fd..aa3caa319c4 100644 --- a/mozilla/js/tests/ecma/Array/15.4.3.2.js +++ b/mozilla/js/tests/ecma/Array/15.4.3.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,39 +35,26 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.4.3.2.js - ECMA Section: 15.4.3.2 Array.length - Description: The length property is 1. - Author: christine@netscape.com - Date: 7 october 1997 +/** + File Name: 15.4.3.2.js + ECMA Section: 15.4.3.2 Array.length + Description: The length property is 1. + + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.3.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.length"; +var SECTION = "15.4.3.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.length"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Array.length", + 1, + Array.length ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Array.length", 1, Array.length ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.3.js b/mozilla/js/tests/ecma/Array/15.4.3.js index c3385fc68a3..2370098de3d 100644 --- a/mozilla/js/tests/ecma/Array/15.4.3.js +++ b/mozilla/js/tests/ecma/Array/15.4.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.4.3.js - ECMA Section: 15.4.3 Properties of the Array Constructor - Description: The value of the internal [[Prototype]] property of the - Array constructor is the Function prototype object. - Author: christine@netscape.com - Date: 7 october 1997 +/** + File Name: 15.4.3.js + ECMA Section: 15.4.3 Properties of the Array Constructor + Description: The value of the internal [[Prototype]] property of the + Array constructor is the Function prototype object. + + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.3"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "Properties of the Array Constructor"; +var SECTION = "15.4.3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Array Constructor"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Array.__proto__", + Function.prototype, + Array.__proto__ ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ ); - - return ( array ); -} -function test() { - for (tc=0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - - stopTest(); - - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.4.1.js b/mozilla/js/tests/ecma/Array/15.4.4.1.js index 917b1aa0b05..8b7fca4f3e0 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.1.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,39 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.4.1.js - ECMA Section: 15.4.4.1 Array.prototype.constructor - Description: The initial value of Array.prototype.constructor - is the built-in Array constructor. - Author: christine@netscape.com - Date: 7 october 1997 + File Name: 15.4.4.1.js + ECMA Section: 15.4.4.1 Array.prototype.constructor + Description: The initial value of Array.prototype.constructor + is the built-in Array constructor. + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.4.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.prototype.constructor"; +var SECTION = "15.4.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.constructor"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Array.prototype.constructor == Array", true, Array.prototype.constructor == Array); - return ( array ); -} -function test() { - for (tc=0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Array.prototype.constructor == Array", + true, + Array.prototype.constructor == Array); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.4.2.js b/mozilla/js/tests/ecma/Array/15.4.4.2.js index 9b52442d2cf..68fc709b32c 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.2.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.4.2.js - ECMA Section: 15.4.4.2 Array.prototype.toString() - Description: The elements of this object are converted to strings - and these strings are then concatenated, separated by - comma characters. The result is the same as if the - built-in join method were invoiked for this object - with no argument. - Author: christine@netscape.com - Date: 7 october 1997 + File Name: 15.4.4.2.js + ECMA Section: 15.4.4.2 Array.prototype.toString() + Description: The elements of this object are converted to strings + and these strings are then concatenated, separated by + comma characters. The result is the same as if the + built-in join method were invoiked for this object + with no argument. + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.4.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.prototype.toString"; +var SECTION = "15.4.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.toString"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Array.prototype.toString.length", + 0, + Array.prototype.toString.length ); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "(new Array()).toString()", + "", + (new Array()).toString() ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "(new Array(2)).toString()", + ",", + (new Array(2)).toString() ); - array[item++] = new TestCase( SECTION, "Array.prototype.toString.length", 0, Array.prototype.toString.length ); +new TestCase( SECTION, + "(new Array(0,1)).toString()", + "0,1", + (new Array(0,1)).toString() ); - array[item++] = new TestCase( SECTION, "(new Array()).toString()", "", (new Array()).toString() ); - array[item++] = new TestCase( SECTION, "(new Array(2)).toString()", ",", (new Array(2)).toString() ); - array[item++] = new TestCase( SECTION, "(new Array(0,1)).toString()", "0,1", (new Array(0,1)).toString() ); - array[item++] = new TestCase( SECTION, "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", "NaN,Infinity,-Infinity", (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() ); +new TestCase( SECTION, + "(new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString()", + "NaN,Infinity,-Infinity", + (new Array( Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toString() ); - array[item++] = new TestCase( SECTION, "(new Array( Boolean(1), Boolean(0))).toString()", "true,false", (new Array(Boolean(1),Boolean(0))).toString() ); - array[item++] = new TestCase( SECTION, "(new Array(void 0,null)).toString()", ",", (new Array(void 0,null)).toString() ); +new TestCase( SECTION, + "(new Array( Boolean(1), Boolean(0))).toString()", + "true,false", + (new Array(Boolean(1),Boolean(0))).toString() ); - var EXPECT_STRING = ""; - var MYARR = new Array(); +new TestCase( SECTION, + "(new Array(void 0,null)).toString()", + ",", + (new Array(void 0,null)).toString() ); - for ( var i = -50; i < 50; i+= 0.25 ) { - MYARR[MYARR.length] = i; - EXPECT_STRING += i +","; - } +var EXPECT_STRING = ""; +var MYARR = new Array(); - EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 ); - - array[item++] = new TestCase( SECTION, "MYARR.toString()", EXPECT_STRING, MYARR.toString() ); - - - return ( array ); -} -function test() { - for ( tc=0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( var i = -50; i < 50; i+= 0.25 ) { + MYARR[MYARR.length] = i; + EXPECT_STRING += i +","; } + +EXPECT_STRING = EXPECT_STRING.substring( 0, EXPECT_STRING.length -1 ); + +new TestCase( SECTION, + "MYARR.toString()", + EXPECT_STRING, + MYARR.toString() ); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.4.3-1.js b/mozilla/js/tests/ecma/Array/15.4.4.3-1.js index c8cff0ecaec..46d1f48be13 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.3-1.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,141 +35,127 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.4.3-1.js - ECMA Section: 15.4.4.3-1 Array.prototype.join() - Description: The elements of this object are converted to strings and - these strings are then concatenated, separated by comma - characters. The result is the same as if the built-in join - method were invoiked for this object with no argument. - Author: christine@netscape.com, pschwartau@netscape.com - Date: 07 October 1997 - Modified: 14 July 2002 - Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155285 - ECMA-262 Ed.3 Section 15.4.4.5 Array.prototype.join() - Step 3: If |separator| is |undefined|, let |separator| - be the single-character string "," -* -*/ + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.join() + Description: The elements of this object are converted to strings and + these strings are then concatenated, separated by comma + characters. The result is the same as if the built-in join + method were invoiked for this object with no argument. + Author: christine@netscape.com, pschwartau@netscape.com + Date: 07 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155285 + ECMA-262 Ed.3 Section 15.4.4.5 Array.prototype.join() + Step 3: If |separator| is |undefined|, let |separator| + be the single-character string "," + * + */ - var SECTION = "15.4.4.3-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.4.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Array.prototype.join()"); +writeHeaderToLog( SECTION + " Array.prototype.join()"); - var testcases = getTestCases(); - test(); +var ARR_PROTOTYPE = Array.prototype; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length ); +new TestCase( SECTION, "delete Array.prototype.join.length", false, delete Array.prototype.join.length ); +new TestCase( SECTION, "delete Array.prototype.join.length; Array.prototype.join.length", 1, eval("delete Array.prototype.join.length; Array.prototype.join.length") ); - var ARR_PROTOTYPE = Array.prototype; +// case where array length is 0 - array[item++] = new TestCase( SECTION, "Array.prototype.join.length", 1, Array.prototype.join.length ); - array[item++] = new TestCase( SECTION, "delete Array.prototype.join.length", false, delete Array.prototype.join.length ); - array[item++] = new TestCase( SECTION, "delete Array.prototype.join.length; Array.prototype.join.length", 1, eval("delete Array.prototype.join.length; Array.prototype.join.length") ); +new TestCase( SECTION, + "var TEST_ARRAY = new Array(); TEST_ARRAY.join()", + "", + eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join()") ); - // case where array length is 0 +// array length is 0, but spearator is specified - array[item++] = new TestCase( SECTION, - "var TEST_ARRAY = new Array(); TEST_ARRAY.join()", - "", - eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join()") ); +new TestCase( SECTION, + "var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')", + "", + eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')") ); - // array length is 0, but spearator is specified +// length is greater than 0, separator is supplied +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')", + "&&true&false&123&[object Object]&true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')") ); - array[item++] = new TestCase( SECTION, - "var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')", - "", - eval("var TEST_ARRAY = new Array(); TEST_ARRAY.join(' ')") ); +// length is greater than 0, separator is empty string +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')", + "truefalse123[object Object]true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')") ); - // length is greater than 0, separator is supplied - array[item++] = new TestCase( SECTION, - "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')", - "&&true&false&123&[object Object]&true", - eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('&')") ); +// length is greater than 0, separator is undefined +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)", + ",,true,false,123,[object Object],true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)") ); - // length is greater than 0, separator is empty string - array[item++] = new TestCase( SECTION, - "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')", - "truefalse123[object Object]true", - eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('')") ); - // length is greater than 0, separator is undefined - array[item++] = new TestCase( SECTION, - "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)", - ",,true,false,123,[object Object],true", - eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join(void 0)") ); +// length is greater than 0, separator is not supplied +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()", + ",,true,false,123,[object Object],true", + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()") ); - // length is greater than 0, separator is not supplied - array[item++] = new TestCase( SECTION, - "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()", - ",,true,false,123,[object Object],true", - eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join()") ); +// separator is a control character +new TestCase( SECTION, + "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')", + unescape("%u000B%u000Btrue%u000Bfalse%u000B123%u000B[object Object]%u000Btrue"), + eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')") ); - // separator is a control character - array[item++] = new TestCase( SECTION, - "var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')", - unescape("%u000B%u000Btrue%u000Bfalse%u000B123%u000B[object Object]%u000Btrue"), - eval("var TEST_ARRAY = new Array(null, void 0, true, false, 123, new Object(), new Boolean(true) ); TEST_ARRAY.join('\v')") ); - - // length of array is 1 - array[item++] = new TestCase( SECTION, - "var TEST_ARRAY = new Array(true) ); TEST_ARRAY.join('\v')", - "true", - eval("var TEST_ARRAY = new Array(true); TEST_ARRAY.join('\v')") ); +// length of array is 1 +new TestCase( SECTION, + "var TEST_ARRAY = new Array(true) ); TEST_ARRAY.join('\v')", + "true", + eval("var TEST_ARRAY = new Array(true); TEST_ARRAY.join('\v')") ); - SEPARATOR = "\t" - TEST_LENGTH = 100; - TEST_STRING = ""; - ARGUMENTS = ""; - TEST_RESULT = ""; +SEPARATOR = "\t" +TEST_LENGTH = 100; +TEST_STRING = ""; +ARGUMENTS = ""; +TEST_RESULT = ""; - for ( var index = 0; index < TEST_LENGTH; index++ ) { - ARGUMENTS += index; - ARGUMENTS += ( index == TEST_LENGTH -1 ) ? "" : ","; +for ( var index = 0; index < TEST_LENGTH; index++ ) { + ARGUMENTS += index; + ARGUMENTS += ( index == TEST_LENGTH -1 ) ? "" : ","; - TEST_RESULT += index; - TEST_RESULT += ( index == TEST_LENGTH -1 ) ? "" : SEPARATOR; - } - - TEST_ARRAY = eval( "new Array( "+ARGUMENTS +")" ); - - array[item++] = new TestCase( SECTION, "TEST_ARRAY.join("+SEPARATOR+")", TEST_RESULT, TEST_ARRAY.join( SEPARATOR ) ); - - array[item++] = new TestCase( SECTION, "(new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join()", - "true,false,,,1e+21,1e-7", - (new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join() ); - - // this is not an Array object - array[item++] = new TestCase( SECTION, - "var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')", - "true:false:111:0.5:1230000:NaN::", - eval("var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')") ); - - - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + TEST_RESULT += index; + TEST_RESULT += ( index == TEST_LENGTH -1 ) ? "" : SEPARATOR; } + +TEST_ARRAY = eval( "new Array( "+ARGUMENTS +")" ); + +new TestCase( SECTION, + "TEST_ARRAY.join("+SEPARATOR+")", + TEST_RESULT, + TEST_ARRAY.join( SEPARATOR ) ); + +new TestCase( SECTION, + "(new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join()", + "true,false,,,1e+21,1e-7", + (new Array( Boolean(true), Boolean(false), null, void 0, Number(1e+21), Number(1e-7))).join() ); + +// this is not an Array object +new TestCase( SECTION, + "var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')", + "true:false:111:0.5:1230000:NaN::", + eval("var OB = new Object_1('true,false,111,0.5,1.23e6,NaN,void 0,null'); OB.join(':')") ); + +test(); + function Object_1( value ) { - this.array = value.split(","); - this.length = this.array.length; - for ( var i = 0; i < this.length; i++ ) { - this[i] = eval(this.array[i]); - } - this.join = Array.prototype.join; - this.getClass = Object.prototype.toString; + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.join; + this.getClass = Object.prototype.toString; } diff --git a/mozilla/js/tests/ecma/Array/15.4.4.4-1.js b/mozilla/js/tests/ecma/Array/15.4.4.4-1.js index 3e09fd3631a..ca8271b571c 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.4-1.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,12 +36,12 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.4.4.3-1.js - ECMA Section: 15.4.4.3-1 Array.prototype.reverse() - Description: + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.reverse() + Description: - The elements of the array are rearranged so as to reverse their order. - This object is returned as the result of the call. + The elements of the array are rearranged so as to reverse their order. + This object is returned as the result of the call. 1. Call the [[Get]] method of this object with argument "length". 2. Call ToUint32(Result(1)). @@ -51,237 +52,240 @@ 7. Call ToString(k). 8. ToString(Result(6)). 9. Call the [[Get]] method of this object with argument Result(7). - 10. Call the [[Get]] method of this object with argument Result(8). - 11. If this object has a property named by Result(8), go to step 12; but - if this object has no property named by Result(8), then go to either - step 12 or step 14, depending on the implementation. - 12. Call the [[Put]] method of this object with arguments Result(7) and - Result(10). - 13. Go to step 15. - 14. Call the [[Delete]] method on this object, providing Result(7) as the - name of the property to delete. - 15. If this object has a property named by Result(7), go to step 16; but if - this object has no property named by Result(7), then go to either step 16 - or step 18, depending on the implementation. - 16. Call the [[Put]] method of this object with arguments Result(8) and - Result(9). - 17. Go to step 19. - 18. Call the [[Delete]] method on this object, providing Result(8) as the - name of the property to delete. - 19. Increase k by 1. - 20. Go to step 5. + 10. Call the [[Get]] method of this object with argument Result(8). + 11. If this object has a property named by Result(8), go to step 12; but + if this object has no property named by Result(8), then go to either + step 12 or step 14, depending on the implementation. + 12. Call the [[Put]] method of this object with arguments Result(7) and + Result(10). + 13. Go to step 15. + 14. Call the [[Delete]] method on this object, providing Result(7) as the + name of the property to delete. + 15. If this object has a property named by Result(7), go to step 16; but if + this object has no property named by Result(7), then go to either step 16 + or step 18, depending on the implementation. + 16. Call the [[Put]] method of this object with arguments Result(8) and + Result(9). + 17. Go to step 19. + 18. Call the [[Delete]] method on this object, providing Result(8) as the + name of the property to delete. + 19. Increase k by 1. + 20. Go to step 5. -Note that the reverse function is intentionally generic; it does not require -that its this value be an Array object. Therefore it can be transferred to other -kinds of objects for use as a method. Whether the reverse function can be applied -successfully to a host object is implementation dependent. + Note that the reverse function is intentionally generic; it does not require + that its this value be an Array object. Therefore it can be transferred to other + kinds of objects for use as a method. Whether the reverse function can be applied + successfully to a host object is implementation dependent. - Note: Array.prototype.reverse allows some flexibility in implementation - regarding array indices that have not been populated. This test covers the - cases in which unpopulated indices are not deleted, since the JavaScript - implementation does not delete uninitialzed indices. + Note: Array.prototype.reverse allows some flexibility in implementation + regarding array indices that have not been populated. This test covers the + cases in which unpopulated indices are not deleted, since the JavaScript + implementation does not delete uninitialzed indices. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.4.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var BUGNUMBER="123724"; +var SECTION = "15.4.4.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var BUGNUMBER="123724"; - writeHeaderToLog( SECTION + " Array.prototype.reverse()"); +writeHeaderToLog( SECTION + " Array.prototype.reverse()"); - var testcases = new Array(); - getTestCases(); - test(); +var ARR_PROTOTYPE = Array.prototype; -function getTestCases() { - var ARR_PROTOTYPE = Array.prototype; +new TestCase( SECTION, + "Array.prototype.reverse.length", + 0, + Array.prototype.reverse.length ); - testcases[testcases.length] = new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); - testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length ); - testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); +new TestCase( SECTION, + "delete Array.prototype.reverse.length", + false, + delete Array.prototype.reverse.length ); - // length of array is 0 - testcases[testcases.length] = new TestCase( SECTION, - "var A = new Array(); A.reverse(); A.length", - 0, - eval("var A = new Array(); A.reverse(); A.length") ); +new TestCase( SECTION, + "delete Array.prototype.reverse.length; Array.prototype.reverse.length", + 0, + eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); - // length of array is 1 - var A = new Array(true); - var R = Reverse(A); +// length of array is 0 +new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); - testcases[testcases.length] = new TestCase( SECTION, - "var A = new Array(true); A.reverse(); A.length", - R.length, - eval("var A = new Array(true); A.reverse(); A.length") ); - CheckItems( R, A ); +// length of array is 1 +var A = new Array(true); +var R = Reverse(A); - // length of array is 2 - var S = "var A = new Array( true,false )"; - eval(S); - var R = Reverse(A); +new TestCase( SECTION, + "var A = new Array(true); A.reverse(); A.length", + R.length, + eval("var A = new Array(true); A.reverse(); A.length") ); - testcases[testcases.length] = new TestCase( - SECTION, - S +"; A.reverse(); A.length", - R.length, - eval( S + "; A.reverse(); A.length") ); +CheckItems( R, A ); - CheckItems( R, A ); +// length of array is 2 +var S = "var A = new Array( true,false )"; +eval(S); +var R = Reverse(A); - // length of array is 3 - var S = "var A = new Array( true,false,null )"; - eval(S); - var R = Reverse(A); +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); - testcases[testcases.length] = new TestCase( SECTION, - S +"; A.reverse(); A.length", - R.length, - eval( S + "; A.reverse(); A.length") ); - CheckItems( R, A ); +CheckItems( R, A ); - // length of array is 4 - var S = "var A = new Array( true,false,null,void 0 )"; - eval(S); - var R = Reverse(A); +// length of array is 3 +var S = "var A = new Array( true,false,null )"; +eval(S); +var R = Reverse(A); - testcases[testcases.length] = new TestCase( SECTION, - S +"; A.reverse(); A.length", - R.length, - eval( S + "; A.reverse(); A.length") ); - CheckItems( R, A ); +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +// length of array is 4 +var S = "var A = new Array( true,false,null,void 0 )"; +eval(S); +var R = Reverse(A); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); +CheckItems( R, A ); - // some array indexes have not been set - var S = "var A = new Array(); A[8] = 'hi', A[3] = 'yo'"; - eval(S); - var R = Reverse(A); +// some array indexes have not been set +var S = "var A = new Array(); A[8] = 'hi', A[3] = 'yo'"; +eval(S); +var R = Reverse(A); - testcases[testcases.length] = new TestCase( SECTION, - S +"; A.reverse(); A.length", - R.length, - eval( S + "; A.reverse(); A.length") ); - CheckItems( R, A ); +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); - var OBJECT_OBJECT = new Object(); - var FUNCTION_OBJECT = new Function( 'return this' ); - var BOOLEAN_OBJECT = new Boolean; - var DATE_OBJECT = new Date(0); - var STRING_OBJECT = new String('howdy'); - var NUMBER_OBJECT = new Number(Math.PI); - var ARRAY_OBJECT= new Array(1000); +var OBJECT_OBJECT = new Object(); +var FUNCTION_OBJECT = new Function( 'return this' ); +var BOOLEAN_OBJECT = new Boolean; +var DATE_OBJECT = new Date(0); +var STRING_OBJECT = new String('howdy'); +var NUMBER_OBJECT = new Number(Math.PI); +var ARRAY_OBJECT= new Array(1000); - var args = "null, void 0, Math.pow(2,32), 1.234e-32, OBJECT_OBJECT, BOOLEAN_OBJECT, FUNCTION_OBJECT, DATE_OBJECT, STRING_OBJECT,"+ - "ARRAY_OBJECT, NUMBER_OBJECT, Math, true, false, 123, '90210'"; +var args = "null, void 0, Math.pow(2,32), 1.234e-32, OBJECT_OBJECT, BOOLEAN_OBJECT, FUNCTION_OBJECT, DATE_OBJECT, STRING_OBJECT,"+ +"ARRAY_OBJECT, NUMBER_OBJECT, Math, true, false, 123, '90210'"; - var S = "var A = new Array("+args+")"; - eval(S); - var R = Reverse(A); +var S = "var A = new Array("+args+")"; +eval(S); +var R = Reverse(A); - testcases[testcases.length] = new TestCase( SECTION, - S +"; A.reverse(); A.length", - R.length, - eval( S + "; A.reverse(); A.length") ); - CheckItems( R, A ); +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); - var limit = 1000; - var args = ""; - for (var i = 0; i < limit; i++ ) { - args += i +""; - if ( i + 1 < limit ) { - args += ","; - } - } +CheckItems( R, A ); - var S = "var A = new Array("+args+")"; - eval(S); - var R = Reverse(A); - - testcases[testcases.length] = new TestCase( SECTION, - S +"; A.reverse(); A.length", - R.length, - eval( S + "; A.reverse(); A.length") ); - CheckItems( R, A ); - - var S = "var MYOBJECT = new Object_1( \"void 0, 1, null, 2, \'\'\" )"; - eval(S); - var R = Reverse( A ); - - testcases[testcases.length] = new TestCase( SECTION, - S +"; A.reverse(); A.length", - R.length, - eval( S + "; A.reverse(); A.length") ); - CheckItems( R, A ); - - return ( testcases ); +var limit = 1000; +var args = ""; +for (var i = 0; i < limit; i++ ) { + args += i +""; + if ( i + 1 < limit ) { + args += ","; + } } + +var S = "var A = new Array("+args+")"; +eval(S); +var R = Reverse(A); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +var S = "var MYOBJECT = new Object_1( \"void 0, 1, null, 2, \'\'\" )"; +eval(S); +var R = Reverse( A ); + +new TestCase( SECTION, + S +"; A.reverse(); A.length", + R.length, + eval( S + "; A.reverse(); A.length") ); + +CheckItems( R, A ); + +test(); + function CheckItems( R, A ) { - for ( var i = 0; i < R.length; i++ ) { - testcases[testcases.length] = new TestCase( - SECTION, - "A["+i+ "]", - R[i], - A[i] ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( var i = 0; i < R.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } } + function Object_1( value ) { - this.array = value.split(","); - this.length = this.array.length; - for ( var i = 0; i < this.length; i++ ) { - this[i] = eval(this.array[i]); - } - this.join = Array.prototype.reverse; - this.getClass = Object.prototype.toString; + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.reverse; + this.getClass = Object.prototype.toString; } + function Reverse( array ) { - var r2 = array.length; - var k = 0; - var r3 = Math.floor( r2/2 ); - if ( r3 == k ) { - return array; - } - - for ( k = 0; k < r3; k++ ) { - var r6 = r2 - k - 1; -// var r7 = String( k ); - var r7 = k; - var r8 = String( r6 ); - - var r9 = array[r7]; - var r10 = array[r8]; - - array[r7] = r10; - array[r8] = r9; - } - + var r2 = array.length; + var k = 0; + var r3 = Math.floor( r2/2 ); + if ( r3 == k ) { return array; + } + + for ( k = 0; k < r3; k++ ) { + var r6 = r2 - k - 1; +// var r7 = String( k ); + var r7 = k; + var r8 = String( r6 ); + + var r9 = array[r7]; + var r10 = array[r8]; + + array[r7] = r10; + array[r8] = r9; + } + + return array; } + function Iterate( array ) { - for ( var i = 0; i < array.length; i++ ) { + for ( var i = 0; i < array.length; i++ ) { // print( i+": "+ array[String(i)] ); - } + } } function Object_1( value ) { - this.array = value.split(","); - this.length = this.array.length; - for ( var i = 0; i < this.length; i++ ) { - this[i] = this.array[i]; - } - this.reverse = Array.prototype.reverse; - this.getClass = Object.prototype.toString; + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = this.array[i]; + } + this.reverse = Array.prototype.reverse; + this.getClass = Object.prototype.toString; } diff --git a/mozilla/js/tests/ecma/Array/15.4.4.4-2.js b/mozilla/js/tests/ecma/Array/15.4.4.4-2.js index 9684e521d2c..37252e0a9cd 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.4-2.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.4-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,13 +35,14 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.4.4.3-1.js - ECMA Section: 15.4.4.3-1 Array.prototype.reverse() - Description: - The elements of the array are rearranged so as to reverse their order. - This object is returned as the result of the call. +/** + File Name: 15.4.4.3-1.js + ECMA Section: 15.4.4.3-1 Array.prototype.reverse() + Description: + + The elements of the array are rearranged so as to reverse their order. + This object is returned as the result of the call. 1. Call the [[Get]] method of this object with argument "length". 2. Call ToUint32(Result(1)). @@ -51,128 +53,115 @@ 7. Call ToString(k). 8. ToString(Result(6)). 9. Call the [[Get]] method of this object with argument Result(7). - 10. Call the [[Get]] method of this object with argument Result(8). - 11. If this object has a property named by Result(8), go to step 12; but - if this object has no property named by Result(8), then go to either - step 12 or step 14, depending on the implementation. - 12. Call the [[Put]] method of this object with arguments Result(7) and - Result(10). - 13. Go to step 15. - 14. Call the [[Delete]] method on this object, providing Result(7) as the - name of the property to delete. - 15. If this object has a property named by Result(7), go to step 16; but if - this object has no property named by Result(7), then go to either step 16 - or step 18, depending on the implementation. - 16. Call the [[Put]] method of this object with arguments Result(8) and - Result(9). - 17. Go to step 19. - 18. Call the [[Delete]] method on this object, providing Result(8) as the - name of the property to delete. - 19. Increase k by 1. - 20. Go to step 5. + 10. Call the [[Get]] method of this object with argument Result(8). + 11. If this object has a property named by Result(8), go to step 12; but + if this object has no property named by Result(8), then go to either + step 12 or step 14, depending on the implementation. + 12. Call the [[Put]] method of this object with arguments Result(7) and + Result(10). + 13. Go to step 15. + 14. Call the [[Delete]] method on this object, providing Result(7) as the + name of the property to delete. + 15. If this object has a property named by Result(7), go to step 16; but if + this object has no property named by Result(7), then go to either step 16 + or step 18, depending on the implementation. + 16. Call the [[Put]] method of this object with arguments Result(8) and + Result(9). + 17. Go to step 19. + 18. Call the [[Delete]] method on this object, providing Result(8) as the + name of the property to delete. + 19. Increase k by 1. + 20. Go to step 5. -Note that the reverse function is intentionally generic; it does not require -that its this value be an Array object. Therefore it can be transferred to other -kinds of objects for use as a method. Whether the reverse function can be applied -successfully to a host object is implementation dependent. + Note that the reverse function is intentionally generic; it does not require + that its this value be an Array object. Therefore it can be transferred to other + kinds of objects for use as a method. Whether the reverse function can be applied + successfully to a host object is implementation dependent. - Note: Array.prototype.reverse allows some flexibility in implementation - regarding array indices that have not been populated. This test covers the - cases in which unpopulated indices are not deleted, since the JavaScript - implementation does not delete uninitialzed indices. + Note: Array.prototype.reverse allows some flexibility in implementation + regarding array indices that have not been populated. This test covers the + cases in which unpopulated indices are not deleted, since the JavaScript + implementation does not delete uninitialzed indices. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.4.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = new Array(); +var SECTION = "15.4.4.4-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Array.prototype.reverse()"); +writeHeaderToLog( SECTION + " Array.prototype.reverse()"); - getTestCases(); - test(); +var ARR_PROTOTYPE = Array.prototype; -function getTestCases() { - var ARR_PROTOTYPE = Array.prototype; +new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); +new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length ); +new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); - testcases[testcases.length] = new TestCase( SECTION, "Array.prototype.reverse.length", 0, Array.prototype.reverse.length ); - testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length", false, delete Array.prototype.reverse.length ); - testcases[testcases.length] = new TestCase( SECTION, "delete Array.prototype.reverse.length; Array.prototype.reverse.length", 0, eval("delete Array.prototype.reverse.length; Array.prototype.reverse.length") ); +// length of array is 0 +new TestCase( SECTION, + "var A = new Array(); A.reverse(); A.length", + 0, + eval("var A = new Array(); A.reverse(); A.length") ); + +test(); - // length of array is 0 - testcases[testcases.length] = new TestCase( SECTION, - "var A = new Array(); A.reverse(); A.length", - 0, - eval("var A = new Array(); A.reverse(); A.length") ); - return ( testcases ); -} function CheckItems( R, A ) { - for ( var i = 0; i < R.length; i++ ) { - testcases[testcases.length] = new TestCase( - SECTION, - "A["+i+ "]", - R[i], - A[i] ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( var i = 0; i < R.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "]", + R[i], + A[i] ); + } } +test(); + function Object_1( value ) { - this.array = value.split(","); - this.length = this.array.length; - for ( var i = 0; i < this.length; i++ ) { - this[i] = eval(this.array[i]); - } - this.join = Array.prototype.reverse; - this.getClass = Object.prototype.toString; + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.join = Array.prototype.reverse; + this.getClass = Object.prototype.toString; } function Reverse( array ) { - var r2 = array.length; - var k = 0; - var r3 = Math.floor( r2/2 ); - if ( r3 == k ) { - return array; - } - - for ( k = 0; k < r3; k++ ) { - var r6 = r2 - k - 1; -// var r7 = String( k ); - var r7 = k; - var r8 = String( r6 ); - - var r9 = array[r7]; - var r10 = array[r8]; - - array[r7] = r10; - array[r8] = r9; - } - + var r2 = array.length; + var k = 0; + var r3 = Math.floor( r2/2 ); + if ( r3 == k ) { return array; + } + + for ( k = 0; k < r3; k++ ) { + var r6 = r2 - k - 1; +// var r7 = String( k ); + var r7 = k; + var r8 = String( r6 ); + + var r9 = array[r7]; + var r10 = array[r8]; + + array[r7] = r10; + array[r8] = r9; + } + + return array; } function Iterate( array ) { - for ( var i = 0; i < array.length; i++ ) { + for ( var i = 0; i < array.length; i++ ) { // print( i+": "+ array[String(i)] ); - } + } } function Object_1( value ) { - this.array = value.split(","); - this.length = this.array.length; - for ( var i = 0; i < this.length; i++ ) { - this[i] = this.array[i]; - } - this.reverse = Array.prototype.reverse; - this.getClass = Object.prototype.toString; + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = this.array[i]; + } + this.reverse = Array.prototype.reverse; + this.getClass = Object.prototype.toString; } diff --git a/mozilla/js/tests/ecma/Array/15.4.4.5-1.js b/mozilla/js/tests/ecma/Array/15.4.4.5-1.js index d117f1510d0..cf082b3cb63 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.5-1.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,205 +35,187 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.4.5.js - ECMA Section: Array.prototype.sort(comparefn) - Description: + File Name: 15.4.4.5.js + ECMA Section: Array.prototype.sort(comparefn) + Description: - This test file tests cases in which the compare function is not supplied. + This test file tests cases in which the compare function is not supplied. - The elements of this array are sorted. The sort is not necessarily stable. - If comparefn is provided, it should be a function that accepts two arguments - x and y and returns a negative value if x < y, zero if x = y, or a positive - value if x > y. + The elements of this array are sorted. The sort is not necessarily stable. + If comparefn is provided, it should be a function that accepts two arguments + x and y and returns a negative value if x < y, zero if x = y, or a positive + value if x > y. 1. Call the [[Get]] method of this object with argument "length". 2. Call ToUint32(Result(1)). - 1. Perform an implementation-dependent sequence of calls to the - [[Get]] , [[Put]], and [[Delete]] methods of this object and - toSortCompare (described below), where the first argument for each call - to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less - than Result(2) and where the arguments for calls to SortCompare are - results of previous calls to the [[Get]] method. After this sequence - is complete, this object must have the following two properties. - (1) There must be some mathematical permutation of the nonnegative - integers less than Result(2), such that for every nonnegative integer - j less than Result(2), if property old[j] existed, then new[(j)] is - exactly the same value as old[j],. but if property old[j] did not exist, - then new[(j)] either does not exist or exists with value undefined. - (2) If comparefn is not supplied or is a consistent comparison - function for the elements of this array, then for all nonnegative - integers j and k, each less than Result(2), if old[j] compares less - than old[k] (see SortCompare below), then (j) < (k). Here we use the - notation old[j] to refer to the hypothetical result of calling the [ - [Get]] method of this object with argument j before this step is - executed, and the notation new[j] to refer to the hypothetical result - of calling the [[Get]] method of this object with argument j after this - step has been completely executed. A function is a consistent - comparison function for a set of values if (a) for any two of those - values (possibly the same value) considered as an ordered pair, it - always returns the same value when given that pair of values as its - two arguments, and the result of applying ToNumber to this value is - not NaN; (b) when considered as a relation, where the pair (x, y) is - considered to be in the relation if and only if applying the function - to x and y and then applying ToNumber to the result produces a - negative value, this relation is a partial order; and (c) when - considered as a different relation, where the pair (x, y) is considered - to be in the relation if and only if applying the function to x and y - and then applying ToNumber to the result produces a zero value (of either - sign), this relation is an equivalence relation. In this context, the - phrase "x compares less than y" means applying Result(2) to x and y and - then applying ToNumber to the result produces a negative value. - 3.Return this object. + 1. Perform an implementation-dependent sequence of calls to the + [[Get]] , [[Put]], and [[Delete]] methods of this object and + toSortCompare (described below), where the first argument for each call + to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less + than Result(2) and where the arguments for calls to SortCompare are + results of previous calls to the [[Get]] method. After this sequence + is complete, this object must have the following two properties. + (1) There must be some mathematical permutation of the nonnegative + integers less than Result(2), such that for every nonnegative integer + j less than Result(2), if property old[j] existed, then new[(j)] is + exactly the same value as old[j],. but if property old[j] did not exist, + then new[(j)] either does not exist or exists with value undefined. + (2) If comparefn is not supplied or is a consistent comparison + function for the elements of this array, then for all nonnegative + integers j and k, each less than Result(2), if old[j] compares less + than old[k] (see SortCompare below), then (j) < (k). Here we use the + notation old[j] to refer to the hypothetical result of calling the [ + [Get]] method of this object with argument j before this step is + executed, and the notation new[j] to refer to the hypothetical result + of calling the [[Get]] method of this object with argument j after this + step has been completely executed. A function is a consistent + comparison function for a set of values if (a) for any two of those + values (possibly the same value) considered as an ordered pair, it + always returns the same value when given that pair of values as its + two arguments, and the result of applying ToNumber to this value is + not NaN; (b) when considered as a relation, where the pair (x, y) is + considered to be in the relation if and only if applying the function + to x and y and then applying ToNumber to the result produces a + negative value, this relation is a partial order; and (c) when + considered as a different relation, where the pair (x, y) is considered + to be in the relation if and only if applying the function to x and y + and then applying ToNumber to the result produces a zero value (of either + sign), this relation is an equivalence relation. In this context, the + phrase "x compares less than y" means applying Result(2) to x and y and + then applying ToNumber to the result produces a negative value. + 3.Return this object. - When the SortCompare operator is called with two arguments x and y, the following steps are taken: - 1.If x and y are both undefined, return +0. - 2.If x is undefined, return 1. - 3.If y is undefined, return 1. - 4.If the argument comparefn was not provided in the call to sort, go to step 7. - 5.Call comparefn with arguments x and y. - 6.Return Result(5). - 7.Call ToString(x). - 8.Call ToString(y). - 9.If Result(7) < Result(8), return 1. - 10.If Result(7) > Result(8), return 1. - 11.Return +0. + When the SortCompare operator is called with two arguments x and y, the following steps are taken: + 1.If x and y are both undefined, return +0. + 2.If x is undefined, return 1. + 3.If y is undefined, return 1. + 4.If the argument comparefn was not provided in the call to sort, go to step 7. + 5.Call comparefn with arguments x and y. + 6.Return Result(5). + 7.Call ToString(x). + 8.Call ToString(y). + 9.If Result(7) < Result(8), return 1. + 10.If Result(7) > Result(8), return 1. + 11.Return +0. -Note that, because undefined always compared greater than any other value, undefined and nonexistent -property values always sort to the end of the result. It is implementation-dependent whether or not such -properties will exist or not at the end of the array when the sort is concluded. + Note that, because undefined always compared greater than any other value, undefined and nonexistent + property values always sort to the end of the result. It is implementation-dependent whether or not such + properties will exist or not at the end of the array when the sort is concluded. -Note that the sort function is intentionally generic; it does not require that its this value be an Array object. -Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be -applied successfully to a host object is implementation dependent . + Note that the sort function is intentionally generic; it does not require that its this value be an Array object. + Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be + applied successfully to a host object is implementation dependent . - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.4.4.5-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.prototype.sort(comparefn)"; +var SECTION = "15.4.4.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.sort(comparefn)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); +var S = new Array(); +var item = 0; - var testcases = new Array(); - getTestCases(); - test(); +// array is empty. +S[item++] = "var A = new Array()"; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// array contains one item +S[item++] = "var A = new Array( true )"; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +// length of array is 2 +S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; + +S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; + +S[item] = "var A = new Array( "; + +var limit = 0x0061; +for ( var i = 0x007A; i >= limit; i-- ) { + S[item] += "\'"+ String.fromCharCode(i) +"\'" ; + if ( i > limit ) { + S[item] += ","; + } } -function getTestCases() { - var S = new Array(); - var item = 0; - // array is empty. - S[item++] = "var A = new Array()"; +S[item] += ")"; - // array contains one item - S[item++] = "var A = new Array( true )"; +item++; - // length of array is 2 - S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; - - S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; - - S[item] = "var A = new Array( "; - - var limit = 0x0061; - for ( var i = 0x007A; i >= limit; i-- ) { - S[item] += "\'"+ String.fromCharCode(i) +"\'" ; - if ( i > limit ) { - S[item] += ","; - } - } - - S[item] += ")"; - - item++; - - for ( var i = 0; i < S.length; i++ ) { - CheckItems( S[i] ); - } +for ( var i = 0; i < S.length; i++ ) { + CheckItems( S[i] ); } + function CheckItems( S ) { - eval( S ); - var E = Sort( A ); + eval( S ); + var E = Sort( A ); - testcases[testcases.length] = new TestCase( SECTION, - S +"; A.sort(); A.length", - E.length, - eval( S + "; A.sort(); A.length") ); + new TestCase( SECTION, + S +"; A.sort(); A.length", + E.length, + eval( S + "; A.sort(); A.length") ); - for ( var i = 0; i < E.length; i++ ) { - testcases[testcases.length] = new TestCase( - SECTION, - "A["+i+ "].toString()", - E[i] +"", - A[i] +""); + for ( var i = 0; i < E.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); - if ( A[i] == void 0 && typeof A[i] == "undefined" ) { - testcases[testcases.length] = new TestCase( - SECTION, - "typeof A["+i+ "]", - typeof E[i], - typeof A[i] ); - } + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + new TestCase( + SECTION, + "typeof A["+i+ "]", + typeof E[i], + typeof A[i] ); } + } } function Object_1( value ) { - this.array = value.split(","); - this.length = this.array.length; - for ( var i = 0; i < this.length; i++ ) { - this[i] = eval(this.array[i]); - } - this.sort = Array.prototype.sort; - this.getClass = Object.prototype.toString; + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.sort = Array.prototype.sort; + this.getClass = Object.prototype.toString; } function Sort( a ) { - for ( i = 0; i < a.length; i++ ) { - for ( j = i+1; j < a.length; j++ ) { - var lo = a[i]; - var hi = a[j]; - var c = Compare( lo, hi ); - if ( c == 1 ) { - a[i] = hi; - a[j] = lo; - } - } + for ( i = 0; i < a.length; i++ ) { + for ( j = i+1; j < a.length; j++ ) { + var lo = a[i]; + var hi = a[j]; + var c = Compare( lo, hi ); + if ( c == 1 ) { + a[i] = hi; + a[j] = lo; + } } - return a; + } + return a; } function Compare( x, y ) { - if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { - return +0; - } - if ( x == void 0 && typeof x == "undefined" ) { - return 1; - } - if ( y == void 0 && typeof y == "undefined" ) { - return -1; - } - x = String(x); - y = String(y); - if ( x < y ) { - return -1; - } - if ( x > y ) { - return 1; - } - return 0; + if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { + return +0; + } + if ( x == void 0 && typeof x == "undefined" ) { + return 1; + } + if ( y == void 0 && typeof y == "undefined" ) { + return -1; + } + x = String(x); + y = String(y); + if ( x < y ) { + return -1; + } + if ( x > y ) { + return 1; + } + return 0; } diff --git a/mozilla/js/tests/ecma/Array/15.4.4.5-2.js b/mozilla/js/tests/ecma/Array/15.4.4.5-2.js index a406a6f05be..1b8facc03a1 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.5-2.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,206 +35,191 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.4.5-2.js - ECMA Section: Array.prototype.sort(comparefn) - Description: + File Name: 15.4.4.5-2.js + ECMA Section: Array.prototype.sort(comparefn) + Description: - This test file tests cases in which the compare function is supplied. - In this cases, the sort creates a reverse sort. + This test file tests cases in which the compare function is supplied. + In this cases, the sort creates a reverse sort. - The elements of this array are sorted. The sort is not necessarily stable. - If comparefn is provided, it should be a function that accepts two arguments - x and y and returns a negative value if x < y, zero if x = y, or a positive - value if x > y. + The elements of this array are sorted. The sort is not necessarily stable. + If comparefn is provided, it should be a function that accepts two arguments + x and y and returns a negative value if x < y, zero if x = y, or a positive + value if x > y. 1. Call the [[Get]] method of this object with argument "length". 2. Call ToUint32(Result(1)). - 1. Perform an implementation-dependent sequence of calls to the - [[Get]] , [[Put]], and [[Delete]] methods of this object and - toSortCompare (described below), where the first argument for each call - to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less - than Result(2) and where the arguments for calls to SortCompare are - results of previous calls to the [[Get]] method. After this sequence - is complete, this object must have the following two properties. - (1) There must be some mathematical permutation of the nonnegative - integers less than Result(2), such that for every nonnegative integer - j less than Result(2), if property old[j] existed, then new[(j)] is - exactly the same value as old[j],. but if property old[j] did not exist, - then new[(j)] either does not exist or exists with value undefined. - (2) If comparefn is not supplied or is a consistent comparison - function for the elements of this array, then for all nonnegative - integers j and k, each less than Result(2), if old[j] compares less - than old[k] (see SortCompare below), then (j) < (k). Here we use the - notation old[j] to refer to the hypothetical result of calling the [ - [Get]] method of this object with argument j before this step is - executed, and the notation new[j] to refer to the hypothetical result - of calling the [[Get]] method of this object with argument j after this - step has been completely executed. A function is a consistent - comparison function for a set of values if (a) for any two of those - values (possibly the same value) considered as an ordered pair, it - always returns the same value when given that pair of values as its - two arguments, and the result of applying ToNumber to this value is - not NaN; (b) when considered as a relation, where the pair (x, y) is - considered to be in the relation if and only if applying the function - to x and y and then applying ToNumber to the result produces a - negative value, this relation is a partial order; and (c) when - considered as a different relation, where the pair (x, y) is considered - to be in the relation if and only if applying the function to x and y - and then applying ToNumber to the result produces a zero value (of either - sign), this relation is an equivalence relation. In this context, the - phrase "x compares less than y" means applying Result(2) to x and y and - then applying ToNumber to the result produces a negative value. - 3.Return this object. + 1. Perform an implementation-dependent sequence of calls to the + [[Get]] , [[Put]], and [[Delete]] methods of this object and + toSortCompare (described below), where the first argument for each call + to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less + than Result(2) and where the arguments for calls to SortCompare are + results of previous calls to the [[Get]] method. After this sequence + is complete, this object must have the following two properties. + (1) There must be some mathematical permutation of the nonnegative + integers less than Result(2), such that for every nonnegative integer + j less than Result(2), if property old[j] existed, then new[(j)] is + exactly the same value as old[j],. but if property old[j] did not exist, + then new[(j)] either does not exist or exists with value undefined. + (2) If comparefn is not supplied or is a consistent comparison + function for the elements of this array, then for all nonnegative + integers j and k, each less than Result(2), if old[j] compares less + than old[k] (see SortCompare below), then (j) < (k). Here we use the + notation old[j] to refer to the hypothetical result of calling the [ + [Get]] method of this object with argument j before this step is + executed, and the notation new[j] to refer to the hypothetical result + of calling the [[Get]] method of this object with argument j after this + step has been completely executed. A function is a consistent + comparison function for a set of values if (a) for any two of those + values (possibly the same value) considered as an ordered pair, it + always returns the same value when given that pair of values as its + two arguments, and the result of applying ToNumber to this value is + not NaN; (b) when considered as a relation, where the pair (x, y) is + considered to be in the relation if and only if applying the function + to x and y and then applying ToNumber to the result produces a + negative value, this relation is a partial order; and (c) when + considered as a different relation, where the pair (x, y) is considered + to be in the relation if and only if applying the function to x and y + and then applying ToNumber to the result produces a zero value (of either + sign), this relation is an equivalence relation. In this context, the + phrase "x compares less than y" means applying Result(2) to x and y and + then applying ToNumber to the result produces a negative value. + 3.Return this object. - When the SortCompare operator is called with two arguments x and y, the following steps are taken: - 1.If x and y are both undefined, return +0. - 2.If x is undefined, return 1. - 3.If y is undefined, return 1. - 4.If the argument comparefn was not provided in the call to sort, go to step 7. - 5.Call comparefn with arguments x and y. - 6.Return Result(5). - 7.Call ToString(x). - 8.Call ToString(y). - 9.If Result(7) < Result(8), return 1. - 10.If Result(7) > Result(8), return 1. - 11.Return +0. + When the SortCompare operator is called with two arguments x and y, the following steps are taken: + 1.If x and y are both undefined, return +0. + 2.If x is undefined, return 1. + 3.If y is undefined, return 1. + 4.If the argument comparefn was not provided in the call to sort, go to step 7. + 5.Call comparefn with arguments x and y. + 6.Return Result(5). + 7.Call ToString(x). + 8.Call ToString(y). + 9.If Result(7) < Result(8), return 1. + 10.If Result(7) > Result(8), return 1. + 11.Return +0. -Note that, because undefined always compared greater than any other value, undefined and nonexistent -property values always sort to the end of the result. It is implementation-dependent whether or not such -properties will exist or not at the end of the array when the sort is concluded. + Note that, because undefined always compared greater than any other value, undefined and nonexistent + property values always sort to the end of the result. It is implementation-dependent whether or not such + properties will exist or not at the end of the array when the sort is concluded. -Note that the sort function is intentionally generic; it does not require that its this value be an Array object. -Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be -applied successfully to a host object is implementation dependent . + Note that the sort function is intentionally generic; it does not require that its this value be an Array object. + Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be + applied successfully to a host object is implementation dependent . - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.4.4.5-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.prototype.sort(comparefn)"; +var SECTION = "15.4.4.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.sort(comparefn)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var S = new Array(); +var item = 0; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +// array is empty. +S[item++] = "var A = new Array()"; + +// array contains one item +S[item++] = "var A = new Array( true )"; + +// length of array is 2 +S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; + +S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; + +S[item] = "var A = new Array( "; + +var limit = 0x0061; +for ( var i = 0x007A; i >= limit; i-- ) { + S[item] += "\'"+ String.fromCharCode(i) +"\'" ; + if ( i > limit ) { + S[item] += ","; + } } -function getTestCases() { - var S = new Array(); - var item = 0; - // array is empty. - S[item++] = "var A = new Array()"; - - // array contains one item - S[item++] = "var A = new Array( true )"; - - // length of array is 2 - S[item++] = "var A = new Array( true, false, new Boolean(true), new Boolean(false), 'true', 'false' )"; - - S[item++] = "var A = new Array(); A[3] = 'undefined'; A[6] = null; A[8] = 'null'; A[0] = void 0"; - - S[item] = "var A = new Array( "; - - var limit = 0x0061; - for ( var i = 0x007A; i >= limit; i-- ) { - S[item] += "\'"+ String.fromCharCode(i) +"\'" ; - if ( i > limit ) { - S[item] += ","; - } - } - - S[item] += ")"; - - for ( var i = 0; i < S.length; i++ ) { - CheckItems( S[i] ); - } +S[item] += ")"; +for ( var i = 0; i < S.length; i++ ) { + CheckItems( S[i] ); } + +test(); + function CheckItems( S ) { - eval( S ); - var E = Sort( A ); + eval( S ); + var E = Sort( A ); - testcases[testcases.length] = new TestCase( SECTION, - S +"; A.sort(Compare); A.length", - E.length, - eval( S + "; A.sort(Compare); A.length") ); + new TestCase( SECTION, + S +"; A.sort(Compare); A.length", + E.length, + eval( S + "; A.sort(Compare); A.length") ); - for ( var i = 0; i < E.length; i++ ) { - testcases[testcases.length] = new TestCase( - SECTION, - "A["+i+ "].toString()", - E[i] +"", - A[i] +""); + for ( var i = 0; i < E.length; i++ ) { + new TestCase( + SECTION, + "A["+i+ "].toString()", + E[i] +"", + A[i] +""); - if ( A[i] == void 0 && typeof A[i] == "undefined" ) { - testcases[testcases.length] = new TestCase( - SECTION, - "typeof A["+i+ "]", - typeof E[i], - typeof A[i] ); - } + if ( A[i] == void 0 && typeof A[i] == "undefined" ) { + new TestCase( + SECTION, + "typeof A["+i+ "]", + typeof E[i], + typeof A[i] ); } + } } function Object_1( value ) { - this.array = value.split(","); - this.length = this.array.length; - for ( var i = 0; i < this.length; i++ ) { - this[i] = eval(this.array[i]); - } - this.sort = Array.prototype.sort; - this.getClass = Object.prototype.toString; + this.array = value.split(","); + this.length = this.array.length; + for ( var i = 0; i < this.length; i++ ) { + this[i] = eval(this.array[i]); + } + this.sort = Array.prototype.sort; + this.getClass = Object.prototype.toString; } function Sort( a ) { - var r1 = a.length; - for ( i = 0; i < a.length; i++ ) { - for ( j = i+1; j < a.length; j++ ) { - var lo = a[i]; - var hi = a[j]; - var c = Compare( lo, hi ); - if ( c == 1 ) { - a[i] = hi; - a[j] = lo; - } - } + var r1 = a.length; + for ( i = 0; i < a.length; i++ ) { + for ( j = i+1; j < a.length; j++ ) { + var lo = a[i]; + var hi = a[j]; + var c = Compare( lo, hi ); + if ( c == 1 ) { + a[i] = hi; + a[j] = lo; + } } - return a; + } + return a; } function Compare( x, y ) { - if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { - return +0; - } - if ( x == void 0 && typeof x == "undefined" ) { - return 1; - } - if ( y == void 0 && typeof y == "undefined" ) { - return -1; - } - x = String(x); - y = String(y); - if ( x < y ) { - return 1; - } - if ( x > y ) { - return -1; - } - return 0; + if ( x == void 0 && y == void 0 && typeof x == "undefined" && typeof y == "undefined" ) { + return +0; + } + if ( x == void 0 && typeof x == "undefined" ) { + return 1; + } + if ( y == void 0 && typeof y == "undefined" ) { + return -1; + } + x = String(x); + y = String(y); + if ( x < y ) { + return 1; + } + if ( x > y ) { + return -1; + } + return 0; } diff --git a/mozilla/js/tests/ecma/Array/15.4.4.5-3.js b/mozilla/js/tests/ecma/Array/15.4.4.5-3.js index aedb9d597a3..7b98fa112b1 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.5-3.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.5-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,163 +35,146 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.4.5-3.js - ECMA Section: Array.prototype.sort(comparefn) - Description: + File Name: 15.4.4.5-3.js + ECMA Section: Array.prototype.sort(comparefn) + Description: - This is a regression test for - http://scopus/bugsplat/show_bug.cgi?id=117144 + This is a regression test for + http://scopus/bugsplat/show_bug.cgi?id=117144 - Verify that sort is successfull, even if the sort compare function returns - a very large negative or positive value. + Verify that sort is successfull, even if the sort compare function returns + a very large negative or positive value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.4.4.5-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.prototype.sort(comparefn)"; +var SECTION = "15.4.4.5-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.prototype.sort(comparefn)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - getTestCases(); - test(); +var array = new Array(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +array[array.length] = new Date( TIME_2000 * Math.PI ); +array[array.length] = new Date( TIME_2000 * 10 ); +array[array.length] = new Date( TIME_1900 + TIME_1900 ); +array[array.length] = new Date(0); +array[array.length] = new Date( TIME_2000 ); +array[array.length] = new Date( TIME_1900 + TIME_1900 +TIME_1900 ); +array[array.length] = new Date( TIME_1900 * Math.PI ); +array[array.length] = new Date( TIME_1900 * 10 ); +array[array.length] = new Date( TIME_1900 ); +array[array.length] = new Date( TIME_2000 + TIME_2000 ); +array[array.length] = new Date( 1899, 0, 1 ); +array[array.length] = new Date( 2000, 1, 29 ); +array[array.length] = new Date( 2000, 0, 1 ); +array[array.length] = new Date( 1999, 11, 31 ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +var testarr1 = new Array(); +clone( array, testarr1 ); +testarr1.sort( comparefn1 ); + +var testarr2 = new Array(); +clone( array, testarr2 ); +testarr2.sort( comparefn2 ); + +testarr3 = new Array(); +clone( array, testarr3 ); +testarr3.sort( comparefn3 ); + +// when there's no sort function, sort sorts by the toString value of Date. + +var testarr4 = new Array(); +clone( array, testarr4 ); +testarr4.sort(); + +var realarr = new Array(); +clone( array, realarr ); +realarr.sort( realsort ); + +var stringarr = new Array(); +clone( array, stringarr ); +stringarr.sort( stringsort ); + +for ( var i = 0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr1["+i+"]", + realarr[i], + testarr1[i] ); } -function getTestCases() { - var array = new Array(); - - array[array.length] = new Date( TIME_2000 * Math.PI ); - array[array.length] = new Date( TIME_2000 * 10 ); - array[array.length] = new Date( TIME_1900 + TIME_1900 ); - array[array.length] = new Date(0); - array[array.length] = new Date( TIME_2000 ); - array[array.length] = new Date( TIME_1900 + TIME_1900 +TIME_1900 ); - array[array.length] = new Date( TIME_1900 * Math.PI ); - array[array.length] = new Date( TIME_1900 * 10 ); - array[array.length] = new Date( TIME_1900 ); - array[array.length] = new Date( TIME_2000 + TIME_2000 ); - array[array.length] = new Date( 1899, 0, 1 ); - array[array.length] = new Date( 2000, 1, 29 ); - array[array.length] = new Date( 2000, 0, 1 ); - array[array.length] = new Date( 1999, 11, 31 ); - - var testarr1 = new Array() - clone( array, testarr1 ); - testarr1.sort( comparefn1 ); - - var testarr2 = new Array() - clone( array, testarr2 ); - testarr2.sort( comparefn2 ); - - testarr3 = new Array(); - clone( array, testarr3 ); - testarr3.sort( comparefn3 ); - - // when there's no sort function, sort sorts by the toString value of Date. - - var testarr4 = new Array() - clone( array, testarr4 ); - testarr4.sort(); - - var realarr = new Array(); - clone( array, realarr ); - realarr.sort( realsort ); - - var stringarr = new Array(); - clone( array, stringarr ); - stringarr.sort( stringsort ); - - for ( var i = 0, tc = 0; i < array.length; i++, tc++) { - testcases[tc] = new TestCase( - SECTION, - "testarr1["+i+"]", - realarr[i], - testarr1[i] ); - } - - for ( var i=0; i < array.length; i++, tc++) { - testcases[tc] = new TestCase( - SECTION, - "testarr2["+i+"]", - realarr[i], - testarr2[i] ); - } - - for ( var i=0; i < array.length; i++, tc++) { - testcases[tc] = new TestCase( - SECTION, - "testarr3["+i+"]", - realarr[i], - testarr3[i] ); - } - - for ( var i=0; i < array.length; i++, tc++) { - testcases[tc] = new TestCase( - SECTION, - "testarr4["+i+"]", - stringarr[i].toString(), - testarr4[i].toString() ); - } - +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr2["+i+"]", + realarr[i], + testarr2[i] ); } + +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr3["+i+"]", + realarr[i], + testarr3[i] ); +} + +for ( var i=0; i < array.length; i++) { + new TestCase( + SECTION, + "testarr4["+i+"]", + stringarr[i].toString(), + testarr4[i].toString() ); +} + +test(); + function comparefn1( x, y ) { - return x - y; + return x - y; } function comparefn2( x, y ) { - return x.valueOf() - y.valueOf(); + return x.valueOf() - y.valueOf(); } function realsort( x, y ) { - return ( x.valueOf() == y.valueOf() ? 0 : ( x.valueOf() > y.valueOf() ? 1 : -1 ) ); + return ( x.valueOf() == y.valueOf() ? 0 : ( x.valueOf() > y.valueOf() ? 1 : -1 ) ); } function comparefn3( x, y ) { - return ( x == y ? 0 : ( x > y ? 1: -1 ) ); + return ( x == y ? 0 : ( x > y ? 1: -1 ) ); } function clone( source, target ) { - for (i = 0; i < source.length; i++ ) { - target[i] = source[i]; - } + for (i = 0; i < source.length; i++ ) { + target[i] = source[i]; + } } function stringsort( x, y ) { - for ( var i = 0; i < x.toString().length; i++ ) { - var d = (x.toString()).charCodeAt(i) - (y.toString()).charCodeAt(i); - if ( d > 0 ) { - return 1; - } else { - if ( d < 0 ) { - return -1; - } else { - continue; - } - } + for ( var i = 0; i < x.toString().length; i++ ) { + var d = (x.toString()).charCodeAt(i) - (y.toString()).charCodeAt(i); + if ( d > 0 ) { + return 1; + } else { + if ( d < 0 ) { + return -1; + } else { + continue; + } + } - var d = x.length - y.length; + var d = x.length - y.length; - if ( d > 0 ) { - return 1; - } else { - if ( d < 0 ) { - return -1; - } - } - } - return 0; -} \ No newline at end of file + if ( d > 0 ) { + return 1; + } else { + if ( d < 0 ) { + return -1; + } + } + } + return 0; +} diff --git a/mozilla/js/tests/ecma/Array/15.4.4.js b/mozilla/js/tests/ecma/Array/15.4.4.js index eb1b96d1e2e..6d930dfcf5f 100644 --- a/mozilla/js/tests/ecma/Array/15.4.4.js +++ b/mozilla/js/tests/ecma/Array/15.4.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,59 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.4.js - ECMA Section: 15.4.4 Properties of the Array Prototype Object - Description: The value of the internal [[Prototype]] property of - the Array prototype object is the Object prototype - object. + File Name: 15.4.4.js + ECMA Section: 15.4.4 Properties of the Array Prototype Object + Description: The value of the internal [[Prototype]] property of + the Array prototype object is the Object prototype + object. - Note that the Array prototype object is itself an - array; it has a length property (whose initial value - is (0) and the special [[Put]] method. + Note that the Array prototype object is itself an + array; it has a length property (whose initial value + is (0) and the special [[Put]] method. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.4.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the Array Prototype Object"; +var SECTION = "15.4.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Array Prototype Object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - -// these testcases are ECMA_2 -// array[item++] = new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); -// array[item++] = new TestCase( SECTION, "Array.__proto__.valueOf == Object.__proto__.valueOf", true, (Array.__proto__.valueOf == Object.__proto__.valueOf) ); - - array[item++] = new TestCase( SECTION, "Array.prototype.length", 0, Array.prototype.length ); +new TestCase( SECTION, "Array.prototype.length", 0, Array.prototype.length ); // verify that prototype object is an Array object. - array[item++] = new TestCase( SECTION, "typeof Array.prototype", "object", typeof Array.prototype ); +new TestCase( SECTION, "typeof Array.prototype", "object", typeof Array.prototype ); - array[item++] = new TestCase( SECTION, - "Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()", - "[object Array]", - eval("Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()") ); +new TestCase( SECTION, + "Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()", + "[object Array]", + eval("Array.prototype.toString = Object.prototype.toString; Array.prototype.toString()") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.5.1-1.js b/mozilla/js/tests/ecma/Array/15.4.5.1-1.js index 11f129054fa..8ead61349e4 100644 --- a/mozilla/js/tests/ecma/Array/15.4.5.1-1.js +++ b/mozilla/js/tests/ecma/Array/15.4.5.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,154 +35,134 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.5.1-1.js - ECMA Section: [[ Put]] (P, V) - Description: - Array objects use a variation of the [[Put]] method used for other native - ECMAScript objects (section 8.6.2.2). + File Name: 15.4.5.1-1.js + ECMA Section: [[ Put]] (P, V) + Description: + Array objects use a variation of the [[Put]] method used for other native + ECMAScript objects (section 8.6.2.2). - Assume A is an Array object and P is a string. + Assume A is an Array object and P is a string. - When the [[Put]] method of A is called with property P and value V, the - following steps are taken: + When the [[Put]] method of A is called with property P and value V, the + following steps are taken: - 1. Call the [[CanPut]] method of A with name P. - 2. If Result(1) is false, return. - 3. If A doesn't have a property with name P, go to step 7. - 4. If P is "length", go to step 12. - 5. Set the value of property P of A to V. - 6. Go to step 8. - 7. Create a property with name P, set its value to V and give it empty - attributes. - 8. If P is not an array index, return. - 9. If A itself has a property (not an inherited property) named "length", - andToUint32(P) is less than the value of the length property of A, then - return. - 10. Change (or set) the value of the length property of A to ToUint32(P)+1. - 11. Return. - 12. Compute ToUint32(V). - 13. For every integer k that is less than the value of the length property - of A but not less than Result(12), if A itself has a property (not an - inherited property) named ToString(k), then delete that property. - 14. Set the value of property P of A to Result(12). - 15. Return. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Call the [[CanPut]] method of A with name P. + 2. If Result(1) is false, return. + 3. If A doesn't have a property with name P, go to step 7. + 4. If P is "length", go to step 12. + 5. Set the value of property P of A to V. + 6. Go to step 8. + 7. Create a property with name P, set its value to V and give it empty + attributes. + 8. If P is not an array index, return. + 9. If A itself has a property (not an inherited property) named "length", + andToUint32(P) is less than the value of the length property of A, then + return. + 10. Change (or set) the value of the length property of A to ToUint32(P)+1. + 11. Return. + 12. Compute ToUint32(V). + 13. For every integer k that is less than the value of the length property + of A but not less than Result(12), if A itself has a property (not an + inherited property) named ToString(k), then delete that property. + 14. Set the value of property P of A to Result(12). + 15. Return. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.4.5.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array [[Put]] (P, V)"; +var SECTION = "15.4.5.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array [[Put]] (P, V)"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - - var item = 0; - - // P is "length" - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A.length = 1000; A.length", - 1000, - eval("var A = new Array(); A.length = 1000; A.length") ); - - // A has Property P, and P is not length or an array index - array[item++] = new TestCase( SECTION, - "var A = new Array(1000); A.name = 'name of this array'; A.name", - 'name of this array', - eval("var A = new Array(1000); A.name = 'name of this array'; A.name") ); - - array[item++] = new TestCase( SECTION, - "var A = new Array(1000); A.name = 'name of this array'; A.length", - 1000, - eval("var A = new Array(1000); A.name = 'name of this array'; A.length") ); +writeHeaderToLog( SECTION + " "+ TITLE); - // A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the - // value of length +// P is "length" - array[item++] = new TestCase( SECTION, - "var A = new Array(1000); A[123] = 'hola'; A[123]", - 'hola', - eval("var A = new Array(1000); A[123] = 'hola'; A[123]") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 1000; A.length", + 1000, + eval("var A = new Array(); A.length = 1000; A.length") ); - array[item++] = new TestCase( SECTION, - "var A = new Array(1000); A[123] = 'hola'; A.length", - 1000, - eval("var A = new Array(1000); A[123] = 'hola'; A.length") ); +// A has Property P, and P is not length or an array index +new TestCase( SECTION, + "var A = new Array(1000); A.name = 'name of this array'; A.name", + 'name of this array', + eval("var A = new Array(1000); A.name = 'name of this array'; A.name") ); + +new TestCase( SECTION, + "var A = new Array(1000); A.name = 'name of this array'; A.length", + 1000, + eval("var A = new Array(1000); A.name = 'name of this array'; A.length") ); - for ( var i = 0X0020, TEST_STRING = "var A = new Array( " ; i < 0x00ff; i++ ) { - TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'"; - if ( i < 0x00FF - 1 ) { - TEST_STRING += ","; - } else { - TEST_STRING += ");" - } - } +// A has Property P, P is not length, P is an array index, and ToUint32(p) is less than the +// value of length - var LENGTH = 0x00ff - 0x0020; +new TestCase( SECTION, + "var A = new Array(1000); A[123] = 'hola'; A[123]", + 'hola', + eval("var A = new Array(1000); A[123] = 'hola'; A[123]") ); - array[item++] = new TestCase( SECTION, - TEST_STRING +" A[150] = 'hello'; A[150]", - 'hello', - eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) ); +new TestCase( SECTION, + "var A = new Array(1000); A[123] = 'hola'; A.length", + 1000, + eval("var A = new Array(1000); A[123] = 'hola'; A.length") ); - array[item++] = new TestCase( SECTION, - TEST_STRING +" A[150] = 'hello'; A[150]", - LENGTH, - eval( TEST_STRING + " A[150] = 'hello'; A.length" ) ); - // A has Property P, P is not length, P is an array index, and ToUint32(p) is not less than the - // value of length - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A[123] = true; A.length", - 124, - eval("var A = new Array(); A[123] = true; A.length") ); - - array[item++] = new TestCase( SECTION, - "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length", - 16, - eval("var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length") ); - - for ( var i = 0; i < A.length; i++, item++ ) { - array[item] = new TestCase( SECTION, - "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A[" +i +"]", - (i <= 10) ? i : ( i == 15 ? '15' : void 0 ), - A[i] ); - } - // P is not an array index, and P is not "length" - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A.join.length = 4; A.join.length", - 1, - eval("var A = new Array(); A.join.length = 4; A.join.length") ); - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A.join.length = 4; A.length", - 0, - eval("var A = new Array(); A.join.length = 4; A.length") ); - - return array; +for ( var i = 0X0020, TEST_STRING = "var A = new Array( " ; i < 0x00ff; i++ ) { + TEST_STRING += "\'\\"+ String.fromCharCode( i ) +"\'"; + if ( i < 0x00FF - 1 ) { + TEST_STRING += ","; + } else { + TEST_STRING += ");" + } } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +var LENGTH = 0x00ff - 0x0020; + +new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + 'hello', + eval( TEST_STRING + " A[150] = 'hello'; A[150]" ) ); + +new TestCase( SECTION, + TEST_STRING +" A[150] = 'hello'; A[150]", + LENGTH, + eval( TEST_STRING + " A[150] = 'hello'; A.length" ) ); + +// A has Property P, P is not length, P is an array index, and ToUint32(p) is not less than the +// value of length + +new TestCase( SECTION, + "var A = new Array(); A[123] = true; A.length", + 124, + eval("var A = new Array(); A[123] = true; A.length") ); + +new TestCase( SECTION, + "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length", + 16, + eval("var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A.length") ); + +for ( var i = 0; i < A.length; i++ ) { + new TestCase( SECTION, + "var A = new Array(0,1,2,3,4,5,6,7,8,9,10); A[15] ='15'; A[" +i +"]", + (i <= 10) ? i : ( i == 15 ? '15' : void 0 ), + A[i] ); } +// P is not an array index, and P is not "length" + +new TestCase( SECTION, + "var A = new Array(); A.join.length = 4; A.join.length", + 1, + eval("var A = new Array(); A.join.length = 4; A.join.length") ); + +new TestCase( SECTION, + "var A = new Array(); A.join.length = 4; A.length", + 0, + eval("var A = new Array(); A.join.length = 4; A.length") ); + +test(); diff --git a/mozilla/js/tests/ecma/Array/15.4.5.1-2.js b/mozilla/js/tests/ecma/Array/15.4.5.1-2.js index 20b355e309c..c35a69e07b4 100644 --- a/mozilla/js/tests/ecma/Array/15.4.5.1-2.js +++ b/mozilla/js/tests/ecma/Array/15.4.5.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,132 +35,116 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.5.1-2.js - ECMA Section: [[ Put]] (P, V) - Description: - Array objects use a variation of the [[Put]] method used for other native - ECMAScript objects (section 8.6.2.2). + File Name: 15.4.5.1-2.js + ECMA Section: [[ Put]] (P, V) + Description: + Array objects use a variation of the [[Put]] method used for other native + ECMAScript objects (section 8.6.2.2). - Assume A is an Array object and P is a string. + Assume A is an Array object and P is a string. - When the [[Put]] method of A is called with property P and value V, the - following steps are taken: + When the [[Put]] method of A is called with property P and value V, the + following steps are taken: - 1. Call the [[CanPut]] method of A with name P. - 2. If Result(1) is false, return. - 3. If A doesn't have a property with name P, go to step 7. - 4. If P is "length", go to step 12. - 5. Set the value of property P of A to V. - 6. Go to step 8. - 7. Create a property with name P, set its value to V and give it empty - attributes. - 8. If P is not an array index, return. - 9. If A itself has a property (not an inherited property) named "length", - andToUint32(P) is less than the value of the length property of A, then - return. - 10. Change (or set) the value of the length property of A to ToUint32(P)+1. - 11. Return. - 12. Compute ToUint32(V). - 13. For every integer k that is less than the value of the length property - of A but not less than Result(12), if A itself has a property (not an - inherited property) named ToString(k), then delete that property. - 14. Set the value of property P of A to Result(12). - 15. Return. + 1. Call the [[CanPut]] method of A with name P. + 2. If Result(1) is false, return. + 3. If A doesn't have a property with name P, go to step 7. + 4. If P is "length", go to step 12. + 5. Set the value of property P of A to V. + 6. Go to step 8. + 7. Create a property with name P, set its value to V and give it empty + attributes. + 8. If P is not an array index, return. + 9. If A itself has a property (not an inherited property) named "length", + andToUint32(P) is less than the value of the length property of A, then + return. + 10. Change (or set) the value of the length property of A to ToUint32(P)+1. + 11. Return. + 12. Compute ToUint32(V). + 13. For every integer k that is less than the value of the length property + of A but not less than Result(12), if A itself has a property (not an + inherited property) named ToString(k), then delete that property. + 14. Set the value of property P of A to Result(12). + 15. Return. - These are testcases from Waldemar, detailed in - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552 + These are testcases from Waldemar, detailed in + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123552 - Author: christine@netscape.com - Date: 15 June 1998 + Author: christine@netscape.com + Date: 15 June 1998 */ - var SECTION = "15.4.5.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array [[Put]] (P,V)"; +var SECTION = "15.4.5.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array [[Put]] (P,V)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var a = new Array(); - var a = new Array(); +AddCase( "3.00", "three" ); +AddCase( "00010", "eight" ); +AddCase( "37xyz", "thirty-five" ); +AddCase("5000000000", 5) + AddCase( "-2", -3 ); - AddCase( "3.00", "three" ); - AddCase( "00010", "eight" ); - AddCase( "37xyz", "thirty-five" ); - AddCase("5000000000", 5) - AddCase( "-2", -3 ); +new TestCase( SECTION, + "a[10]", + void 0, + a[10] ); - testcases[tc++] = new TestCase( SECTION, - "a[10]", - void 0, - a[10] ); +new TestCase( SECTION, + "a[3]", + void 0, + a[3] ); - testcases[tc++] = new TestCase( SECTION, - "a[3]", - void 0, - a[3] ); +a[4] = "four"; - a[4] = "four"; +new TestCase( SECTION, + "a[4] = \"four\"; a[4]", + "four", + a[4] ); - testcases[tc++] = new TestCase( SECTION, - "a[4] = \"four\"; a[4]", - "four", - a[4] ); +new TestCase( SECTION, + "a[\"4\"]", + "four", + a["4"] ); - testcases[tc++] = new TestCase( SECTION, - "a[\"4\"]", - "four", - a["4"] ); +new TestCase( SECTION, + "a[\"4.00\"]", + void 0, + a["4.00"] ); - testcases[tc++] = new TestCase( SECTION, - "a[\"4.00\"]", - void 0, - a["4.00"] ); - - testcases[tc++] = new TestCase( SECTION, - "a.length", - 5, - a.length ); +new TestCase( SECTION, + "a.length", + 5, + a.length ); - a["5000000000"] = 5; +a["5000000000"] = 5; - testcases[tc++] = new TestCase( SECTION, - "a[\"5000000000\"] = 5; a.length", - 5, - a.length ); +new TestCase( SECTION, + "a[\"5000000000\"] = 5; a.length", + 5, + a.length ); - testcases[tc++] = new TestCase( SECTION, - "a[\"-2\"] = -3; a.length", - 5, - a.length ); +new TestCase( SECTION, + "a[\"-2\"] = -3; a.length", + 5, + a.length ); - test(); +test(); function AddCase ( arg, value ) { - a[arg] = value; + a[arg] = value; - testcases[tc++] = new TestCase( SECTION, - "a[\"" + arg + "\"] = "+ value +"; a.length", - 0, - a.length ); -} - - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "a[\"" + arg + "\"] = "+ value +"; a.length", + 0, + a.length ); } diff --git a/mozilla/js/tests/ecma/Array/15.4.5.2-1.js b/mozilla/js/tests/ecma/Array/15.4.5.2-1.js index 6e1e74f9b51..0c10ba3f459 100644 --- a/mozilla/js/tests/ecma/Array/15.4.5.2-1.js +++ b/mozilla/js/tests/ecma/Array/15.4.5.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,75 +35,50 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.4.5.2-1.js - ECMA Section: Array.length - Description: - 15.4.5.2 length - The length property of this Array object is always numerically greater - than the name of every property whose name is an array index. - The length property has the attributes { DontEnum, DontDelete }. - Author: christine@netscape.com - Date: 12 november 1997 +/** + File Name: 15.4.5.2-1.js + ECMA Section: Array.length + Description: + 15.4.5.2 length + The length property of this Array object is always numerically greater + than the name of every property whose name is an array index. + + The length property has the attributes { DontEnum, DontDelete }. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.4.5.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.length"; +var SECTION = "15.4.5.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.length"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "var A = new Array(); A.length", + 0, + eval("var A = new Array(); A.length") ); +new TestCase( SECTION, + "var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length", + Math.pow(2,32)-1, + eval("var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; A.length", + 123, + eval("var A = new Array(); A.length = 123; A.length") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS", + "", + eval("var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; delete A.length", + false , + eval("var A = new Array(); A.length = 123; delete A.length") ); +new TestCase( SECTION, + "var A = new Array(); A.length = 123; delete A.length; A.length", + 123, + eval("var A = new Array(); A.length = 123; delete A.length; A.length") ); +test(); - array[item++] = new TestCase( SECTION, - "var A = new Array(); A.length", - 0, - eval("var A = new Array(); A.length") ); - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length", - Math.pow(2,32)-1, - eval("var A = new Array(); A[Math.pow(2,32)-2] = 'hi'; A.length") ); - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A.length = 123; A.length", - 123, - eval("var A = new Array(); A.length = 123; A.length") ); - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS", - "", - eval("var A = new Array(); A.length = 123; var PROPS = ''; for ( var p in A ) { PROPS += ( p == 'length' ? p : ''); } PROPS") ); - - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A.length = 123; delete A.length", - false , - eval("var A = new Array(); A.length = 123; delete A.length") ); - - array[item++] = new TestCase( SECTION, - "var A = new Array(); A.length = 123; delete A.length; A.length", - 123, - eval("var A = new Array(); A.length = 123; delete A.length; A.length") ); - return array; -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Array/15.4.5.2-2.js b/mozilla/js/tests/ecma/Array/15.4.5.2-2.js index 6d542b5b70c..33ece2e62b8 100644 --- a/mozilla/js/tests/ecma/Array/15.4.5.2-2.js +++ b/mozilla/js/tests/ecma/Array/15.4.5.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,105 +35,91 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.4.5.2-2.js - ECMA Section: Array.length - Description: - 15.4.5.2 length - The length property of this Array object is always numerically greater - than the name of every property whose name is an array index. + File Name: 15.4.5.2-2.js + ECMA Section: Array.length + Description: + 15.4.5.2 length + The length property of this Array object is always numerically greater + than the name of every property whose name is an array index. - The length property has the attributes { DontEnum, DontDelete }. + The length property has the attributes { DontEnum, DontDelete }. - This test verifies that the Array.length property is not Read Only. + This test verifies that the Array.length property is not Read Only. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.4.5.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Array.length"; +var SECTION = "15.4.5.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Array.length"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) ); - addCase( new Array(), 0, Math.pow(2,14), Math.pow(2,14) ); +addCase( new Array(), 0, 1, 1 ); - addCase( new Array(), 0, 1, 1 ); +addCase( new Array(Math.pow(2,12)), Math.pow(2,12), 0, 0 ); +addCase( new Array(Math.pow(2,13)), Math.pow(2,13), Math.pow(2,12), Math.pow(2,12) ); +addCase( new Array(Math.pow(2,12)), Math.pow(2,12), Math.pow(2,12), Math.pow(2,12) ); +addCase( new Array(Math.pow(2,14)), Math.pow(2,14), Math.pow(2,12), Math.pow(2,12) ) - addCase( new Array(Math.pow(2,12)), Math.pow(2,12), 0, 0 ); - addCase( new Array(Math.pow(2,13)), Math.pow(2,13), Math.pow(2,12), Math.pow(2,12) ); - addCase( new Array(Math.pow(2,12)), Math.pow(2,12), Math.pow(2,12), Math.pow(2,12) ); - addCase( new Array(Math.pow(2,14)), Math.pow(2,14), Math.pow(2,12), Math.pow(2,12) ) + // some tests where array is not empty + // array is populated with strings + for ( var arg = "", i = 0; i < Math.pow(2,12); i++ ) { + arg += String(i) + ( i != Math.pow(2,12)-1 ? "," : "" ); - // some tests where array is not empty - // array is populated with strings - for ( var arg = "", i = 0; i < Math.pow(2,12); i++ ) { - arg += String(i) + ( i != Math.pow(2,12)-1 ? "," : "" ); - - } +} // print(i +":"+arg); - var a = eval( "new Array("+arg+")" ); +var a = eval( "new Array("+arg+")" ); - addCase( a, i, i, i ); - addCase( a, i, Math.pow(2,12)+i+1, Math.pow(2,12)+i+1, true ); - addCase( a, Math.pow(2,12)+5, 0, 0, true ); +addCase( a, i, i, i ); +addCase( a, i, Math.pow(2,12)+i+1, Math.pow(2,12)+i+1, true ); +addCase( a, Math.pow(2,12)+5, 0, 0, true ); - test(); +test(); function addCase( object, old_len, set_len, new_len, checkitems ) { - object.length = set_len; + object.length = set_len; - testcases[testcases.length] = new TestCase( SECTION, - "array = new Array("+ old_len+"); array.length = " + set_len + - "; array.length", - new_len, - object.length ); + new TestCase( SECTION, + "array = new Array("+ old_len+"); array.length = " + set_len + + "; array.length", + new_len, + object.length ); - if ( checkitems ) { + if ( checkitems ) { // verify that items between old and newlen are all undefined if ( new_len < old_len ) { - var passed = true; - for ( var i = new_len; i < old_len; i++ ) { - if ( object[i] != void 0 ) { - passed = false; - } - } - testcases[testcases.length] = new TestCase( SECTION, - "verify that array items have been deleted", - true, - passed ); + var passed = true; + for ( var i = new_len; i < old_len; i++ ) { + if ( object[i] != void 0 ) { + passed = false; + } + } + new TestCase( SECTION, + "verify that array items have been deleted", + true, + passed ); } if ( new_len > old_len ) { - var passed = true; - for ( var i = old_len; i < new_len; i++ ) { - if ( object[i] != void 0 ) { - passed = false; - } - } - testcases[testcases.length] = new TestCase( SECTION, - "verify that new items are undefined", - true, - passed ); - } + var passed = true; + for ( var i = old_len; i < new_len; i++ ) { + if ( object[i] != void 0 ) { + passed = false; + } + } + new TestCase( SECTION, + "verify that new items are undefined", + true, + passed ); } + } } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Array/browser.js b/mozilla/js/tests/ecma/Array/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Array/shell.js b/mozilla/js/tests/ecma/Array/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Boolean/15.6.1.js b/mozilla/js/tests/ecma/Boolean/15.6.1.js index 9188e4ef7b2..757331220a3 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.1.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,60 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.1.js - ECMA Section: 15.6.1 The Boolean Function - 15.6.1.1 Boolean( value ) - 15.6.1.2 Boolean () - Description: Boolean( value ) should return a Boolean value - not a Boolean object) computed by - Boolean.toBooleanValue( value) + File Name: 15.6.1.js + ECMA Section: 15.6.1 The Boolean Function + 15.6.1.1 Boolean( value ) + 15.6.1.2 Boolean () + Description: Boolean( value ) should return a Boolean value + not a Boolean object) computed by + Boolean.toBooleanValue( value) - 15.6.1.2 Boolean() returns false + 15.6.1.2 Boolean() returns false - Author: christine@netscape.com - Date: 27 jun 1997 + Author: christine@netscape.com + Date: 27 jun 1997 - Data File Fields: - VALUE Argument passed to the Boolean function - TYPE typeof VALUE (not used, but helpful in understanding - the data file) - E_RETURN Expected return value of Boolean( VALUE ) + Data File Fields: + VALUE Argument passed to the Boolean function + TYPE typeof VALUE (not used, but helpful in understanding + the data file) + E_RETURN Expected return value of Boolean( VALUE ) */ - var SECTION = "15.6.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Boolean constructor called as a function: Boolean( value ) and Boolean()"; +var SECTION = "15.6.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Boolean constructor called as a function: Boolean( value ) and Boolean()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +var array = new Array(); +var item = 0; - test(); +new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); +new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); +new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); +new TestCase( SECTION, "Boolean('1')", true, Boolean("1") ); +new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); +new TestCase( SECTION, "Boolean('-1')", true, Boolean("-1") ); +new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); +new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Boolean('true')", true, Boolean("true") ); +new TestCase( SECTION, "Boolean('false')", true, Boolean("false") ); +new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); - array[item++] = new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); - array[item++] = new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); - array[item++] = new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); - array[item++] = new TestCase( SECTION, "Boolean('1')", true, Boolean("1") ); - array[item++] = new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); - array[item++] = new TestCase( SECTION, "Boolean('-1')", true, Boolean("-1") ); - array[item++] = new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); - array[item++] = new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); - - array[item++] = new TestCase( SECTION, "Boolean('true')", true, Boolean("true") ); - array[item++] = new TestCase( SECTION, "Boolean('false')", true, Boolean("false") ); - array[item++] = new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); - - array[item++] = new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Boolean(void(0))", false, Boolean( void(0) ) ); - array[item++] = new TestCase( SECTION, "Boolean(x=0)", false, Boolean( x=0 ) ); - array[item++] = new TestCase( SECTION, "Boolean(x=1)", true, Boolean( x=1 ) ); - array[item++] = new TestCase( SECTION, "Boolean(x=false)", false, Boolean( x=false ) ); - array[item++] = new TestCase( SECTION, "Boolean(x=true)", true, Boolean( x=true ) ); - array[item++] = new TestCase( SECTION, "Boolean(x=null)", false, Boolean( x=null ) ); - array[item++] = new TestCase( SECTION, "Boolean()", false, Boolean() ); +new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); +new TestCase( SECTION, "Boolean(void(0))", false, Boolean( void(0) ) ); +new TestCase( SECTION, "Boolean(x=0)", false, Boolean( x=0 ) ); +new TestCase( SECTION, "Boolean(x=1)", true, Boolean( x=1 ) ); +new TestCase( SECTION, "Boolean(x=false)", false, Boolean( x=false ) ); +new TestCase( SECTION, "Boolean(x=true)", true, Boolean( x=true ) ); +new TestCase( SECTION, "Boolean(x=null)", false, Boolean( x=null ) ); +new TestCase( SECTION, "Boolean()", false, Boolean() ); // array[item++] = new TestCase( SECTION, "Boolean(var someVar)", false, Boolean( someVar ) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.2.js b/mozilla/js/tests/ecma/Boolean/15.6.2.js index cc0b1d21292..08ddac7f084 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.2.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,142 +35,125 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.2.js - ECMA Section: 15.6.2 The Boolean Constructor - 15.6.2.1 new Boolean( value ) - 15.6.2.2 new Boolean() + File Name: 15.6.2.js + ECMA Section: 15.6.2 The Boolean Constructor + 15.6.2.1 new Boolean( value ) + 15.6.2.2 new Boolean() - This test verifies that the Boolean constructor - initializes a new object (typeof should return - "object"). The prototype of the new object should - be Boolean.prototype. The value of the object - should be ToBoolean( value ) (a boolean value). + This test verifies that the Boolean constructor + initializes a new object (typeof should return + "object"). The prototype of the new object should + be Boolean.prototype. The value of the object + should be ToBoolean( value ) (a boolean value). - Description: - Author: christine@netscape.com - Date: june 27, 1997 + Description: + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "15.6.2 The Boolean Constructor; 15.6.2.1 new Boolean( value ); 15.6.2.2 new Boolean()"; +var SECTION = "15.6.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "15.6.2 The Boolean Constructor; 15.6.2.1 new Boolean( value ); 15.6.2.2 new Boolean()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +var array = new Array(); +var item = 0; - test(); +new TestCase( SECTION, "typeof (new Boolean(1))", "object", typeof (new Boolean(1)) ); +new TestCase( SECTION, "(new Boolean(1)).constructor", Boolean.prototype.constructor, (new Boolean(1)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(1)).valueOf()", true, (new Boolean(1)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(1)", "object", typeof new Boolean(1) ); +new TestCase( SECTION, "(new Boolean(0)).constructor", Boolean.prototype.constructor, (new Boolean(0)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(0)).valueOf()", false, (new Boolean(0)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(0)", "object", typeof new Boolean(0) ); +new TestCase( SECTION, "(new Boolean(-1)).constructor", Boolean.prototype.constructor, (new Boolean(-1)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(-1)).valueOf()", true, (new Boolean(-1)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(-1)", "object", typeof new Boolean(-1) ); +new TestCase( SECTION, "(new Boolean('1')).constructor", Boolean.prototype.constructor, (new Boolean('1')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('1')).valueOf()", true, (new Boolean('1')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('1')", "object", typeof new Boolean('1') ); +new TestCase( SECTION, "(new Boolean('0')).constructor", Boolean.prototype.constructor, (new Boolean('0')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('0')).valueOf()", true, (new Boolean('0')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('0')", "object", typeof new Boolean('0') ); +new TestCase( SECTION, "(new Boolean('-1')).constructor", Boolean.prototype.constructor, (new Boolean('-1')).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean('-1')).valueOf()", true, (new Boolean('-1')).valueOf() ); +new TestCase( SECTION, "typeof new Boolean('-1')", "object", typeof new Boolean('-1') ); +new TestCase( SECTION, "(new Boolean(new Boolean(true))).constructor", Boolean.prototype.constructor, (new Boolean(new Boolean(true))).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(new Boolean(true))).valueOf()", true, (new Boolean(new Boolean(true))).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(new Boolean(true))", "object", typeof new Boolean(new Boolean(true)) ); +new TestCase( SECTION, "(new Boolean(Number.NaN)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NaN)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.NaN)).valueOf()", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.NaN)", "object", typeof new Boolean(Number.NaN) ); +new TestCase( SECTION, "(new Boolean(null)).constructor", Boolean.prototype.constructor, (new Boolean(null)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(null)).valueOf()", false, (new Boolean(null)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(null)", "object", typeof new Boolean(null) ); +new TestCase( SECTION, "(new Boolean(void 0)).constructor", Boolean.prototype.constructor, (new Boolean(void 0)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(void 0)).valueOf()", false, (new Boolean(void 0)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(void 0)", "object", typeof new Boolean(void 0) ); +new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.POSITIVE_INFINITY)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).valueOf()", true, (new Boolean(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.POSITIVE_INFINITY)", "object", typeof new Boolean(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); +new TestCase( SECTION, + "TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).valueOf()", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof new Boolean(Number.NEGATIVE_INFINITY)", "object", typeof new Boolean(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); +new TestCase( "15.6.2.2", + "TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", + "[object Boolean]", + eval("TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); +new TestCase( "15.6.2.2", "(new Boolean()).valueOf()", false, (new Boolean()).valueOf() ); +new TestCase( "15.6.2.2", "typeof new Boolean()", "object", typeof new Boolean() ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "typeof (new Boolean(1))", "object", typeof (new Boolean(1)) ); - array[item++] = new TestCase( SECTION, "(new Boolean(1)).constructor", Boolean.prototype.constructor, (new Boolean(1)).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(1)).valueOf()", true, (new Boolean(1)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(1)", "object", typeof new Boolean(1) ); - array[item++] = new TestCase( SECTION, "(new Boolean(0)).constructor", Boolean.prototype.constructor, (new Boolean(0)).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(0)).valueOf()", false, (new Boolean(0)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(0)", "object", typeof new Boolean(0) ); - array[item++] = new TestCase( SECTION, "(new Boolean(-1)).constructor", Boolean.prototype.constructor, (new Boolean(-1)).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(-1);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(-1)).valueOf()", true, (new Boolean(-1)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(-1)", "object", typeof new Boolean(-1) ); - array[item++] = new TestCase( SECTION, "(new Boolean('1')).constructor", Boolean.prototype.constructor, (new Boolean('1')).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean('1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean('1')).valueOf()", true, (new Boolean('1')).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean('1')", "object", typeof new Boolean('1') ); - array[item++] = new TestCase( SECTION, "(new Boolean('0')).constructor", Boolean.prototype.constructor, (new Boolean('0')).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean('0');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean('0')).valueOf()", true, (new Boolean('0')).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean('0')", "object", typeof new Boolean('0') ); - array[item++] = new TestCase( SECTION, "(new Boolean('-1')).constructor", Boolean.prototype.constructor, (new Boolean('-1')).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean('-1');TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean('-1')).valueOf()", true, (new Boolean('-1')).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean('-1')", "object", typeof new Boolean('-1') ); - array[item++] = new TestCase( SECTION, "(new Boolean(new Boolean(true))).constructor", Boolean.prototype.constructor, (new Boolean(new Boolean(true))).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(new Boolean(true));TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(new Boolean(true))).valueOf()", true, (new Boolean(new Boolean(true))).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(new Boolean(true))", "object", typeof new Boolean(new Boolean(true)) ); - array[item++] = new TestCase( SECTION, "(new Boolean(Number.NaN)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NaN)).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(Number.NaN);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(Number.NaN)).valueOf()", false, (new Boolean(Number.NaN)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.NaN)", "object", typeof new Boolean(Number.NaN) ); - array[item++] = new TestCase( SECTION, "(new Boolean(null)).constructor", Boolean.prototype.constructor, (new Boolean(null)).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(null);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(null)).valueOf()", false, (new Boolean(null)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(null)", "object", typeof new Boolean(null) ); - array[item++] = new TestCase( SECTION, "(new Boolean(void 0)).constructor", Boolean.prototype.constructor, (new Boolean(void 0)).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(void 0);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(void 0)).valueOf()", false, (new Boolean(void 0)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(void 0)", "object", typeof new Boolean(void 0) ); - array[item++] = new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.POSITIVE_INFINITY)).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(Number.POSITIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(Number.POSITIVE_INFINITY)).valueOf()", true, (new Boolean(Number.POSITIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.POSITIVE_INFINITY)", "object", typeof new Boolean(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); - array[item++] = new TestCase( SECTION, - "TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean(Number.NEGATIVE_INFINITY);TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).valueOf()", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof new Boolean(Number.NEGATIVE_INFINITY)", "object", typeof new Boolean(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "(new Boolean(Number.NEGATIVE_INFINITY)).constructor", Boolean.prototype.constructor, (new Boolean(Number.NEGATIVE_INFINITY)).constructor ); - array[item++] = new TestCase( "15.6.2.2", - "TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()", - "[object Boolean]", - eval("TESTBOOL=new Boolean();TESTBOOL.toString=Object.prototype.toString;TESTBOOL.toString()") ); - array[item++] = new TestCase( "15.6.2.2", "(new Boolean()).valueOf()", false, (new Boolean()).valueOf() ); - array[item++] = new TestCase( "15.6.2.2", "typeof new Boolean()", "object", typeof new Boolean() ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.3.1-1.js b/mozilla/js/tests/ecma/Boolean/15.6.3.1-1.js index 30cb1aece82..0edc5737853 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.3.1-1.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.3.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.3.1-1.js - ECMA Section: 15.6.3 Boolean.prototype + File Name: 15.6.3.1-1.js + ECMA Section: 15.6.3 Boolean.prototype - Description: The initial value of Boolean.prototype is the built-in - Boolean prototype object (15.6.4). + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). - The property shall have the attributes [DontEnum, - DontDelete, ReadOnly ]. + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. - This tests the DontEnum property of Boolean.prototype + This tests the DontEnum property of Boolean.prototype - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.3.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype"; +var SECTION = "15.6.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var array = new Array(); +var item = 0; -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var str='';for ( p in Boolean ) { str += p } str;", - "", - eval("var str='';for ( p in Boolean ) { str += p } str;") ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "var str='';for ( p in Boolean ) { str += p } str;", + "", + eval("var str='';for ( p in Boolean ) { str += p } str;") ); +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.3.1-2.js b/mozilla/js/tests/ecma/Boolean/15.6.3.1-2.js index 3c6d66eb788..a557dbe9a7d 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.3.1-2.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.3.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,51 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.3.1-2.js - ECMA Section: 15.6.3.1 Boolean.prototype + File Name: 15.6.3.1-2.js + ECMA Section: 15.6.3.1 Boolean.prototype - Description: The initial valu eof Boolean.prototype is the built-in - Boolean prototype object (15.6.4). + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). - The property shall have the attributes [DontEnum, - DontDelete, ReadOnly ]. + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. - This tests the DontDelete property of Boolean.prototype + This tests the DontDelete property of Boolean.prototype - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.3.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype" - writeHeaderToLog( SECTION + TITLE ); +var SECTION = "15.6.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" +writeHeaderToLog( SECTION + TITLE ); - var testcases = getTestCases(); - test(); +var array = new Array(); +var item = 0; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "delete( Boolean.prototype)", + false, + delete( Boolean.prototype) ); - array[item++] = new TestCase( SECTION, - "delete( Boolean.prototype)", - false, - delete( Boolean.prototype) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.3.1-3.js b/mozilla/js/tests/ecma/Boolean/15.6.3.1-3.js index ce25aa7d9c3..9671ed83659 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.3.1-3.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.3.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,51 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.3.1-3.js - ECMA Section: 15.6.3.1 Boolean.prototype + File Name: 15.6.3.1-3.js + ECMA Section: 15.6.3.1 Boolean.prototype - Description: The initial valu eof Boolean.prototype is the built-in - Boolean prototype object (15.6.4). + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). - The property shall have the attributes [DontEnum, - DontDelete, ReadOnly ]. + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. - This tests the DontDelete property of Boolean.prototype + This tests the DontDelete property of Boolean.prototype - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.3.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype" - writeHeaderToLog( SECTION + TITLE ); +var SECTION = "15.6.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" +writeHeaderToLog( SECTION + TITLE ); - var testcases = getTestCases(); - test(); +var array = new Array(); +var item = 0; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "delete( Boolean.prototype); Boolean.prototype", + Boolean.prototype, + eval("delete( Boolean.prototype); Boolean.prototype") ); - array[item++] = new TestCase( SECTION, - "delete( Boolean.prototype); Boolean.prototype", - Boolean.prototype, - eval("delete( Boolean.prototype); Boolean.prototype") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.3.1-4.js b/mozilla/js/tests/ecma/Boolean/15.6.3.1-4.js index b3e9c58a338..ac2433ba51a 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.3.1-4.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.3.1-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,39 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.3.1-4.js - ECMA Section: 15.6.3.1 Properties of the Boolean Prototype Object + File Name: 15.6.3.1-4.js + ECMA Section: 15.6.3.1 Properties of the Boolean Prototype Object - Description: The initial value of Boolean.prototype is the built-in - Boolean prototype object (15.6.4). + Description: The initial value of Boolean.prototype is the built-in + Boolean prototype object (15.6.4). - The property shall have the attributes [DontEnum, - DontDelete, ReadOnly ]. + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. - This tests the ReadOnly property of Boolean.prototype + This tests the ReadOnly property of Boolean.prototype - Author: christine@netscape.com - Date: 30 september 1997 + Author: christine@netscape.com + Date: 30 september 1997 */ - var SECTION = "15.6.3.1-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype" - writeHeaderToLog( SECTION + TITLE ); +var SECTION = "15.6.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype" +writeHeaderToLog( SECTION + TITLE ); - var testcases = getTestCases(); - test(); +var BOOL_PROTO = Boolean.prototype; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO", + true, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO") ); - var BOOL_PROTO = Boolean.prototype; +new TestCase( SECTION, + "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null", + false, + eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null") ); - array[item++] = new TestCase( SECTION, - "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO", - true, - eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == BOOL_PROTO") ); - - array[item++] = new TestCase( SECTION, - "var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null", - false, - eval("var BOOL_PROTO = Boolean.prototype; Boolean.prototype=null; Boolean.prototype == null") ); - - return ( array ); -} - - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.3.1-5.js b/mozilla/js/tests/ecma/Boolean/15.6.3.1-5.js index 0d69cdb39a1..2ba82e117f1 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.3.1-5.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.3.1-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,43 +35,22 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.3.1-5.js - ECMA Section: 15.6.3.1 Boolean.prototype - Description: - Author: christine@netscape.com - Date: 28 october 1997 + File Name: 15.6.3.1-5.js + ECMA Section: 15.6.3.1 Boolean.prototype + Description: + Author: christine@netscape.com + Date: 28 october 1997 */ - var VERSION = "ECMA_2"; - startTest(); - var SECTION = "15.6.3.1-5"; - var TITLE = "Boolean.prototype" +var VERSION = "ECMA_2"; +startTest(); +var SECTION = "15.6.3.1-5"; +var TITLE = "Boolean.prototype" - writeHeaderToLog( SECTION + " " + TITLE ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " " + TITLE ); -// all tests must call a function that returns an array of TestCase objects. - test(); +new TestCase( SECTION, "Function.prototype == Boolean.__proto__", true, Function.prototype == Boolean.__proto__ ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Function.prototype == Boolean.__proto__", true, Function.prototype == Boolean.__proto__ ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.3.1.js b/mozilla/js/tests/ecma/Boolean/15.6.3.1.js index 0462f653f35..afc75ee26e5 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.3.1.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.3.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.3.1.js - ECMA Section: 15.6.3.1 Boolean.prototype + File Name: 15.6.3.1.js + ECMA Section: 15.6.3.1 Boolean.prototype - Description: The initial valu eof Boolean.prototype is the built-in - Boolean prototype object (15.6.4). + Description: The initial valu eof Boolean.prototype is the built-in + Boolean prototype object (15.6.4). - The property shall have the attributes [DontEnum, - DontDelete, ReadOnly ]. + The property shall have the attributes [DontEnum, + DontDelete, ReadOnly ]. - It has the internal [[Call]] and [[Construct]] - properties (not tested), and the length property. + It has the internal [[Call]] and [[Construct]] + properties (not tested), and the length property. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.3.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype"; +var SECTION = "15.6.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); +new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); - array[item++] = new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.3.js b/mozilla/js/tests/ecma/Boolean/15.6.3.js index fb4a8ee1744..66db9338ae5 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.3.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.3.js - ECMA Section: 15.6.3 Properties of the Boolean Constructor + File Name: 15.6.3.js + ECMA Section: 15.6.3 Properties of the Boolean Constructor - Description: The value of the internal prototype property is - the Function prototype object. + Description: The value of the internal prototype property is + the Function prototype object. - It has the internal [[Call]] and [[Construct]] - properties, and the length property. + It has the internal [[Call]] and [[Construct]] + properties, and the length property. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.3"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "Properties of the Boolean Constructor" - writeHeaderToLog( SECTION + TITLE ); +var SECTION = "15.6.3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Boolean Constructor" +writeHeaderToLog( SECTION + TITLE ); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "Boolean.__proto__ == Function.prototype", true, Boolean.__proto__ == Function.prototype ); +new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "Boolean.__proto__ == Function.prototype", true, Boolean.__proto__ == Function.prototype ); - array[item++] = new TestCase( SECTION, "Boolean.length", 1, Boolean.length ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4-1.js b/mozilla/js/tests/ecma/Boolean/15.6.4-1.js index 46b53953fc5..e3910ab1021 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4-1.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,55 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4-1.js - ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + File Name: 15.6.4-1.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object - Description: - The Boolean prototype object is itself a Boolean object (its [[Class]] is - "Boolean") whose value is false. + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. - The value of the internal [[Prototype]] property of the Boolean prototype object - is the Object prototype object (15.2.3.1). + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). - Author: christine@netscape.com - Date: 30 september 1997 + Author: christine@netscape.com + Date: 30 september 1997 */ - var VERSION = "ECMA_1" - startTest(); - var SECTION = "15.6.4-1"; +var VERSION = "ECMA_1" +startTest(); +var SECTION = "15.6.4-1"; - writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); - var testcases = getTestCases(); - test(); +writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "typeof Boolean.prototype == typeof( new Boolean )", true, typeof Boolean.prototype == typeof( new Boolean ) ); +new TestCase( SECTION, "typeof( Boolean.prototype )", "object", typeof(Boolean.prototype) ); +new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); +new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Boolean.prototype == typeof( new Boolean )", true, typeof Boolean.prototype == typeof( new Boolean ) ); - array[item++] = new TestCase( SECTION, "typeof( Boolean.prototype )", "object", typeof(Boolean.prototype) ); - array[item++] = new TestCase( SECTION, - "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", - "[object Boolean]", - eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); - array[item++] = new TestCase( SECTION, "Boolean.prototype.valueOf()", false, Boolean.prototype.valueOf() ); - - return ( array ); -} - -function test() { - for (tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4-2.js b/mozilla/js/tests/ecma/Boolean/15.6.4-2.js index 330cc6b96f4..47a108ea1ac 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4-2.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4-2.js - ECMA Section: 15.6.4 Properties of the Boolean Prototype Object + File Name: 15.6.4-2.js + ECMA Section: 15.6.4 Properties of the Boolean Prototype Object - Description: - The Boolean prototype object is itself a Boolean object (its [[Class]] is - "Boolean") whose value is false. + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is + "Boolean") whose value is false. - The value of the internal [[Prototype]] property of the Boolean prototype object - is the Object prototype object (15.2.3.1). + The value of the internal [[Prototype]] property of the Boolean prototype object + is the Object prototype object (15.2.3.1). - Author: christine@netscape.com - Date: 30 september 1997 + Author: christine@netscape.com + Date: 30 september 1997 */ - var VERSION = "ECMA_2" - startTest(); - var SECTION = "15.6.4-2"; +var VERSION = "ECMA_2" +startTest(); +var SECTION = "15.6.4-2"; - writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); - var testcases = getTestCases(); - test(); +writeHeaderToLog( SECTION + " Properties of the Boolean Prototype Object"); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); - - return ( array ); -} - -function test() { - for (tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.1.js b/mozilla/js/tests/ecma/Boolean/15.6.4.1.js index 22b8eb9c089..0eec10335d1 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.1.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,26 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.1.js - ECMA Section: 15.6.4.1 Boolean.prototype.constructor + File Name: 15.6.4.1.js + ECMA Section: 15.6.4.1 Boolean.prototype.constructor - Description: The initial value of Boolean.prototype.constructor - is the built-in Boolean constructor. + Description: The initial value of Boolean.prototype.constructor + is the built-in Boolean constructor. - Author: christine@netscape.com - Date: 30 september 1997 + Author: christine@netscape.com + Date: 30 september 1997 */ - var SECTION = "15.6.4.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.constructor" - writeHeaderToLog( SECTION + TITLE ); +var SECTION = "15.6.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.constructor" +writeHeaderToLog( SECTION + TITLE ); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "( Boolean.prototype.constructor == Boolean )", - true , - (Boolean.prototype.constructor == Boolean) ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "( Boolean.prototype.constructor == Boolean )", + true , + (Boolean.prototype.constructor == Boolean) ); +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.2-1.js b/mozilla/js/tests/ecma/Boolean/15.6.4.2-1.js index a4cf9b0693e..70e82da5b8e 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.2-1.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,79 +35,61 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.2.js - ECMA Section: 15.6.4.2-1 Boolean.prototype.toString() - Description: If this boolean value is true, then the string "true" - is returned; otherwise this boolean value must be false, - and the string "false" is returned. + File Name: 15.6.4.2.js + ECMA Section: 15.6.4.2-1 Boolean.prototype.toString() + Description: If this boolean value is true, then the string "true" + is returned; otherwise this boolean value must be false, + and the string "false" is returned. - The toString function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.4.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.toString()" - writeHeaderToLog( SECTION + TITLE ); +var SECTION = "15.6.4.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" +writeHeaderToLog( SECTION + TITLE ); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "new Boolean(1)", "true", (new Boolean(1)).toString() ); +new TestCase( SECTION, "new Boolean(0)", "false", (new Boolean(0)).toString() ); +new TestCase( SECTION, "new Boolean(-1)", "true", (new Boolean(-1)).toString() ); +new TestCase( SECTION, "new Boolean('1')", "true", (new Boolean("1")).toString() ); +new TestCase( SECTION, "new Boolean('0')", "true", (new Boolean("0")).toString() ); +new TestCase( SECTION, "new Boolean(true)", "true", (new Boolean(true)).toString() ); +new TestCase( SECTION, "new Boolean(false)", "false", (new Boolean(false)).toString() ); +new TestCase( SECTION, "new Boolean('true')", "true", (new Boolean('true')).toString() ); +new TestCase( SECTION, "new Boolean('false')", "true", (new Boolean('false')).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(1)", "true", (new Boolean(1)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(0)", "false", (new Boolean(0)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(-1)", "true", (new Boolean(-1)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean('1')", "true", (new Boolean("1")).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean('0')", "true", (new Boolean("0")).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(true)", "true", (new Boolean(true)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(false)", "false", (new Boolean(false)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean('true')", "true", (new Boolean('true')).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean('false')", "true", (new Boolean('false')).toString() ); +new TestCase( SECTION, "new Boolean('')", "false", (new Boolean('')).toString() ); +new TestCase( SECTION, "new Boolean(null)", "false", (new Boolean(null)).toString() ); +new TestCase( SECTION, "new Boolean(void(0))", "false", (new Boolean(void(0))).toString() ); +new TestCase( SECTION, "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() ); +new TestCase( SECTION, "new Boolean(NaN)", "false", (new Boolean(Number.NaN)).toString() ); +new TestCase( SECTION, "new Boolean()", "false", (new Boolean()).toString() ); +new TestCase( SECTION, "new Boolean(x=1)", "true", (new Boolean(x=1)).toString() ); +new TestCase( SECTION, "new Boolean(x=0)", "false", (new Boolean(x=0)).toString() ); +new TestCase( SECTION, "new Boolean(x=false)", "false", (new Boolean(x=false)).toString() ); +new TestCase( SECTION, "new Boolean(x=true)", "true", (new Boolean(x=true)).toString() ); +new TestCase( SECTION, "new Boolean(x=null)", "false", (new Boolean(x=null)).toString() ); +new TestCase( SECTION, "new Boolean(x='')", "false", (new Boolean(x="")).toString() ); +new TestCase( SECTION, "new Boolean(x=' ')", "true", (new Boolean(x=" ")).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean('')", "false", (new Boolean('')).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(null)", "false", (new Boolean(null)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(void(0))", "false", (new Boolean(void(0))).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(-Infinity)", "true", (new Boolean(Number.NEGATIVE_INFINITY)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(NaN)", "false", (new Boolean(Number.NaN)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean()", "false", (new Boolean()).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=1)", "true", (new Boolean(x=1)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=0)", "false", (new Boolean(x=0)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=false)", "false", (new Boolean(x=false)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=true)", "true", (new Boolean(x=true)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=null)", "false", (new Boolean(x=null)).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(x='')", "false", (new Boolean(x="")).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=' ')", "true", (new Boolean(x=" ")).toString() ); +new TestCase( SECTION, "new Boolean(new MyObject(true))", "true", (new Boolean(new MyObject(true))).toString() ); +new TestCase( SECTION, "new Boolean(new MyObject(false))", "true", (new Boolean(new MyObject(false))).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(new MyObject(true))", "true", (new Boolean(new MyObject(true))).toString() ); - array[item++] = new TestCase( SECTION, "new Boolean(new MyObject(false))", "true", (new Boolean(new MyObject(false))).toString() ); +test(); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - return this; -} \ No newline at end of file + this.value = value; + this.valueOf = new Function( "return this.value" ); + return this; +} diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.2-2.js b/mozilla/js/tests/ecma/Boolean/15.6.4.2-2.js index 275996cddb2..b64be2b0861 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.2-2.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.2-2.js - ECMA Section: 15.6.4.2 Boolean.prototype.toString() - Description: Returns this boolean value. + File Name: 15.6.4.2-2.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. - The toString function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.4.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.toString()" - writeHeaderToLog( SECTION + TITLE ); +var SECTION = "15.6.4.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" +writeHeaderToLog( SECTION + TITLE ); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - - array[item++] = new TestCase( SECTION, - "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()", - "false", - "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()" ); - array[item++] = new TestCase( SECTION, - "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()", - "true", - "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()" ); - array[item++] = new TestCase( SECTION, - "tostr=Boolean.prototype.toString; x=new Boolean(false); x.toString=tostr;x.toString()", - "false", - "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()" ); - return ( array ); - -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()", + "false", + eval("tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()") ); +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()", + "true", + eval("tostr=Boolean.prototype.toString; x=new Boolean(true); x.toString=tostr; x.toString()") ); +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new Boolean(false); x.toString=tostr;x.toString()", + "false", + eval("tostr=Boolean.prototype.toString; x=new Boolean(); x.toString=tostr;x.toString()") ); +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.2-3.js b/mozilla/js/tests/ecma/Boolean/15.6.4.2-3.js index f9f095715d2..a7289efc965 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.2-3.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.2-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.2-3.js - ECMA Section: 15.6.4.2 Boolean.prototype.toString() - Description: Returns this boolean value. + File Name: 15.6.4.2-3.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. - The toString function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.4.2-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.toString()" - writeHeaderToLog( SECTION + TITLE ); +var SECTION = "15.6.4.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()" +writeHeaderToLog( SECTION + TITLE ); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()", "true", eval("tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()") ); +new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()", "false", eval("tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()", "true", eval("tostr=Boolean.prototype.toString; x=true; x.toString=tostr;x.toString()") ); - array[item++] = new TestCase( SECTION, "tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()", "false", eval("tostr=Boolean.prototype.toString; x=false; x.toString=tostr;x.toString()") ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.2-4-n.js b/mozilla/js/tests/ecma/Boolean/15.6.4.2-4-n.js index e8c5988a0dd..1bf12f4463d 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.2-4-n.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.2-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.2-4.js - ECMA Section: 15.6.4.2 Boolean.prototype.toString() - Description: Returns this boolean value. + File Name: 15.6.4.2-4.js + ECMA Section: 15.6.4.2 Boolean.prototype.toString() + Description: Returns this boolean value. - The toString function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.4.2-4-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.toString()"; - writeHeaderToLog( SECTION +" "+ TITLE ); +var SECTION = "15.6.4.2-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.toString()"; +writeHeaderToLog( SECTION +" "+ TITLE ); - var testcases = getTestCases(); - test(); +DESCRIPTION = "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()", + "error", + eval("tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()") ); - array[item++] = new TestCase( SECTION, - "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()", - "error", - "tostr=Boolean.prototype.toString; x=new String( 'hello' ); x.toString=tostr; x.toString()" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval(testcases[tc].actual); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.3-1.js b/mozilla/js/tests/ecma/Boolean/15.6.4.3-1.js index 5c1cb13c3b8..0dbab94e151 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.3-1.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,73 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.3.js - ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() - Description: Returns this boolean value. + File Name: 15.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. - The valueOf function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.4.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.valueOf()"; +var SECTION = "15.6.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "new Boolean(0)", false, (new Boolean(0)).valueOf() ); +new TestCase( SECTION, "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); +new TestCase( SECTION, "new Boolean('1')", true, (new Boolean("1")).valueOf() ); +new TestCase( SECTION, "new Boolean('0')", true, (new Boolean("0")).valueOf() ); +new TestCase( SECTION, "new Boolean(true)", true, (new Boolean(true)).valueOf() ); +new TestCase( SECTION, "new Boolean(false)", false, (new Boolean(false)).valueOf() ); +new TestCase( SECTION, "new Boolean('true')", true, (new Boolean("true")).valueOf() ); +new TestCase( SECTION, "new Boolean('false')", true, (new Boolean('false')).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(1)", true, (new Boolean(1)).valueOf() ); +new TestCase( SECTION, "new Boolean('')", false, (new Boolean('')).valueOf() ); +new TestCase( SECTION, "new Boolean(null)", false, (new Boolean(null)).valueOf() ); +new TestCase( SECTION, "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); +new TestCase( SECTION, "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( SECTION, "new Boolean()", false, (new Boolean()).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(0)", false, (new Boolean(0)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean('1')", true, (new Boolean("1")).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean('0')", true, (new Boolean("0")).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(true)", true, (new Boolean(true)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(false)", false, (new Boolean(false)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean('true')", true, (new Boolean("true")).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean('false')", true, (new Boolean('false')).valueOf() ); +new TestCase( SECTION, "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); +new TestCase( SECTION, "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); +new TestCase( SECTION, "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); +new TestCase( SECTION, "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean('')", false, (new Boolean('')).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(null)", false, (new Boolean(null)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean()", false, (new Boolean()).valueOf() ); - - array[item++] = new TestCase( SECTION, "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); - array[item++] = new TestCase( SECTION, "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.3-2.js b/mozilla/js/tests/ecma/Boolean/15.6.4.3-2.js index 06b44b875a5..3abd1f1e5c9 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.3-2.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,31 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.3-2.js - ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() - Description: Returns this boolean value. + File Name: 15.6.4.3-2.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. - The valueOf function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.4.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.valueOf()"; +var SECTION = "15.6.4.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()", false, eval("valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()") ); + +new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()", true, eval("valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()") ); - array[item++] = new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()", false, eval("valof=Boolean.prototype.valueOf; x=new Boolean(); x.valueOf=valof;x.valueOf()") ); - array[item++] = new TestCase( SECTION, "valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()", true, eval("valof=Boolean.prototype.valueOf; x=new Boolean(true); x.valueOf=valof;x.valueOf()") ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.3-3.js b/mozilla/js/tests/ecma/Boolean/15.6.4.3-3.js index 842d0d5f4ae..7db19acdb4b 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.3-3.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.3-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.3-3.js - ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() - Description: Returns this boolean value. + File Name: 15.6.4.3-3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. - The valueOf function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.4.3-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.valueOf()"; +var SECTION = "15.6.4.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()", - true, - eval("x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()") ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()", + true, + eval("x=true; x.valueOf=Boolean.prototype.valueOf;x.valueOf()") ); +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.3-4-n.js b/mozilla/js/tests/ecma/Boolean/15.6.4.3-4-n.js index bf59233514d..364e079031e 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.3-4-n.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.3-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.3-4.js - ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() - Description: Returns this boolean value. + File Name: 15.6.4.3-4.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. - The valueOf function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "15.6.4.3-4-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean.prototype.valueOf()"; +var SECTION = "15.6.4.3-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean.prototype.valueOf()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +DESCRIPTION = "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()" +EXPECTED = "error"; - test(); +new TestCase( SECTION, + "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()", + "error", + eval("valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()", - "error", - "valof=Boolean.prototype.valueOf; x=new String( 'hello' ); x.valueOf=valof;x.valueOf()" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.3.js b/mozilla/js/tests/ecma/Boolean/15.6.4.3.js index 2c3492fa882..798168959b0 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.3.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,79 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.3.js - ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() - Description: Returns this boolean value. + File Name: 15.6.4.3.js + ECMA Section: 15.6.4.3 Boolean.prototype.valueOf() + Description: Returns this boolean value. - The valueOf function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( "15.8.6.4", "new Boolean(1)", true, (new Boolean(1)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(0)", false, (new Boolean(0)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean('1')", true, (new Boolean("1")).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean('0')", true, (new Boolean("0")).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(true)", true, (new Boolean(true)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(false)", false, (new Boolean(false)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean('true')", true, (new Boolean("true")).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean('false')", true, (new Boolean('false')).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(1)", true, (new Boolean(1)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean('')", false, (new Boolean('')).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(null)", false, (new Boolean(null)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean()", false, (new Boolean()).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(0)", false, (new Boolean(0)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(-1)", true, (new Boolean(-1)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('1')", true, (new Boolean("1")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('0')", true, (new Boolean("0")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(true)", true, (new Boolean(true)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(false)", false, (new Boolean(false)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('true')", true, (new Boolean("true")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('false')", true, (new Boolean('false')).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); - array[item++] = new TestCase( "15.8.6.4", "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean('')", false, (new Boolean('')).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(null)", false, (new Boolean(null)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(void(0))", false, (new Boolean(void(0))).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(-Infinity)", true, (new Boolean(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(NaN)", false, (new Boolean(Number.NaN)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean()", false, (new Boolean()).valueOf() ); - return ( array ); -} +new TestCase( "15.8.6.4", "new Boolean(x=1)", true, (new Boolean(x=1)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=0)", false, (new Boolean(x=0)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=false)", false, (new Boolean(x=false)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=true)", true, (new Boolean(x=true)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=null)", false, (new Boolean(x=null)).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x='')", false, (new Boolean(x="")).valueOf() ); +new TestCase( "15.8.6.4", "new Boolean(x=' ')", true, (new Boolean(x=" ")).valueOf() ); -function test( array ) { - var passed = true; - - writeHeaderToLog("15.8.6.4.3 Properties of the Boolean Object: valueOf"); - - for ( i = 0; i < array.length; i++ ) { - - array[i].passed = writeTestCaseResult( - array[i].expect, - array[i].actual, - "( "+ array[i].description +" ).valueOf() = "+ array[i].actual ); - - array[i].reason += ( array[i].passed ) ? "" : "wrong value "; - - passed = ( array[i].passed ) ? passed : false; - - } - - stopTest(); - - // all tests must return a boolean value - return ( array ); -} - -// for TCMS, the testcases array must be global. - var testcases = getTestCases(); - -// all tests must call a function that returns a boolean value - test( testcases ); +test(); diff --git a/mozilla/js/tests/ecma/Boolean/15.6.4.js b/mozilla/js/tests/ecma/Boolean/15.6.4.js index 5c672410a2b..9d9dd60229b 100644 --- a/mozilla/js/tests/ecma/Boolean/15.6.4.js +++ b/mozilla/js/tests/ecma/Boolean/15.6.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,59 +35,44 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.6.4.js - ECMA Section: Properties of the Boolean Prototype Object - Description: - The Boolean prototype object is itself a Boolean object (its [[Class]] is " - Boolean") whose value is false. + File Name: 15.6.4.js + ECMA Section: Properties of the Boolean Prototype Object + Description: + The Boolean prototype object is itself a Boolean object (its [[Class]] is " + Boolean") whose value is false. - The value of the internal [[Prototype]] property of the Boolean prototype - object is the Object prototype object (15.2.3.1). + The value of the internal [[Prototype]] property of the Boolean prototype + object is the Object prototype object (15.2.3.1). - In following descriptions of functions that are properties of the Boolean - prototype object, the phrase "this Boolean object" refers to the object that - is the this value for the invocation of the function; it is an error if - this does not refer to an object for which the value of the internal - [[Class]] property is "Boolean". Also, the phrase "this boolean value" - refers to the boolean value represented by this Boolean object, that is, - the value of the internal [[Value]] property of this Boolean object. + In following descriptions of functions that are properties of the Boolean + prototype object, the phrase "this Boolean object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Boolean". Also, the phrase "this boolean value" + refers to the boolean value represented by this Boolean object, that is, + the value of the internal [[Value]] property of this Boolean object. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.6.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the Boolean Prototype Object"; +var SECTION = "15.6.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Boolean Prototype Object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "Boolean.prototype == false", + true, + Boolean.prototype == false ); - testcases[tc++] = new TestCase( SECTION, - "Boolean.prototype == false", - true, - Boolean.prototype == false ); +new TestCase( SECTION, + "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", + "[object Boolean]", + eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); - testcases[tc++] = new TestCase( SECTION, - "Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()", - "[object Boolean]", - eval("Boolean.prototype.toString = Object.prototype.toString; Boolean.prototype.toString()") ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Boolean/browser.js b/mozilla/js/tests/ecma/Boolean/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Boolean/shell.js b/mozilla/js/tests/ecma/Boolean/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Date/15.9.1.1-1.js b/mozilla/js/tests/ecma/Date/15.9.1.1-1.js index d097b6e9dfd..766c55703a7 100644 --- a/mozilla/js/tests/ecma/Date/15.9.1.1-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.1.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,56 +35,32 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.1.1-1.js - ECMA Section: 15.9.1.1 Time Range - Description: - - leap seconds are ignored - - assume 86400000 ms / day - - numbers range fom +/- 9,007,199,254,740,991 - - ms precision for any instant that is within - approximately +/-285,616 years from 1 jan 1970 - UTC - - range of times supported is -100,000,000 days - to 100,000,000 days from 1 jan 1970 12:00 am - - time supported is 8.64e5*10e8 milliseconds from - 1 jan 1970 UTC (+/-273972.6027397 years) + File Name: 15.9.1.1-1.js + ECMA Section: 15.9.1.1 Time Range + Description: + - leap seconds are ignored + - assume 86400000 ms / day + - numbers range fom +/- 9,007,199,254,740,991 + - ms precision for any instant that is within + approximately +/-285,616 years from 1 jan 1970 + UTC + - range of times supported is -100,000,000 days + to 100,000,000 days from 1 jan 1970 12:00 am + - time supported is 8.64e5*10e8 milliseconds from + 1 jan 1970 UTC (+/-273972.6027397 years) - - this test generates its own data -- it does not - read data from a file. - Author: christine@netscape.com - Date: 7 july 1997 + - this test generates its own data -- it does not + read data from a file. + Author: christine@netscape.com + Date: 7 july 1997 - Static variables: - FOUR_HUNDRED_YEARS + Static variables: + FOUR_HUNDRED_YEARS */ -function test() { - writeHeaderToLog("15.8.1.1 Time Range"); - - for ( M_SECS = 0, CURRENT_YEAR = 1970; - M_SECS < 8640000000000000; - tc++, M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) { - - testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS)).getUTCFullYear() ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - if ( ! testcases[tc].passed ) { - testcases[tc].reason = "wrong year value"; - } - } - - stopTest(); - - return ( testcases ); -} - // every one hundred years contains: // 24 years with 366 days // @@ -94,9 +71,23 @@ function test() { // 86400000*365*97 = 3067372800000 // +86400000*366*303 = + 9555408000000 // = 1.26227808e+13 - var FOUR_HUNDRED_YEARS = 1.26227808e+13; - var SECTION = "15.9.1.1-1"; - var tc = 0; - var testcases = new Array(); +var FOUR_HUNDRED_YEARS = 1.26227808e+13; +var SECTION = "15.9.1.1-1"; + +writeHeaderToLog("15.8.1.1 Time Range"); + +var M_SECS; +var CURRENT_YEAR; + +for ( M_SECS = 0, CURRENT_YEAR = 1970; + M_SECS < 8640000000000000; + M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) { + + new TestCase( SECTION, + "new Date("+M_SECS+")", + CURRENT_YEAR, + (new Date( M_SECS)).getUTCFullYear() ); +} + +test(); - test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.1.1-2.js b/mozilla/js/tests/ecma/Date/15.9.1.1-2.js index 78beb9d06f5..060c2fcfeb2 100644 --- a/mozilla/js/tests/ecma/Date/15.9.1.1-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.1.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,64 +35,54 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.1.1-2.js - ECMA Section: 15.9.1.1 Time Range - Description: - - leap seconds are ignored - - assume 86400000 ms / day - - numbers range fom +/- 9,007,199,254,740,991 - - ms precision for any instant that is within - approximately +/-285,616 years from 1 jan 1970 - UTC - - range of times supported is -100,000,000 days - to 100,000,000 days from 1 jan 1970 12:00 am - - time supported is 8.64e5*10e8 milliseconds from - 1 jan 1970 UTC (+/-273972.6027397 years) - Author: christine@netscape.com - Date: 9 july 1997 + File Name: 15.9.1.1-2.js + ECMA Section: 15.9.1.1 Time Range + Description: + - leap seconds are ignored + - assume 86400000 ms / day + - numbers range fom +/- 9,007,199,254,740,991 + - ms precision for any instant that is within + approximately +/-285,616 years from 1 jan 1970 + UTC + - range of times supported is -100,000,000 days + to 100,000,000 days from 1 jan 1970 12:00 am + - time supported is 8.64e5*10e8 milliseconds from + 1 jan 1970 UTC (+/-273972.6027397 years) + Author: christine@netscape.com + Date: 9 july 1997 */ -function test() { +// every one hundred years contains: +// 24 years with 366 days +// +// every four hundred years contains: +// 97 years with 366 days +// 303 years with 365 days +// +// 86400000*366*97 = 3067372800000 +// +86400000*365*303 = + 9555408000000 +// = 1.26227808e+13 - writeHeaderToLog("15.8.1.1 Time Range"); +var FOUR_HUNDRED_YEARS = 1.26227808e+13; +var SECTION = "15.9.1.1-2"; - for ( M_SECS = 0, CURRENT_YEAR = 1970; - M_SECS > -8640000000000000; - tc++, M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) { +writeHeaderToLog("15.8.1.1 Time Range"); - testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS )).getUTCFullYear() ); +var M_SECS; +var CURRENT_YEAR; - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description + " = " + - testcases[tc].actual ); +for ( M_SECS = 0, CURRENT_YEAR = 1970; + M_SECS > -8640000000000000; + M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) { - if ( ! testcases[tc].passed ) { - testcases[tc].reason = "wrong year value"; - } - } + new TestCase( SECTION, + "new Date("+M_SECS+")", + CURRENT_YEAR, + (new Date( M_SECS )).getUTCFullYear() ); - stopTest(); - - return ( testcases ); } - // every one hundred years contains: - // 24 years with 366 days - // - // every four hundred years contains: - // 97 years with 366 days - // 303 years with 365 days - // - // 86400000*366*97 = 3067372800000 - // +86400000*365*303 = + 9555408000000 - // = 1.26227808e+13 - var FOUR_HUNDRED_YEARS = 1.26227808e+13; - var SECTION = "15.9.1.1-2"; - var tc = 0; - var testcases = new Array(); - - test(); +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.2.1.js b/mozilla/js/tests/ecma/Date/15.9.2.1.js index d031df036ab..4b72f70289d 100644 --- a/mozilla/js/tests/ecma/Date/15.9.2.1.js +++ b/mozilla/js/tests/ecma/Date/15.9.2.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,90 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.2.1.js - ECMA Section: 15.9.2.1 Date constructor used as a function - Date( year, month, date, hours, minutes, seconds, ms ) - Description: The arguments are accepted, but are completely ignored. - A string is created and returned as if by the - expression (new Date()).toString(). - Author: christine@netscape.com - Date: 28 october 1997 +/** + File Name: 15.9.2.1.js + ECMA Section: 15.9.2.1 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds, ms ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "15.9.2.1"; - var TITLE = "Date Constructor used as a function"; - var TYPEOF = "string"; - var TOLERANCE = 1000; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.2.1"; +var TITLE = "Date Constructor used as a function"; +var TYPEOF = "string"; +var TOLERANCE = 1000; - writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " + - "Date( year, month, date, hours, minutes, seconds, ms )" ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog("15.9.2.1 The Date Constructor Called as a Function: " + + "Date( year, month, date, hours, minutes, seconds, ms )" ); -// all tests must call a function that returns an array of TestCase objects. - test(); +var TODAY = new Date(); -function getTestCases() { - var array = new Array(); - var item = 0; +// Dates around 1970 - var TODAY = new Date(); +new TestCase( SECTION, "Date(1970,0,1,0,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0,0) ); +new TestCase( SECTION, "Date(1969,11,31,15,59,59,999)", (new Date()).toString(), Date(1969,11,31,15,59,59,999)); +new TestCase( SECTION, "Date(1969,11,31,16,0,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0,0)); +new TestCase( SECTION, "Date(1969,11,31,16,0,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,0,1)); - // Dates around 1970 + // Dates around 2000 + new TestCase( SECTION, "Date(1999,11,15,59,59,999)", (new Date()).toString(), Date(1999,11,15,59,59,999)); +new TestCase( SECTION, "Date(1999,11,16,0,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0,0)); +new TestCase( SECTION, "Date(1999,11,31,23,59,59,999)", (new Date()).toString(), Date(1999,11,31,23,59,59,999) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0,0) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59,999)", (new Date()).toString(), Date(1969,11,31,15,59,59,999)) - array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0,0)) - array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,0,1)) +// Dates around 1900 - // Dates around 2000 - array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59,999)", (new Date()).toString(), Date(1999,11,15,59,59,999)); - array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0,0)); - array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59,999)", (new Date()).toString(), Date(1999,11,31,23,59,59,999) ); - array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,0,1) ); +new TestCase( SECTION, "Date(1899,11,31,23,59,59,999)", (new Date()).toString(), Date(1899,11,31,23,59,59,999)); +new TestCase( SECTION, "Date(1900,0,1,0,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0,0) ); +new TestCase( SECTION, "Date(1900,0,1,0,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,0,1) ); +new TestCase( SECTION, "Date(1899,11,31,16,0,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0,0)); - // Dates around 1900 +// Dates around feb 29, 2000 - array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59,999)", (new Date()).toString(), Date(1899,11,31,23,59,59,999)); - array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0,0)); +new TestCase( SECTION, "Date( 2000,1,29,0,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0,0)); +new TestCase( SECTION, "Date( 2000,1,28,23,59,59,999)", (new Date()).toString(), Date( 2000,1,28,23,59,59,999)); +new TestCase( SECTION, "Date( 2000,1,27,16,0,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0,0)); - // Dates around feb 29, 2000 +// Dates around jan 1, 2005 +new TestCase( SECTION, "Date(2004,11,31,23,59,59,999)", (new Date()).toString(), Date(2004,11,31,23,59,59,999)); +new TestCase( SECTION, "Date(2005,0,1,0,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0,0) ); +new TestCase( SECTION, "Date(2005,0,1,0,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,0,1) ); +new TestCase( SECTION, "Date(2004,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0,0)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0,0)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59,999)", (new Date()).toString(), Date( 2000,1,28,23,59,59,999)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0,0)); +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59,999)", (new Date()).toString(), Date(2031,11,31,23,59,59,999)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0,0)); - // Dates around jan 1, 2005 - array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59,999)", (new Date()).toString(), Date(2004,11,31,23,59,59,999)); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0,0)); - - // Dates around jan 1, 2032 - array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59,999)", (new Date()).toString(), Date(2031,11,31,23,59,59,999)); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0,0)); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.2.2-1.js b/mozilla/js/tests/ecma/Date/15.9.2.2-1.js index 78121544c35..6639af743a8 100644 --- a/mozilla/js/tests/ecma/Date/15.9.2.2-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.2.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,87 +35,66 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.2.2.js - ECMA Section: 15.9.2.2 Date constructor used as a function - Date( year, month, date, hours, minutes, seconds ) - Description: The arguments are accepted, but are completely ignored. - A string is created and returned as if by the - expression (new Date()).toString(). + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = 9706; - startTest(); - var SECTION = "15.9.2.2"; - var TOLERANCE = 100; - var TITLE = "The Date Constructor Called as a Function"; +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; - writeHeaderToLog(SECTION+" "+TITLE ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog(SECTION+" "+TITLE ); -// all tests must call a function that returns an array of TestCase objects. - test(); +// Dates around 1970 -function getTestCases() { - var array = new Array(); - var item = 0; - - // Dates around 1970 - - array[item++] = new TestCase( SECTION, "Date(1970,0,1,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(1969,11,31,15,59,59)", (new Date()).toString(), Date(1969,11,31,15,59,59)) - array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0)) - array[item++] = new TestCase( SECTION, "Date(1969,11,31,16,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,1)) +new TestCase( SECTION, "Date(1970,0,1,0,0,0)", (new Date()).toString(), Date(1970,0,1,0,0,0) ); +new TestCase( SECTION, "Date(1969,11,31,15,59,59)", (new Date()).toString(), Date(1969,11,31,15,59,59)); +new TestCase( SECTION, "Date(1969,11,31,16,0,0)", (new Date()).toString(), Date(1969,11,31,16,0,0)); +new TestCase( SECTION, "Date(1969,11,31,16,0,1)", (new Date()).toString(), Date(1969,11,31,16,0,1)); /* - // Dates around 2000 - array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); - array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); - array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); - array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); +// Dates around 2000 +new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); +new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); +new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); - // Dates around 1900 +// Dates around 1900 - array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); +new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); +new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); +new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); +new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); - // Dates around feb 29, 2000 +// Dates around feb 29, 2000 - array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); +new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); +new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); +new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); - // Dates around jan 1, 2005 - array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); +// Dates around jan 1, 2005 +new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); +new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); - // Dates around jan 1, 2032 - array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.2.2-2.js b/mozilla/js/tests/ecma/Date/15.9.2.2-2.js index 89f7aa4bcd8..a21d3359dd5 100644 --- a/mozilla/js/tests/ecma/Date/15.9.2.2-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.2.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,60 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.2.2.js - ECMA Section: 15.9.2.2 Date constructor used as a function - Date( year, month, date, hours, minutes, seconds ) - Description: The arguments are accepted, but are completely ignored. - A string is created and returned as if by the - expression (new Date()).toString(). - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = 9706; - startTest(); - var SECTION = "15.9.2.2"; - var TOLERANCE = 100; - var TITLE = "The Date Constructor Called as a Function"; +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; - writeHeaderToLog(SECTION+" "+TITLE ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog(SECTION+" "+TITLE ); -// all tests must call a function that returns an array of TestCase objects. - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // Dates around 2000 - array[item++] = new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); - array[item++] = new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); - array[item++] = new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); - array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); +// Dates around 2000 +new TestCase( SECTION, "Date(1999,11,15,59,59)", (new Date()).toString(), Date(1999,11,15,59,59)); +new TestCase( SECTION, "Date(1999,11,16,0,0,0)", (new Date()).toString(), Date(1999,11,16,0,0,0)); +new TestCase( SECTION, "Date(1999,11,31,23,59,59)", (new Date()).toString(), Date(1999,11,31,23,59,59) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,0)", (new Date()).toString(), Date(2000,0,0,0,0,0) ); +new TestCase( SECTION, "Date(2000,0,1,0,0,1)", (new Date()).toString(), Date(2000,0,0,0,0,1) ); /* - // Dates around 1900 +// Dates around 1900 - array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); +new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); +new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); +new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); +new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); - // Dates around feb 29, 2000 +// Dates around feb 29, 2000 - array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); +new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); +new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); +new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); - // Dates around jan 1, 2005 - array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); +// Dates around jan 1, 2005 +new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); +new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); - // Dates around jan 1, 2032 - array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.2.2-3.js b/mozilla/js/tests/ecma/Date/15.9.2.2-3.js index b005c85ec27..05e938c6340 100644 --- a/mozilla/js/tests/ecma/Date/15.9.2.2-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.2.2-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,74 +35,53 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.2.2.js - ECMA Section: 15.9.2.2 Date constructor used as a function - Date( year, month, date, hours, minutes, seconds ) - Description: The arguments are accepted, but are completely ignored. - A string is created and returned as if by the - expression (new Date()).toString(). - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = 9706; - startTest(); - var SECTION = "15.9.2.2"; - var TOLERANCE = 100; - var TITLE = "The Date Constructor Called as a Function"; +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; - writeHeaderToLog(SECTION+" "+TITLE ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog(SECTION+" "+TITLE ); -// all tests must call a function that returns an array of TestCase objects. - test(); +// Dates around 1900 -function getTestCases() { - var array = new Array(); - var item = 0; - - // Dates around 1900 - - array[item++] = new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); +new TestCase( SECTION, "Date(1899,11,31,23,59,59)", (new Date()).toString(), Date(1899,11,31,23,59,59)); +new TestCase( SECTION, "Date(1900,0,1,0,0,0)", (new Date()).toString(), Date(1900,0,1,0,0,0) ); +new TestCase( SECTION, "Date(1900,0,1,0,0,1)", (new Date()).toString(), Date(1900,0,1,0,0,1) ); +new TestCase( SECTION, "Date(1899,11,31,16,0,0,0)", (new Date()).toString(), Date(1899,11,31,16,0,0,0)); /* - // Dates around feb 29, 2000 +// Dates around feb 29, 2000 - array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); +new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); +new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); +new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); - // Dates around jan 1, 2005 - array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); +// Dates around jan 1, 2005 +new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); +new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); - // Dates around jan 1, 2032 - array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.2.2-4.js b/mozilla/js/tests/ecma/Date/15.9.2.2-4.js index 63e18d9ca07..406d6161e7b 100644 --- a/mozilla/js/tests/ecma/Date/15.9.2.2-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.2.2-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,67 +35,46 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.2.2.js - ECMA Section: 15.9.2.2 Date constructor used as a function - Date( year, month, date, hours, minutes, seconds ) - Description: The arguments are accepted, but are completely ignored. - A string is created and returned as if by the - expression (new Date()).toString(). - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = 9706; - startTest(); - var SECTION = "15.9.2.2"; - var TOLERANCE = 100; - var TITLE = "The Date Constructor Called as a Function"; +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; - writeHeaderToLog(SECTION+" "+TITLE ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog(SECTION+" "+TITLE ); -// all tests must call a function that returns an array of TestCase objects. - test(); +// Dates around feb 29, 2000 -function getTestCases() { - var array = new Array(); - var item = 0; - - // Dates around feb 29, 2000 - - array[item++] = new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); - array[item++] = new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); +new TestCase( SECTION, "Date( 2000,1,29,0,0,0)", (new Date()).toString(), Date(2000,1,29,0,0,0)); +new TestCase( SECTION, "Date( 2000,1,28,23,59,59)", (new Date()).toString(), Date( 2000,1,28,23,59,59)); +new TestCase( SECTION, "Date( 2000,1,27,16,0,0)", (new Date()).toString(), Date(2000,1,27,16,0,0)); /* - // Dates around jan 1, 2005 - array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); +// Dates around jan 1, 2005 +new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); +new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); - // Dates around jan 1, 2032 - array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.2.2-5.js b/mozilla/js/tests/ecma/Date/15.9.2.2-5.js index 99f2feec64a..a94854fea9b 100644 --- a/mozilla/js/tests/ecma/Date/15.9.2.2-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.2.2-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,60 +35,39 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.2.2.js - ECMA Section: 15.9.2.2 Date constructor used as a function - Date( year, month, date, hours, minutes, seconds ) - Description: The arguments are accepted, but are completely ignored. - A string is created and returned as if by the - expression (new Date()).toString(). + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = 9706; - startTest(); - var SECTION = "15.9.2.2"; - var TOLERANCE = 100; - var TITLE = "The Date Constructor Called as a Function"; +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; - writeHeaderToLog(SECTION+" "+TITLE ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog(SECTION+" "+TITLE ); -// all tests must call a function that returns an array of TestCase objects. - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // Dates around jan 1, 2005 - array[item++] = new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); +// Dates around jan 1, 2005 +new TestCase( SECTION, "Date(2004,11,31,23,59,59)", (new Date()).toString(), Date(2004,11,31,23,59,59)); +new TestCase( SECTION, "Date(2005,0,1,0,0,0)", (new Date()).toString(), Date(2005,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2005,0,1,0,0,1)", (new Date()).toString(), Date(2005,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2004,11,31,16,0,0,0)", (new Date()).toString(), Date(2004,11,31,16,0,0,0)); /* - // Dates around jan 1, 2032 - array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.2.2-6.js b/mozilla/js/tests/ecma/Date/15.9.2.2-6.js index 4761baa3d00..6400233fe26 100644 --- a/mozilla/js/tests/ecma/Date/15.9.2.2-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.2.2-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,31 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.2.2.js - ECMA Section: 15.9.2.2 Date constructor used as a function - Date( year, month, date, hours, minutes, seconds ) - Description: The arguments are accepted, but are completely ignored. - A string is created and returned as if by the - expression (new Date()).toString(). - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 +/** + File Name: 15.9.2.2.js + ECMA Section: 15.9.2.2 Date constructor used as a function + Date( year, month, date, hours, minutes, seconds ) + Description: The arguments are accepted, but are completely ignored. + A string is created and returned as if by the + expression (new Date()).toString(). + + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = 9706; - startTest(); - var SECTION = "15.9.2.2"; - var TOLERANCE = 100; - var TITLE = "The Date Constructor Called as a Function"; +var VERSION = 9706; +startTest(); +var SECTION = "15.9.2.2"; +var TOLERANCE = 100; +var TITLE = "The Date Constructor Called as a Function"; - writeHeaderToLog(SECTION+" "+TITLE ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog(SECTION+" "+TITLE ); -// all tests must call a function that returns an array of TestCase objects. - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // Dates around jan 1, 2032 - array[item++] = new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); - array[item++] = new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); - array[item++] = new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +// Dates around jan 1, 2032 +new TestCase( SECTION, "Date(2031,11,31,23,59,59)", (new Date()).toString(), Date(2031,11,31,23,59,59)); +new TestCase( SECTION, "Date(2032,0,1,0,0,0)", (new Date()).toString(), Date(2032,0,1,0,0,0) ); +new TestCase( SECTION, "Date(2032,0,1,0,0,1)", (new Date()).toString(), Date(2032,0,1,0,0,1) ); +new TestCase( SECTION, "Date(2031,11,31,16,0,0,0)", (new Date()).toString(), Date(2031,11,31,16,0,0,0)); +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.3.1-1.js b/mozilla/js/tests/ecma/Date/15.9.3.1-1.js index bb45298c416..dc15cd3cc3c 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.1-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,255 +36,234 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.9.3.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); +var TZ_ADJUST = TZ_PST * msPerHour; - var testcases = new Array(); +// Dates around 1970 - getTestCases(); - test(); +addNewTestCase( new Date( 1969,11,31,15,59,59,999), + "new Date( 1969,11,31,15,59,59,999)", + [TIME_1970-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = TZ_PST * msPerHour; +addNewTestCase( new Date( 1969,11,31,23,59,59,999), + "new Date( 1969,11,31,23,59,59,999)", + [TIME_1970-TZ_ADJUST-1,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); - // Dates around 1970 +addNewTestCase( new Date( 1970,0,1,0,0,0,0), + "new Date( 1970,0,1,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date( 1969,11,31,15,59,59,999), - "new Date( 1969,11,31,15,59,59,999)", - [TIME_1970-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); +addNewTestCase( new Date( 1969,11,31,16,0,0,0), + "new Date( 1969,11,31,16,0,0,0)", + [TIME_1970,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - addNewTestCase( new Date( 1969,11,31,23,59,59,999), - "new Date( 1969,11,31,23,59,59,999)", - [TIME_1970-TZ_ADJUST-1,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); +addNewTestCase( new Date(1969,12,1,0,0,0,0), + "new Date(1969,12,1,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date( 1970,0,1,0,0,0,0), - "new Date( 1970,0,1,0,0,0,0)", - [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date(1969,11,32,0,0,0,0), + "new Date(1969,11,32,0,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date( 1969,11,31,16,0,0,0), - "new Date( 1969,11,31,16,0,0,0)", - [TIME_1970,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +addNewTestCase( new Date(1969,11,31,24,0,0,0), + "new Date(1969,11,31,24,0,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date(1969,12,1,0,0,0,0), - "new Date(1969,12,1,0,0,0,0)", - [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date(1969,11,31,23,60,0,0), + "new Date(1969,11,31,23,60,0,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date(1969,11,32,0,0,0,0), - "new Date(1969,11,32,0,0,0,0)", - [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date(1969,11,31,23,59,60,0), + "new Date(1969,11,31,23,59,60,0)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date(1969,11,31,24,0,0,0), - "new Date(1969,11,31,24,0,0,0)", - [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date(1969,11,31,23,59,59,1000), + "new Date(1969,11,31,23,59,59,1000)", + [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date(1969,11,31,23,60,0,0), - "new Date(1969,11,31,23,60,0,0)", - [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +// Dates around 2000 - addNewTestCase( new Date(1969,11,31,23,59,60,0), - "new Date(1969,11,31,23,59,60,0)", - [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date( 1999,11,31,15,59,59,999), + "new Date( 1999,11,31,15,59,59,999)", + [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); - addNewTestCase( new Date(1969,11,31,23,59,59,1000), - "new Date(1969,11,31,23,59,59,1000)", - [TIME_1970-TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date( 1999,11,31,16,0,0,0), + "new Date( 1999,11,31,16,0,0,0)", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); - // Dates around 2000 +addNewTestCase( new Date( 1999,11,31,23,59,59,999), + "new Date( 1999,11,31,23,59,59,999)", + [TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); - addNewTestCase( new Date( 1999,11,31,15,59,59,999), - "new Date( 1999,11,31,15,59,59,999)", - [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); +addNewTestCase( new Date( 2000,0,1,0,0,0,0), + "new Date( 2000,0,1,0,0,0,0)", + [TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date( 1999,11,31,16,0,0,0), - "new Date( 1999,11,31,16,0,0,0)", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); +addNewTestCase( new Date( 2000,0,1,0,0,0,1), + "new Date( 2000,0,1,0,0,0,1)", + [TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); - addNewTestCase( new Date( 1999,11,31,23,59,59,999), - "new Date( 1999,11,31,23,59,59,999)", - [TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); +// Dates around 29 Feb 2000 - addNewTestCase( new Date( 2000,0,1,0,0,0,0), - "new Date( 2000,0,1,0,0,0,0)", - [TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); - addNewTestCase( new Date( 2000,0,1,0,0,0,1), - "new Date( 2000,0,1,0,0,0,1)", - [TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); +addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - // Dates around 29 Feb 2000 +addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); +addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date(2000,1,28,16,0,0,0), - "new Date(2000,1,28,16,0,0,0)", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +// Dates around 1900 - addNewTestCase( new Date(2000,1,29,0,0,0,0), - "new Date(2000,1,29,0,0,0,0)", - [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(2000,1,28,24,0,0,0), - "new Date(2000,1,28,24,0,0,0)", - [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); - // Dates around 1900 +addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); - addNewTestCase( new Date(1899,11,31,16,0,0,0), - "new Date(1899,11,31,16,0,0,0)", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date(1899,11,31,15,59,59,999), - "new Date(1899,11,31,15,59,59,999)", - [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); +addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); - addNewTestCase( new Date(1899,11,31,23,59,59,999), - "new Date(1899,11,31,23,59,59,999)", - [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); +// Dates around 2005 - addNewTestCase( new Date(1900,0,1,0,0,0,0), - "new Date(1900,0,1,0,0,0,0)", - [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - addNewTestCase( new Date(1900,0,1,0,0,0,1), - "new Date(1900,0,1,0,0,0,1)", - [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); +addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - // Dates around 2005 - - var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings test case + // Daylight Savings test case - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); + function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - var item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; -} diff --git a/mozilla/js/tests/ecma/Date/15.9.3.1-2.js b/mozilla/js/tests/ecma/Date/15.9.3.1-2.js index 9c1ffe4b517..d79d1b06ab4 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.1-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,213 +35,195 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.9.3.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - getTestCases(); - test(); +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = TZ_PST * msPerHour; -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = TZ_PST * msPerHour; +// Dates around 2000 - // Dates around 2000 +addNewTestCase( new Date( 1999,11,31,15,59,59,999), + "new Date( 1999,11,31,15,59,59,999)", + [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); - addNewTestCase( new Date( 1999,11,31,15,59,59,999), - "new Date( 1999,11,31,15,59,59,999)", - [TIME_2000-1,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); +addNewTestCase( new Date( 1999,11,31,16,0,0,0), + "new Date( 1999,11,31,16,0,0,0)", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); - addNewTestCase( new Date( 1999,11,31,16,0,0,0), - "new Date( 1999,11,31,16,0,0,0)", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); +addNewTestCase( new Date( 1999,11,31,23,59,59,999), + "new Date( 1999,11,31,23,59,59,999)", + [TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); - addNewTestCase( new Date( 1999,11,31,23,59,59,999), - "new Date( 1999,11,31,23,59,59,999)", - [TIME_2000-TZ_ADJUST-1,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); +addNewTestCase( new Date( 2000,0,1,0,0,0,0), + "new Date( 2000,0,1,0,0,0,0)", + [TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date( 2000,0,1,0,0,0,0), - "new Date( 2000,0,1,0,0,0,0)", - [TIME_2000-TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - - addNewTestCase( new Date( 2000,0,1,0,0,0,1), - "new Date( 2000,0,1,0,0,0,1)", - [TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); +addNewTestCase( new Date( 2000,0,1,0,0,0,1), + "new Date( 2000,0,1,0,0,0,1)", + [TIME_2000-TZ_ADJUST+1,2000,0,1,6,8,0,0,1,2000,0,1,6,0,0,0,1] ); /* - // Dates around 29 Feb 2000 +// Dates around 29 Feb 2000 - var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); +var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); - addNewTestCase( new Date(2000,1,28,16,0,0,0), - "new Date(2000,1,28,16,0,0,0)", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date(2000,1,28,16,0,0,0), +"new Date(2000,1,28,16,0,0,0)", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date(2000,1,29,0,0,0,0), - "new Date(2000,1,29,0,0,0,0)", - [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(2000,1,29,0,0,0,0), +"new Date(2000,1,29,0,0,0,0)", +[UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date(2000,1,28,24,0,0,0), - "new Date(2000,1,28,24,0,0,0)", - [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(2000,1,28,24,0,0,0), +"new Date(2000,1,28,24,0,0,0)", +[UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - // Dates around 1900 +// Dates around 1900 - addNewTestCase( new Date(1899,11,31,16,0,0,0), - "new Date(1899,11,31,16,0,0,0)", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date(1899,11,31,16,0,0,0), +"new Date(1899,11,31,16,0,0,0)", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(1899,11,31,15,59,59,999), - "new Date(1899,11,31,15,59,59,999)", - [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); +addNewTestCase( new Date(1899,11,31,15,59,59,999), +"new Date(1899,11,31,15,59,59,999)", +[TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); - addNewTestCase( new Date(1899,11,31,23,59,59,999), - "new Date(1899,11,31,23,59,59,999)", - [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); +addNewTestCase( new Date(1899,11,31,23,59,59,999), +"new Date(1899,11,31,23,59,59,999)", +[TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); - addNewTestCase( new Date(1900,0,1,0,0,0,0), - "new Date(1900,0,1,0,0,0,0)", - [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(1900,0,1,0,0,0,0), +"new Date(1900,0,1,0,0,0,0)", +[TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date(1900,0,1,0,0,0,1), - "new Date(1900,0,1,0,0,0,1)", - [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); +addNewTestCase( new Date(1900,0,1,0,0,0,1), +"new Date(1900,0,1,0,0,0,1)", +[TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); - // Dates around 2005 +// Dates around 2005 - var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); +var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(2005,0,1,0,0,0,0), +"new Date(2005,0,1,0,0,0,0)", +[UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), +"new Date(2004,11,31,16,0,0,0)", +[UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings test case + // Daylight Savings test case - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - var item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); -} - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.3.1-3.js b/mozilla/js/tests/ecma/Date/15.9.3.1-3.js index 7b837b24443..02ad9a3927d 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.1-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,191 +35,173 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.9.3.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = TZ_PST * msPerHour; - getTestCases(); - test(); +// Dates around 29 Feb 2000 -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = TZ_PST * msPerHour; +var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); - // Dates around 29 Feb 2000 +addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); +addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date(2000,1,28,16,0,0,0), - "new Date(2000,1,28,16,0,0,0)", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - - addNewTestCase( new Date(2000,1,29,0,0,0,0), - "new Date(2000,1,29,0,0,0,0)", - [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - - addNewTestCase( new Date(2000,1,28,24,0,0,0), - "new Date(2000,1,28,24,0,0,0)", - [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(2000,1,28,24,0,0,0), + "new Date(2000,1,28,24,0,0,0)", + [UTC_FEB_29_2000-TZ_ADJUST,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); /* - // Dates around 1900 +// Dates around 1900 - addNewTestCase( new Date(1899,11,31,16,0,0,0), - "new Date(1899,11,31,16,0,0,0)", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date(1899,11,31,16,0,0,0), +"new Date(1899,11,31,16,0,0,0)", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(1899,11,31,15,59,59,999), - "new Date(1899,11,31,15,59,59,999)", - [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); +addNewTestCase( new Date(1899,11,31,15,59,59,999), +"new Date(1899,11,31,15,59,59,999)", +[TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); - addNewTestCase( new Date(1899,11,31,23,59,59,999), - "new Date(1899,11,31,23,59,59,999)", - [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); +addNewTestCase( new Date(1899,11,31,23,59,59,999), +"new Date(1899,11,31,23,59,59,999)", +[TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); - addNewTestCase( new Date(1900,0,1,0,0,0,0), - "new Date(1900,0,1,0,0,0,0)", - [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(1900,0,1,0,0,0,0), +"new Date(1900,0,1,0,0,0,0)", +[TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date(1900,0,1,0,0,0,1), - "new Date(1900,0,1,0,0,0,1)", - [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); +addNewTestCase( new Date(1900,0,1,0,0,0,1), +"new Date(1900,0,1,0,0,0,1)", +[TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); - // Dates around 2005 +// Dates around 2005 - var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); +var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(2005,0,1,0,0,0,0), +"new Date(2005,0,1,0,0,0,0)", +[UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), +"new Date(2004,11,31,16,0,0,0)", +[UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings test case + // Daylight Savings test case - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - var item = testcases.length; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); -} - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.3.1-4.js b/mozilla/js/tests/ecma/Date/15.9.3.1-4.js index 792dfd94c2c..6bfcce32d62 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.1-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.1-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,175 +35,156 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.9.3.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = TZ_PST * msPerHour; - getTestCases(); - test(); +// Dates around 1900 -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = TZ_PST * msPerHour; +addNewTestCase( new Date(1899,11,31,16,0,0,0), + "new Date(1899,11,31,16,0,0,0)", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - // Dates around 1900 +addNewTestCase( new Date(1899,11,31,15,59,59,999), + "new Date(1899,11,31,15,59,59,999)", + [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); - addNewTestCase( new Date(1899,11,31,16,0,0,0), - "new Date(1899,11,31,16,0,0,0)", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date(1899,11,31,23,59,59,999), + "new Date(1899,11,31,23,59,59,999)", + [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); - addNewTestCase( new Date(1899,11,31,15,59,59,999), - "new Date(1899,11,31,15,59,59,999)", - [TIME_1900-1,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); +addNewTestCase( new Date(1900,0,1,0,0,0,0), + "new Date(1900,0,1,0,0,0,0)", + [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date(1899,11,31,23,59,59,999), - "new Date(1899,11,31,23,59,59,999)", - [TIME_1900-TZ_ADJUST-1,1900,0,1,1,7,59,59,999,1899,11,31,0,23,59,59,999] ); - - addNewTestCase( new Date(1900,0,1,0,0,0,0), - "new Date(1900,0,1,0,0,0,0)", - [TIME_1900-TZ_ADJUST,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - - addNewTestCase( new Date(1900,0,1,0,0,0,1), - "new Date(1900,0,1,0,0,0,1)", - [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); +addNewTestCase( new Date(1900,0,1,0,0,0,1), + "new Date(1900,0,1,0,0,0,1)", + [TIME_1900-TZ_ADJUST+1,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); /* - // Dates around 2005 +// Dates around 2005 - var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); +var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(2005,0,1,0,0,0,0), +"new Date(2005,0,1,0,0,0,0)", +[UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), +"new Date(2004,11,31,16,0,0,0)", +[UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings test case + // Daylight Savings test case - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - var item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); -} - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.3.1-5.js b/mozilla/js/tests/ecma/Date/15.9.3.1-5.js index ce31865e0ca..ddd06390df5 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.1-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.1-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,152 +35,134 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1) is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.9.3.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; +var SECTION = "15.9.3.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Date( year, month, date, hours, minutes, seconds, ms )"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = TZ_PST * msPerHour; - getTestCases(); - test(); +// Dates around 2005 -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = TZ_PST * msPerHour; +var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - // Dates around 2005 +addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - var UTC_YEAR_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [UTC_YEAR_2005-TZ_ADJUST,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_YEAR_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings test case + // Daylight Savings test case - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - var item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; -} diff --git a/mozilla/js/tests/ecma/Date/15.9.3.2-1.js b/mozilla/js/tests/ecma/Date/15.9.3.2-1.js index 2898b89a8b3..8145eef0928 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.2-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,223 +35,203 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var SECTION = "15.9.3.1"; - var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; - writeHeaderToLog( SECTION+" " +TITLE ); +writeHeaderToLog( SECTION+" " +TITLE ); - var testcases = new Array(); - getTestCases(); +// Dates around 1970 -// all tests must call a function that returns an array of TestCase object - test(); +addNewTestCase( new Date( 1969,11,31,15,59,59), + "new Date( 1969,11,31,15,59,59)", + [-1000,1969,11,31,3,23,59,59,0,1969,11,31,3,15,59,59,0] ); -function getTestCases( ) { +addNewTestCase( new Date( 1969,11,31,16,0,0), + "new Date( 1969,11,31,16,0,0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - // Dates around 1970 +addNewTestCase( new Date( 1969,11,31,23,59,59), + "new Date( 1969,11,31,23,59,59)", + [28799000,1970,0,1,4,7,59,59,0,1969,11,31,3,23,59,59,0] ); - addNewTestCase( new Date( 1969,11,31,15,59,59), - "new Date( 1969,11,31,15,59,59)", - [-1000,1969,11,31,3,23,59,59,0,1969,11,31,3,15,59,59,0] ); +addNewTestCase( new Date( 1970, 0, 1, 0, 0, 0), + "new Date( 1970, 0, 1, 0, 0, 0)", + [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date( 1969,11,31,16,0,0), - "new Date( 1969,11,31,16,0,0)", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - - addNewTestCase( new Date( 1969,11,31,23,59,59), - "new Date( 1969,11,31,23,59,59)", - [28799000,1970,0,1,4,7,59,59,0,1969,11,31,3,23,59,59,0] ); - - addNewTestCase( new Date( 1970, 0, 1, 0, 0, 0), - "new Date( 1970, 0, 1, 0, 0, 0)", - [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - - addNewTestCase( new Date( 1969,11,31,16,0,0), - "new Date( 1969,11,31,16,0,0)", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +addNewTestCase( new Date( 1969,11,31,16,0,0), + "new Date( 1969,11,31,16,0,0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); /* - // Dates around 2000 +// Dates around 2000 - addNewTestCase( new Date( 1999,11,31,15,59,59), - "new Date( 1999,11,31,15,59,59)", - [946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); +addNewTestCase( new Date( 1999,11,31,15,59,59), +"new Date( 1999,11,31,15,59,59)", +[946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); - addNewTestCase( new Date( 1999,11,31,16,0,0), - "new Date( 1999,11,31,16,0,0)", - [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); +addNewTestCase( new Date( 1999,11,31,16,0,0), +"new Date( 1999,11,31,16,0,0)", +[946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); - addNewTestCase( new Date( 2000,0,1,0,0,0), - "new Date( 2000,0,1,0,0,0)", - [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date( 2000,0,1,0,0,0), +"new Date( 2000,0,1,0,0,0)", +[946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - // Dates around 1900 +// Dates around 1900 - addNewTestCase( new Date(1899,11,31,16,0,0), - "new Date(1899,11,31,16,0,0)", - [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date(1899,11,31,16,0,0), +"new Date(1899,11,31,16,0,0)", +[-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(1899,11,31,15,59,59), - "new Date(1899,11,31,15,59,59)", - [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); +addNewTestCase( new Date(1899,11,31,15,59,59), +"new Date(1899,11,31,15,59,59)", +[-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); - addNewTestCase( new Date(1900,0,1,0,0,0), - "new Date(1900,0,1,0,0,0)", - [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(1900,0,1,0,0,0), +"new Date(1900,0,1,0,0,0)", +[-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date(1900,0,1,0,0,1), - "new Date(1900,0,1,0,0,1)", - [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); +addNewTestCase( new Date(1900,0,1,0,0,1), +"new Date(1900,0,1,0,0,1)", +[-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); - var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; +var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; +var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; - // Dates around Feb 29, 2000 - addNewTestCase( new Date(2000,1,28,16,0,0,0), - "new Date(2000,1,28,16,0,0,0)", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); +// Dates around Feb 29, 2000 +addNewTestCase( new Date(2000,1,28,16,0,0,0), +"new Date(2000,1,28,16,0,0,0)", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); - addNewTestCase( new Date(2000,1,29,0,0,0,0), - "new Date(2000,1,29,0,0,0,0)", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(2000,1,29,0,0,0,0), +"new Date(2000,1,29,0,0,0,0)", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date(2000,1,29,24,0,0,0), - "new Date(2000,1,29,24,0,0,0)", - [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); +addNewTestCase( new Date(2000,1,29,24,0,0,0), +"new Date(2000,1,29,24,0,0,0)", +[PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); - // Dates around Jan 1, 2005 +// Dates around Jan 1, 2005 - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); - var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); +var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(2005,0,1,0,0,0,0), +"new Date(2005,0,1,0,0,0,0)", +[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), +"new Date(2004,11,31,16,0,0,0)", +[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings Time + // Daylight Savings Time - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - item = testcases.length; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } - -function test() { - for( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; -} - diff --git a/mozilla/js/tests/ecma/Date/15.9.3.2-2.js b/mozilla/js/tests/ecma/Date/15.9.3.2-2.js index d3886af7f44..65eab591836 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.2-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,201 +35,180 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var SECTION = "15.9.3.1"; - var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; - writeHeaderToLog( SECTION+" " +TITLE ); +writeHeaderToLog( SECTION+" " +TITLE ); - var testcases = new Array(); - getTestCases(); +// Dates around 2000 -// all tests must call a function that returns an array of TestCase object - test(); +addNewTestCase( new Date( 1999,11,31,15,59,59), + "new Date( 1999,11,31,15,59,59)", + [946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); -function getTestCases( ) { +addNewTestCase( new Date( 1999,11,31,16,0,0), + "new Date( 1999,11,31,16,0,0)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); - // Dates around 2000 - - addNewTestCase( new Date( 1999,11,31,15,59,59), - "new Date( 1999,11,31,15,59,59)", - [946684799000,1999,11,31,5,23,59,59,0,1999,11,31,5,15,59,59,0] ); - - addNewTestCase( new Date( 1999,11,31,16,0,0), - "new Date( 1999,11,31,16,0,0)", - [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); - - addNewTestCase( new Date( 2000,0,1,0,0,0), - "new Date( 2000,0,1,0,0,0)", - [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date( 2000,0,1,0,0,0), + "new Date( 2000,0,1,0,0,0)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); /* - // Dates around 1900 +// Dates around 1900 - addNewTestCase( new Date(1899,11,31,16,0,0), - "new Date(1899,11,31,16,0,0)", - [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date(1899,11,31,16,0,0), +"new Date(1899,11,31,16,0,0)", +[-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(1899,11,31,15,59,59), - "new Date(1899,11,31,15,59,59)", - [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); +addNewTestCase( new Date(1899,11,31,15,59,59), +"new Date(1899,11,31,15,59,59)", +[-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); - addNewTestCase( new Date(1900,0,1,0,0,0), - "new Date(1900,0,1,0,0,0)", - [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(1900,0,1,0,0,0), +"new Date(1900,0,1,0,0,0)", +[-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date(1900,0,1,0,0,1), - "new Date(1900,0,1,0,0,1)", - [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); +addNewTestCase( new Date(1900,0,1,0,0,1), +"new Date(1900,0,1,0,0,1)", +[-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); - var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; +var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; +var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; - // Dates around Feb 29, 2000 - addNewTestCase( new Date(2000,1,28,16,0,0,0), - "new Date(2000,1,28,16,0,0,0)", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); +// Dates around Feb 29, 2000 +addNewTestCase( new Date(2000,1,28,16,0,0,0), +"new Date(2000,1,28,16,0,0,0)", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); - addNewTestCase( new Date(2000,1,29,0,0,0,0), - "new Date(2000,1,29,0,0,0,0)", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(2000,1,29,0,0,0,0), +"new Date(2000,1,29,0,0,0,0)", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date(2000,1,29,24,0,0,0), - "new Date(2000,1,29,24,0,0,0)", - [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); +addNewTestCase( new Date(2000,1,29,24,0,0,0), +"new Date(2000,1,29,24,0,0,0)", +[PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); - // Dates around Jan 1, 2005 +// Dates around Jan 1, 2005 - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); - var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); +var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(2005,0,1,0,0,0,0), +"new Date(2005,0,1,0,0,0,0)", +[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), +"new Date(2004,11,31,16,0,0,0)", +[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings Time + // Daylight Savings Time - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } - -function test() { - for( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; -} - diff --git a/mozilla/js/tests/ecma/Date/15.9.3.2-3.js b/mozilla/js/tests/ecma/Date/15.9.3.2-3.js index 53a343fdff0..5e48617702c 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.2-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.2-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,187 +35,166 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var SECTION = "15.9.3.1"; - var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; - writeHeaderToLog( SECTION+" " +TITLE ); +writeHeaderToLog( SECTION+" " +TITLE ); - var testcases = new Array(); - getTestCases(); +// Dates around 1900 -// all tests must call a function that returns an array of TestCase object - test(); +addNewTestCase( new Date(1899,11,31,16,0,0), + "new Date(1899,11,31,16,0,0)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); -function getTestCases( ) { +addNewTestCase( new Date(1899,11,31,15,59,59), + "new Date(1899,11,31,15,59,59)", + [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); - // Dates around 1900 +addNewTestCase( new Date(1900,0,1,0,0,0), + "new Date(1900,0,1,0,0,0)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date(1899,11,31,16,0,0), - "new Date(1899,11,31,16,0,0)", - [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - - addNewTestCase( new Date(1899,11,31,15,59,59), - "new Date(1899,11,31,15,59,59)", - [-2208988801000,1899,11,31,0,23,59,59,0,1899,11,31,0,15,59,59,0] ); - - addNewTestCase( new Date(1900,0,1,0,0,0), - "new Date(1900,0,1,0,0,0)", - [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - - addNewTestCase( new Date(1900,0,1,0,0,1), - "new Date(1900,0,1,0,0,1)", - [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); +addNewTestCase( new Date(1900,0,1,0,0,1), + "new Date(1900,0,1,0,0,1)", + [-2208959999000,1900,0,1,1,8,0,1,0,1900,0,1,1,0,0,1,0] ); /* - var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; + var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; + var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; - // Dates around Feb 29, 2000 - addNewTestCase( new Date(2000,1,28,16,0,0,0), - "new Date(2000,1,28,16,0,0,0)", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); + // Dates around Feb 29, 2000 + addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); - addNewTestCase( new Date(2000,1,29,0,0,0,0), - "new Date(2000,1,29,0,0,0,0)", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); + addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date(2000,1,29,24,0,0,0), - "new Date(2000,1,29,24,0,0,0)", - [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); + addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); - // Dates around Jan 1, 2005 + // Dates around Jan 1, 2005 - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); - var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; + var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + + TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); + var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); + addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); + addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings Time + // Daylight Savings Time - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } - -function test() { - for( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; -} - diff --git a/mozilla/js/tests/ecma/Date/15.9.3.2-4.js b/mozilla/js/tests/ecma/Date/15.9.3.2-4.js index 57641b25f42..84deba3f40d 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.2-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.2-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,170 +35,148 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var SECTION = "15.9.3.1"; - var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; - writeHeaderToLog( SECTION+" " +TITLE ); +writeHeaderToLog( SECTION+" " +TITLE ); - var testcases = new Array(); - getTestCases(); +var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; +var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; -// all tests must call a function that returns an array of TestCase object - test(); +// Dates around Feb 29, 2000 +addNewTestCase( new Date(2000,1,28,16,0,0,0), + "new Date(2000,1,28,16,0,0,0)", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); -function getTestCases( ) { +addNewTestCase( new Date(2000,1,29,0,0,0,0), + "new Date(2000,1,29,0,0,0,0)", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - - var UTC_FEB_29_2000 = TIME_2000 + msPerDay*31 + msPerDay*28; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; - - // Dates around Feb 29, 2000 - addNewTestCase( new Date(2000,1,28,16,0,0,0), - "new Date(2000,1,28,16,0,0,0)", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0,0] ); - - addNewTestCase( new Date(2000,1,29,0,0,0,0), - "new Date(2000,1,29,0,0,0,0)", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - - addNewTestCase( new Date(2000,1,29,24,0,0,0), - "new Date(2000,1,29,24,0,0,0)", - [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); +addNewTestCase( new Date(2000,1,29,24,0,0,0), + "new Date(2000,1,29,24,0,0,0)", + [PST_FEB_29_2000+msPerDay,2000,2,1,3,8,0,0,0,2000,2,1,3,0,0,0,0] ); /* - // Dates around Jan 1, 2005 +// Dates around Jan 1, 2005 - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); - var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); +var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(2005,0,1,0,0,0,0), +"new Date(2005,0,1,0,0,0,0)", +[PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), +"new Date(2004,11,31,16,0,0,0)", +[UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings Time + // Daylight Savings Time - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } - -function test() { - for( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; -} - diff --git a/mozilla/js/tests/ecma/Date/15.9.3.2-5.js b/mozilla/js/tests/ecma/Date/15.9.3.2-5.js index 53b07d059da..97aa761a1c6 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.2-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.2-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,152 +35,131 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.1.js - ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial value of Date.prototype. + File Name: 15.9.3.1.js + ECMA Section: 15.9.3.1 new Date (year, month, date, hours, minutes, seconds, ms) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial value of Date.prototype. - The [[Class]] property of the newly constructed object - is set as follows: - 1. Call ToNumber(year) - 2. Call ToNumber(month) - 3. Call ToNumber(date) - 4. Call ToNumber(hours) - 5. Call ToNumber(minutes) - 6. Call ToNumber(seconds) - 7. Call ToNumber(ms) - 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= - 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, - Result(8) is Result(1) - 9. Compute MakeDay(Result(8), Result(2), Result(3) - 10. Compute MakeTime(Result(4), Result(5), Result(6), - Result(7) - 11. Compute MakeDate(Result(9), Result(10)) - 12. Set the [[Value]] property of the newly constructed - object to TimeClip(UTC(Result(11))). + The [[Class]] property of the newly constructed object + is set as follows: + 1. Call ToNumber(year) + 2. Call ToNumber(month) + 3. Call ToNumber(date) + 4. Call ToNumber(hours) + 5. Call ToNumber(minutes) + 6. Call ToNumber(seconds) + 7. Call ToNumber(ms) + 8. If Result(1)is NaN and 0 <= ToInteger(Result(1)) <= + 99, Result(8) is 1900+ToInteger(Result(1)); otherwise, + Result(8) is Result(1) + 9. Compute MakeDay(Result(8), Result(2), Result(3) + 10. Compute MakeTime(Result(4), Result(5), Result(6), + Result(7) + 11. Compute MakeDate(Result(9), Result(10)) + 12. Set the [[Value]] property of the newly constructed + object to TimeClip(UTC(Result(11))). - This tests the returned value of a newly constructed - Date object. + This tests the returned value of a newly constructed + Date object. - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var SECTION = "15.9.3.1"; - var TITLE = "Date( year, month, date, hours, minutes, seconds )"; +var SECTION = "15.9.3.1"; +var TITLE = "Date( year, month, date, hours, minutes, seconds )"; - writeHeaderToLog( SECTION+" " +TITLE ); +writeHeaderToLog( SECTION+" " +TITLE ); - var testcases = new Array(); - getTestCases(); +// Dates around Jan 1, 2005 -// all tests must call a function that returns an array of TestCase object - test(); +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); +var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; -function getTestCases( ) { +addNewTestCase( new Date(2005,0,1,0,0,0,0), + "new Date(2005,0,1,0,0,0,0)", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - // Dates around Jan 1, 2005 - - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002)+ TimeInYear(2003) + TimeInYear(2004); - var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; - - addNewTestCase( new Date(2005,0,1,0,0,0,0), - "new Date(2005,0,1,0,0,0,0)", - [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - - addNewTestCase( new Date(2004,11,31,16,0,0,0), - "new Date(2004,11,31,16,0,0,0)", - [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(2004,11,31,16,0,0,0), + "new Date(2004,11,31,16,0,0,0)", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - // Daylight Savings Time + // Daylight Savings Time - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(1998,3,5,1,59,59,999), - "new Date(1998,3,5,1,59,59,999)", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(1998,3,5,1,59,59,999), + "new Date(1998,3,5,1,59,59,999)", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(1998,3,5,2,0,0,0), - "new Date(1998,3,5,2,0,0,0)", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(1998,3,5,2,0,0,0), + "new Date(1998,3,5,2,0,0,0)", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(1998,9,25,1,59,59,999), - "new Date(1998,9,25,1,59,59,999)", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(1998,9,25,1,59,59,999), + "new Date(1998,9,25,1,59,59,999)", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(1998,9,25,2,0,0,0), - "new Date(1998,9,25,2,0,0,0)", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(1998,9,25,2,0,0,0), + "new Date(1998,9,25,2,0,0,0)", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray); +//adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray); - item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } - -function test() { - for( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - return testcases; -} - diff --git a/mozilla/js/tests/ecma/Date/15.9.3.8-1.js b/mozilla/js/tests/ecma/Date/15.9.3.8-1.js index 2ef5004e3af..2ae570518aa 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.8-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.8-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,281 +36,259 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.9.3.8.js - ECMA Section: 15.9.3.8 The Date Constructor - new Date( value ) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial valiue of Date.prototype. + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. - The [[Class]] property of the newly constructed object is - set to "Date". + The [[Class]] property of the newly constructed object is + set to "Date". - The [[Value]] property of the newly constructed object is - set as follows: + The [[Value]] property of the newly constructed object is + set as follows: - 1. Call ToPrimitive(value) - 2. If Type( Result(1) ) is String, then go to step 5. - 3. Let V be ToNumber( Result(1) ). - 4. Set the [[Value]] property of the newly constructed - object to TimeClip(V) and return. - 5. Parse Result(1) as a date, in exactly the same manner - as for the parse method. Let V be the time value for - this date. - 6. Go to step 4. + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "15.9.3.8"; - var TYPEOF = "object"; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var tc= 0; - var TITLE = "Date constructor: new Date( value )"; - var SECTION = "15.9.3.8"; - var VERSION = "ECMA_1"; - startTest(); +var tc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION +" " + TITLE ); +writeHeaderToLog( SECTION +" " + TITLE ); - testcases = new Array(); - getTestCases(); - -// all tests must call a function that returns a boolean value - test(); - -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = -TZ_PST * msPerHour; +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; - // Dates around 1970 - addNewTestCase( new Date(0), - "new Date(0)", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +// Dates around 1970 +addNewTestCase( new Date(0), + "new Date(0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - addNewTestCase( new Date(1), - "new Date(1)", - [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); +addNewTestCase( new Date(1), + "new Date(1)", + [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); - addNewTestCase( new Date(true), - "new Date(true)", - [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); +addNewTestCase( new Date(true), + "new Date(true)", + [1,1970,0,1,4,0,0,0,1,1969,11,31,3,16,0,0,1] ); - addNewTestCase( new Date(false), - "new Date(false)", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +addNewTestCase( new Date(false), + "new Date(false)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - addNewTestCase( new Date( (new Date(0)).toString() ), - "new Date(\""+ (new Date(0)).toString()+"\" )", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +addNewTestCase( new Date( (new Date(0)).toString() ), + "new Date(\""+ (new Date(0)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); /* // addNewTestCase( "new Date(\""+ (new Date(0)).toLocaleString()+"\")", [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - addNewTestCase( new Date((new Date(0)).toUTCString()), - "new Date(\""+ (new Date(0)).toUTCString()+"\" )", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +addNewTestCase( new Date((new Date(0)).toUTCString()), +"new Date(\""+ (new Date(0)).toUTCString()+"\" )", +[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - addNewTestCase( new Date((new Date(1)).toString()), - "new Date(\""+ (new Date(1)).toString()+"\" )", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +addNewTestCase( new Date((new Date(1)).toString()), +"new Date(\""+ (new Date(1)).toString()+"\" )", +[0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - addNewTestCase( new Date( TZ_ADJUST ), - "new Date(" + TZ_ADJUST+")", - [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date( TZ_ADJUST ), +"new Date(" + TZ_ADJUST+")", +[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), - "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", - [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), +"new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", +[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); // addNewTestCase( "new Date(\""+ (new Date(TZ_ADJUST)).toLocaleString()+"\")",[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), - "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", - [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), +"new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", +[TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - // Dates around 2000 +// Dates around 2000 - addNewTestCase( new Date(TIME_2000+TZ_ADJUST), - "new Date(" +(TIME_2000+TZ_ADJUST)+")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(TIME_2000+TZ_ADJUST), +"new Date(" +(TIME_2000+TZ_ADJUST)+")", +[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(TIME_2000), - "new Date(" +TIME_2000+")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(TIME_2000), +"new Date(" +TIME_2000+")", +[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), - "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), +"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", +[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date((new Date(TIME_2000)).toString()), - "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date((new Date(TIME_2000)).toString()), +"new Date(\"" +(new Date(TIME_2000)).toString()+"\")", +[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); // addNewTestCase( "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toLocaleString()+"\")", [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); // addNewTestCase( "new Date(\"" +(new Date(TIME_2000)).toLocaleString()+"\")", [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), - "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), +"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", +[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), - "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), +"new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", +[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - // Dates around Feb 29, 2000 +// Dates around Feb 29, 2000 - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; - addNewTestCase( new Date(UTC_FEB_29_2000), - "new Date("+UTC_FEB_29_2000+")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date(UTC_FEB_29_2000), +"new Date("+UTC_FEB_29_2000+")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date(PST_FEB_29_2000), - "new Date("+PST_FEB_29_2000+")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(PST_FEB_29_2000), +"new Date("+PST_FEB_29_2000+")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), - "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), +"new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), - "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), +"new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); // Parsing toLocaleString() is not guaranteed by ECMA. // addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), - "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), +"new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), - "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), +"new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - // Dates around 1900 +// Dates around 1900 - var PST_1900 = TIME_1900 + 8*msPerHour; +var PST_1900 = TIME_1900 + 8*msPerHour; - addNewTestCase( new Date( TIME_1900 ), - "new Date("+TIME_1900+")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( TIME_1900 ), +"new Date("+TIME_1900+")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(PST_1900), - "new Date("+PST_1900+")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(PST_1900), +"new Date("+PST_1900+")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), - "new Date(\""+(new Date(TIME_1900)).toString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), +"new Date(\""+(new Date(TIME_1900)).toString()+"\")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toString() ), - "new Date(\""+(new Date(PST_1900 )).toString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toString() ), +"new Date(\""+(new Date(PST_1900 )).toString()+"\")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), - "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), +"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), - "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), +"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(DST_START_1998-1), - "new Date("+(DST_START_1998-1)+")", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(DST_START_1998), - "new Date("+DST_START_1998+")", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(DST_END_1998-1), - "new Date("+(DST_END_1998-1)+")", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(DST_END_1998), - "new Date("+DST_END_1998+")", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray, 'msMode'); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); - item = testcases.length; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); -} - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - - // all tests must return a boolean value - return ( testcases ); + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.3.8-2.js b/mozilla/js/tests/ecma/Date/15.9.3.8-2.js index 5407e1e1fbc..454060e625f 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.8-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.8-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,256 +36,233 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.9.3.8.js - ECMA Section: 15.9.3.8 The Date Constructor - new Date( value ) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial valiue of Date.prototype. + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. - The [[Class]] property of the newly constructed object is - set to "Date". + The [[Class]] property of the newly constructed object is + set to "Date". - The [[Value]] property of the newly constructed object is - set as follows: + The [[Value]] property of the newly constructed object is + set as follows: - 1. Call ToPrimitive(value) - 2. If Type( Result(1) ) is String, then go to step 5. - 3. Let V be ToNumber( Result(1) ). - 4. Set the [[Value]] property of the newly constructed - object to TimeClip(V) and return. - 5. Parse Result(1) as a date, in exactly the same manner - as for the parse method. Let V be the time value for - this date. - 6. Go to step 4. + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "15.9.3.8"; - var TYPEOF = "object"; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var tc= 0; - var TITLE = "Date constructor: new Date( value )"; - var SECTION = "15.9.3.8"; - var VERSION = "ECMA_1"; - startTest(); +var tc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION +" " + TITLE ); +writeHeaderToLog( SECTION +" " + TITLE ); - testcases = new Array(); - getTestCases(); +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; -// all tests must call a function that returns a boolean value - test(); +addNewTestCase( new Date((new Date(0)).toUTCString()), + "new Date(\""+ (new Date(0)).toUTCString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = -TZ_PST * msPerHour; +addNewTestCase( new Date((new Date(1)).toString()), + "new Date(\""+ (new Date(1)).toString()+"\" )", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - addNewTestCase( new Date((new Date(0)).toUTCString()), - "new Date(\""+ (new Date(0)).toUTCString()+"\" )", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +addNewTestCase( new Date( TZ_ADJUST ), + "new Date(" + TZ_ADJUST+")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date((new Date(1)).toString()), - "new Date(\""+ (new Date(1)).toString()+"\" )", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - - addNewTestCase( new Date( TZ_ADJUST ), - "new Date(" + TZ_ADJUST+")", - [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - - addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), - "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", - [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date((new Date(TZ_ADJUST)).toString()), + "new Date(\""+ (new Date(TZ_ADJUST)).toString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), - "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", - [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date( (new Date(TZ_ADJUST)).toUTCString() ), + "new Date(\""+ (new Date(TZ_ADJUST)).toUTCString()+"\")", + [TZ_ADJUST,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); /* - // Dates around 2000 +// Dates around 2000 - addNewTestCase( new Date(TIME_2000+TZ_ADJUST), - "new Date(" +(TIME_2000+TZ_ADJUST)+")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(TIME_2000+TZ_ADJUST), +"new Date(" +(TIME_2000+TZ_ADJUST)+")", +[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(TIME_2000), - "new Date(" +TIME_2000+")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(TIME_2000), +"new Date(" +TIME_2000+")", +[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), - "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), +"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", +[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date((new Date(TIME_2000)).toString()), - "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date((new Date(TIME_2000)).toString()), +"new Date(\"" +(new Date(TIME_2000)).toString()+"\")", +[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); // addNewTestCase( "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toLocaleString()+"\")", [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); // addNewTestCase( "new Date(\"" +(new Date(TIME_2000)).toLocaleString()+"\")", [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), - "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), +"new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", +[TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), - "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), +"new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", +[TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - // Dates around Feb 29, 2000 +// Dates around Feb 29, 2000 - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; - addNewTestCase( new Date(UTC_FEB_29_2000), - "new Date("+UTC_FEB_29_2000+")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date(UTC_FEB_29_2000), +"new Date("+UTC_FEB_29_2000+")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date(PST_FEB_29_2000), - "new Date("+PST_FEB_29_2000+")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(PST_FEB_29_2000), +"new Date("+PST_FEB_29_2000+")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), - "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), +"new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), - "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), +"new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); // Parsing toLocaleString() is not guaranteed by ECMA. // addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), - "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), +"new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), - "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), +"new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - // Dates around 1900 +// Dates around 1900 - var PST_1900 = TIME_1900 + 8*msPerHour; +var PST_1900 = TIME_1900 + 8*msPerHour; - addNewTestCase( new Date( TIME_1900 ), - "new Date("+TIME_1900+")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( TIME_1900 ), +"new Date("+TIME_1900+")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(PST_1900), - "new Date("+PST_1900+")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(PST_1900), +"new Date("+PST_1900+")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), - "new Date(\""+(new Date(TIME_1900)).toString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), +"new Date(\""+(new Date(TIME_1900)).toString()+"\")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toString() ), - "new Date(\""+(new Date(PST_1900 )).toString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toString() ), +"new Date(\""+(new Date(PST_1900 )).toString()+"\")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), - "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), +"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), - "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), +"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(DST_START_1998-1), - "new Date("+(DST_START_1998-1)+")", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(DST_START_1998), - "new Date("+DST_START_1998+")", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(DST_END_1998-1), - "new Date("+(DST_END_1998-1)+")", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(DST_END_1998), - "new Date("+DST_END_1998+")", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray, 'msMode'); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); - item = testcases.length; - - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); -} - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - - // all tests must return a boolean value - return ( testcases ); + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.3.8-3.js b/mozilla/js/tests/ecma/Date/15.9.3.8-3.js index 8d453ab9128..05b513c76a6 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.8-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.8-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,235 +35,213 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.8.js - ECMA Section: 15.9.3.8 The Date Constructor - new Date( value ) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial valiue of Date.prototype. + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. - The [[Class]] property of the newly constructed object is - set to "Date". + The [[Class]] property of the newly constructed object is + set to "Date". - The [[Value]] property of the newly constructed object is - set as follows: + The [[Value]] property of the newly constructed object is + set as follows: - 1. Call ToPrimitive(value) - 2. If Type( Result(1) ) is String, then go to step 5. - 3. Let V be ToNumber( Result(1) ). - 4. Set the [[Value]] property of the newly constructed - object to TimeClip(V) and return. - 5. Parse Result(1) as a date, in exactly the same manner - as for the parse method. Let V be the time value for - this date. - 6. Go to step 4. + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "15.9.3.8"; - var TYPEOF = "object"; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var tc= 0; - var TITLE = "Date constructor: new Date( value )"; - var SECTION = "15.9.3.8"; - var VERSION = "ECMA_1"; - startTest(); +var tc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION +" " + TITLE ); +writeHeaderToLog( SECTION +" " + TITLE ); - testcases = new Array(); - getTestCases(); - -// all tests must call a function that returns a boolean value - test(); - -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = -TZ_PST * msPerHour; +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; - // Dates around 2000 +// Dates around 2000 - addNewTestCase( new Date(TIME_2000+TZ_ADJUST), - "new Date(" +(TIME_2000+TZ_ADJUST)+")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(TIME_2000+TZ_ADJUST), + "new Date(" +(TIME_2000+TZ_ADJUST)+")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date(TIME_2000), - "new Date(" +TIME_2000+")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(TIME_2000), + "new Date(" +TIME_2000+")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), - "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date((new Date(TIME_2000)).toString()), - "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date((new Date(TIME_2000)).toString()), + "new Date(\"" +(new Date(TIME_2000)).toString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), - "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", - [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000+TZ_ADJUST)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000+TZ_ADJUST)).toUTCString()+"\")", + [TIME_2000+TZ_ADJUST,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), - "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", - [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_2000)).toUTCString()), + "new Date(\"" +(new Date(TIME_2000)).toUTCString()+"\")", + [TIME_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); /* - // Dates around Feb 29, 2000 +// Dates around Feb 29, 2000 - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; - addNewTestCase( new Date(UTC_FEB_29_2000), - "new Date("+UTC_FEB_29_2000+")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date(UTC_FEB_29_2000), +"new Date("+UTC_FEB_29_2000+")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date(PST_FEB_29_2000), - "new Date("+PST_FEB_29_2000+")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date(PST_FEB_29_2000), +"new Date("+PST_FEB_29_2000+")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), - "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), +"new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), - "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), +"new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); // Parsing toLocaleString() is not guaranteed by ECMA. // addNewTestCase( "new Date(\""+(new Date(UTC_FEB_29_2000)).toLocaleString()+"\")", [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(PST_FEB_29_2000)).toLocaleString()+"\")", [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), - "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), +"new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", +[UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), - "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), +"new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", +[PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - // Dates around 1900 +// Dates around 1900 - var PST_1900 = TIME_1900 + 8*msPerHour; +var PST_1900 = TIME_1900 + 8*msPerHour; - addNewTestCase( new Date( TIME_1900 ), - "new Date("+TIME_1900+")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( TIME_1900 ), +"new Date("+TIME_1900+")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(PST_1900), - "new Date("+PST_1900+")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(PST_1900), +"new Date("+PST_1900+")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), - "new Date(\""+(new Date(TIME_1900)).toString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), +"new Date(\""+(new Date(TIME_1900)).toString()+"\")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toString() ), - "new Date(\""+(new Date(PST_1900 )).toString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toString() ), +"new Date(\""+(new Date(PST_1900 )).toString()+"\")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), - "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), +"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), - "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), +"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(DST_START_1998-1), - "new Date("+(DST_START_1998-1)+")", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(DST_START_1998), - "new Date("+DST_START_1998+")", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(DST_END_1998-1), - "new Date("+(DST_END_1998-1)+")", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(DST_END_1998), - "new Date("+DST_END_1998+")", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray, 'msMode'); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); - item = testcases.length; - - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); -} - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - - // all tests must return a boolean value - return ( testcases ); + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.3.8-4.js b/mozilla/js/tests/ecma/Date/15.9.3.8-4.js index 8dbca982e97..b2525fc200e 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.8-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.8-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,204 +35,182 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.8.js - ECMA Section: 15.9.3.8 The Date Constructor - new Date( value ) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial valiue of Date.prototype. + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. - The [[Class]] property of the newly constructed object is - set to "Date". + The [[Class]] property of the newly constructed object is + set to "Date". - The [[Value]] property of the newly constructed object is - set as follows: + The [[Value]] property of the newly constructed object is + set as follows: - 1. Call ToPrimitive(value) - 2. If Type( Result(1) ) is String, then go to step 5. - 3. Let V be ToNumber( Result(1) ). - 4. Set the [[Value]] property of the newly constructed - object to TimeClip(V) and return. - 5. Parse Result(1) as a date, in exactly the same manner - as for the parse method. Let V be the time value for - this date. - 6. Go to step 4. + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "15.9.3.8"; - var TYPEOF = "object"; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var tc= 0; - var TITLE = "Date constructor: new Date( value )"; - var SECTION = "15.9.3.8"; - var VERSION = "ECMA_1"; - startTest(); +var tc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION +" " + TITLE ); +writeHeaderToLog( SECTION +" " + TITLE ); - testcases = new Array(); - getTestCases(); +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; -// all tests must call a function that returns a boolean value - test(); +// Dates around Feb 29, 2000 -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = -TZ_PST * msPerHour; +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; - // Dates around Feb 29, 2000 +addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date("+UTC_FEB_29_2000+")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + TZ_ADJUST; +addNewTestCase( new Date(PST_FEB_29_2000), + "new Date("+PST_FEB_29_2000+")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date(UTC_FEB_29_2000), - "new Date("+UTC_FEB_29_2000+")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date(PST_FEB_29_2000), - "new Date("+PST_FEB_29_2000+")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - - addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toString() ), - "new Date(\""+(new Date(UTC_FEB_29_2000)).toString()+"\")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - - addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), - "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); - addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), - "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", - [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); +addNewTestCase( new Date( (new Date(UTC_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(UTC_FEB_29_2000)).toGMTString()+"\")", + [UTC_FEB_29_2000,2000,1,29,2,0,0,0,0,2000,1,28,1,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), - "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", - [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_FEB_29_2000)).toGMTString() ), + "new Date(\""+(new Date(PST_FEB_29_2000)).toGMTString()+"\")", + [PST_FEB_29_2000,2000,1,29,2,8,0,0,0,2000,1,29,2,0,0,0,0] ); /* - // Dates around 1900 +// Dates around 1900 - var PST_1900 = TIME_1900 + 8*msPerHour; +var PST_1900 = TIME_1900 + 8*msPerHour; - addNewTestCase( new Date( TIME_1900 ), - "new Date("+TIME_1900+")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( TIME_1900 ), +"new Date("+TIME_1900+")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(PST_1900), - "new Date("+PST_1900+")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(PST_1900), +"new Date("+PST_1900+")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), - "new Date(\""+(new Date(TIME_1900)).toString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), +"new Date(\""+(new Date(TIME_1900)).toString()+"\")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toString() ), - "new Date(\""+(new Date(PST_1900 )).toString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toString() ), +"new Date(\""+(new Date(PST_1900 )).toString()+"\")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), - "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), +"new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", +[TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), - "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), +"new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", +[ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(TIME_1900)).toLocaleString()+"\")", [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); // addNewTestCase( "new Date(\""+(new Date(PST_1900 )).toLocaleString()+"\")", [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); */ /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(DST_START_1998-1), - "new Date("+(DST_START_1998-1)+")", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(DST_START_1998), - "new Date("+DST_START_1998+")", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(DST_END_1998-1), - "new Date("+(DST_END_1998-1)+")", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(DST_END_1998), - "new Date("+DST_END_1998+")", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray, 'msMode'); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); - item = testcases.length; - - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); -} - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - - // all tests must return a boolean value - return ( testcases ); + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.3.8-5.js b/mozilla/js/tests/ecma/Date/15.9.3.8-5.js index a9c7a93dc56..39aa91c6244 100644 --- a/mozilla/js/tests/ecma/Date/15.9.3.8-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.3.8-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,172 +35,150 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.3.8.js - ECMA Section: 15.9.3.8 The Date Constructor - new Date( value ) - Description: The [[Prototype]] property of the newly constructed - object is set to the original Date prototype object, - the one that is the initial valiue of Date.prototype. + File Name: 15.9.3.8.js + ECMA Section: 15.9.3.8 The Date Constructor + new Date( value ) + Description: The [[Prototype]] property of the newly constructed + object is set to the original Date prototype object, + the one that is the initial valiue of Date.prototype. - The [[Class]] property of the newly constructed object is - set to "Date". + The [[Class]] property of the newly constructed object is + set to "Date". - The [[Value]] property of the newly constructed object is - set as follows: + The [[Value]] property of the newly constructed object is + set as follows: - 1. Call ToPrimitive(value) - 2. If Type( Result(1) ) is String, then go to step 5. - 3. Let V be ToNumber( Result(1) ). - 4. Set the [[Value]] property of the newly constructed - object to TimeClip(V) and return. - 5. Parse Result(1) as a date, in exactly the same manner - as for the parse method. Let V be the time value for - this date. - 6. Go to step 4. + 1. Call ToPrimitive(value) + 2. If Type( Result(1) ) is String, then go to step 5. + 3. Let V be ToNumber( Result(1) ). + 4. Set the [[Value]] property of the newly constructed + object to TimeClip(V) and return. + 5. Parse Result(1) as a date, in exactly the same manner + as for the parse method. Let V be the time value for + this date. + 6. Go to step 4. - Author: christine@netscape.com - Date: 28 october 1997 - Version: 9706 + Author: christine@netscape.com + Date: 28 october 1997 + Version: 9706 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "15.9.3.8"; - var TYPEOF = "object"; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.3.8"; +var TYPEOF = "object"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; // for TCMS, the testcases array must be global. - var tc= 0; - var TITLE = "Date constructor: new Date( value )"; - var SECTION = "15.9.3.8"; - var VERSION = "ECMA_1"; - startTest(); +var tc= 0; +var TITLE = "Date constructor: new Date( value )"; +var SECTION = "15.9.3.8"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION +" " + TITLE ); +writeHeaderToLog( SECTION +" " + TITLE ); - testcases = new Array(); - getTestCases(); - -// all tests must call a function that returns a boolean value - test(); - -function getTestCases( ) { - // all the "ResultArrays" below are hard-coded to Pacific Standard Time values - - var TZ_ADJUST = -TZ_PST * msPerHour; +// all the "ResultArrays" below are hard-coded to Pacific Standard Time values - +var TZ_ADJUST = -TZ_PST * msPerHour; - // Dates around 1900 +// Dates around 1900 - var PST_1900 = TIME_1900 + 8*msPerHour; +var PST_1900 = TIME_1900 + 8*msPerHour; - addNewTestCase( new Date( TIME_1900 ), - "new Date("+TIME_1900+")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( TIME_1900 ), + "new Date("+TIME_1900+")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date(PST_1900), - "new Date("+PST_1900+")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(PST_1900), + "new Date("+PST_1900+")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), - "new Date(\""+(new Date(TIME_1900)).toString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toString() ), + "new Date(\""+(new Date(TIME_1900)).toString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toString() ), - "new Date(\""+(new Date(PST_1900 )).toString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toString() ), + "new Date(\""+(new Date(PST_1900 )).toString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), - "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", - [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date( (new Date(TIME_1900)).toUTCString() ), + "new Date(\""+(new Date(TIME_1900)).toUTCString()+"\")", + [TIME_1900,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), - "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", - [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date( (new Date(PST_1900)).toUTCString() ), + "new Date(\""+(new Date(PST_1900 )).toUTCString()+"\")", + [ PST_1900,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); /* - This test case is incorrect. Need to fix the DaylightSavings functions in - shell.js for this to work properly. + This test case is incorrect. Need to fix the DaylightSavings functions in + shell.js for this to work properly. - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - addNewTestCase( new Date(DST_START_1998-1), - "new Date("+(DST_START_1998-1)+")", - [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); + addNewTestCase( new Date(DST_START_1998-1), + "new Date("+(DST_START_1998-1)+")", + [DST_START_1998-1,1998,3,5,0,9,59,59,999,1998,3,5,0,1,59,59,999] ); - addNewTestCase( new Date(DST_START_1998), - "new Date("+DST_START_1998+")", - [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); + addNewTestCase( new Date(DST_START_1998), + "new Date("+DST_START_1998+")", + [DST_START_1998,1998,3,5,0,10,0,0,0,1998,3,5,0,3,0,0,0]); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - addNewTestCase ( new Date(DST_END_1998-1), - "new Date("+(DST_END_1998-1)+")", - [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); + addNewTestCase ( new Date(DST_END_1998-1), + "new Date("+(DST_END_1998-1)+")", + [DST_END_1998-1,1998,9,25,0,8,59,59,999,1998,9,25,0,1,59,59,999] ); - addNewTestCase ( new Date(DST_END_1998), - "new Date("+DST_END_1998+")", - [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); + addNewTestCase ( new Date(DST_END_1998), + "new Date("+DST_END_1998+")", + [DST_END_1998,1998,9,25,0,9,0,0,0,1998,9,25,0,1,0,0,0] ); */ -} + +test(); function addNewTestCase( DateCase, DateString, ResultArray ) { - //adjust hard-coded ResultArray for tester's timezone instead of PST - adjustResultArray(ResultArray, 'msMode'); + //adjust hard-coded ResultArray for tester's timezone instead of PST + adjustResultArray(ResultArray, 'msMode'); - item = testcases.length; - - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); -} - -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - - // all tests must return a boolean value - return ( testcases ); + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", ResultArray[UTC_HOURS], DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", ResultArray[UTC_MINUTES],DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.4.2-1.js b/mozilla/js/tests/ecma/Date/15.9.4.2-1.js index 96623f91f3b..98b62780e5e 100644 --- a/mozilla/js/tests/ecma/Date/15.9.4.2-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.4.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -50,29 +51,29 @@ * Author: christine@netscape.com */ - var SECTION = "15.9.4.2-1"; // provide a document reference (ie, ECMA section) - var VERSION = "ECMA"; // Version of JavaScript or ECMA - var TITLE = "Regression Test for Date.parse"; // Provide ECMA section title or a description - var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=4088"; // Provide URL to bugsplat or bugzilla report +var SECTION = "15.9.4.2-1"; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA"; // Version of JavaScript or ECMA +var TITLE = "Regression Test for Date.parse"; // Provide ECMA section title or a description +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=4088"; // Provide URL to bugsplat or bugzilla report - startTest(); // leave this alone +startTest(); // leave this alone - AddTestCase( "new Date('1/1/1999 12:30 AM').toString()", - new Date(1999,0,1,0,30).toString(), - new Date('1/1/1999 12:30 AM').toString() ); +AddTestCase( "new Date('1/1/1999 12:30 AM').toString()", + new Date(1999,0,1,0,30).toString(), + new Date('1/1/1999 12:30 AM').toString() ); - AddTestCase( "new Date('1/1/1999 12:30 PM').toString()", - new Date( 1999,0,1,12,30 ).toString(), - new Date('1/1/1999 12:30 PM').toString() ); +AddTestCase( "new Date('1/1/1999 12:30 PM').toString()", + new Date( 1999,0,1,12,30 ).toString(), + new Date('1/1/1999 12:30 PM').toString() ); - AddTestCase( "new Date('1/1/1999 13:30 AM')", - "Invalid Date", - new Date('1/1/1999 13:30 AM').toString() ); +AddTestCase( "new Date('1/1/1999 13:30 AM')", + "Invalid Date", + new Date('1/1/1999 13:30 AM').toString() ); - AddTestCase( "new Date('1/1/1999 13:30 PM')", - "Invalid Date", - new Date('1/1/1999 13:30 PM').toString() ); +AddTestCase( "new Date('1/1/1999 13:30 PM')", + "Invalid Date", + new Date('1/1/1999 13:30 PM').toString() ); - test(); // leave this alone. this executes the test cases and - // displays results. +test(); // leave this alone. this executes the test cases and +// displays results. diff --git a/mozilla/js/tests/ecma/Date/15.9.4.2.js b/mozilla/js/tests/ecma/Date/15.9.4.2.js index c2d2783987a..c45a066b3a3 100644 --- a/mozilla/js/tests/ecma/Date/15.9.4.2.js +++ b/mozilla/js/tests/ecma/Date/15.9.4.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,195 +35,175 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.4.2.js - ECMA Section: 15.9.4.2 Date.parse() - Description: The parse() function applies the to ToString() operator - to its argument and interprets the resulting string as - a date. It returns a number, the UTC time value - corresponding to the date. + File Name: 15.9.4.2.js + ECMA Section: 15.9.4.2 Date.parse() + Description: The parse() function applies the to ToString() operator + to its argument and interprets the resulting string as + a date. It returns a number, the UTC time value + corresponding to the date. - The string may be interpreted as a local time, a UTC - time, or a time in some other time zone, depending on - the contents of the string. + The string may be interpreted as a local time, a UTC + time, or a time in some other time zone, depending on + the contents of the string. - (need to test strings containing stuff with the time - zone specified, and verify that parse() returns the - correct GMT time) + (need to test strings containing stuff with the time + zone specified, and verify that parse() returns the + correct GMT time) - so for any Date object x, all of these things should - be equal: + so for any Date object x, all of these things should + be equal: - value tested in function: - x.valueOf() test_value() - Date.parse(x.toString()) test_tostring() - Date.parse(x.toGMTString()) test_togmt() + value tested in function: + x.valueOf() test_value() + Date.parse(x.toString()) test_tostring() + Date.parse(x.toGMTString()) test_togmt() - Date.parse(x.toLocaleString()) is not required to - produce the same number value as the preceeding three - expressions. in general the value produced by - Date.parse is implementation dependent when given any - string value that could not be produced in that - implementation by the toString or toGMTString method. + Date.parse(x.toLocaleString()) is not required to + produce the same number value as the preceeding three + expressions. in general the value produced by + Date.parse is implementation dependent when given any + string value that could not be produced in that + implementation by the toString or toGMTString method. - value tested in function: - Date.parse( x.toLocaleString()) test_tolocale() + value tested in function: + Date.parse( x.toLocaleString()) test_tolocale() - Author: christine@netscape.com - Date: 10 july 1997 + Author: christine@netscape.com + Date: 10 july 1997 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "15.9.4.2"; - var TITLE = "Date.parse()"; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.9.4.2"; +var TITLE = "Date.parse()"; - var TIME = 0; - var UTC_YEAR = 1; - var UTC_MONTH = 2; - var UTC_DATE = 3; - var UTC_DAY = 4; - var UTC_HOURS = 5; - var UTC_MINUTES = 6; - var UTC_SECONDS = 7; - var UTC_MS = 8; +var TIME = 0; +var UTC_YEAR = 1; +var UTC_MONTH = 2; +var UTC_DATE = 3; +var UTC_DAY = 4; +var UTC_HOURS = 5; +var UTC_MINUTES = 6; +var UTC_SECONDS = 7; +var UTC_MS = 8; - var YEAR = 9; - var MONTH = 10; - var DATE = 11; - var DAY = 12; - var HOURS = 13; - var MINUTES = 14; - var SECONDS = 15; - var MS = 16; - var TYPEOF = "object"; +var YEAR = 9; +var MONTH = 10; +var DATE = 11; +var DAY = 12; +var HOURS = 13; +var MINUTES = 14; +var SECONDS = 15; +var MS = 16; +var TYPEOF = "object"; // for TCMS, the testcases array must be global. - writeHeaderToLog("15.9.4.2 Date.parse()" ); - var tc= 0; - testcases = new Array(); - getTestCases(); +writeHeaderToLog("15.9.4.2 Date.parse()" ); -// all tests must call a function that returns an array of TestCase objects. - test(); +// Dates around 1970 -function getTestCases() { +addNewTestCase( new Date(0), + "new Date(0)", + [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); - // Dates around 1970 +addNewTestCase( new Date(-1), + "new Date(-1)", + [-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); +addNewTestCase( new Date(28799999), + "new Date(28799999)", + [28799999,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); +addNewTestCase( new Date(28800000), + "new Date(28800000)", + [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); - addNewTestCase( new Date(0), - "new Date(0)", - [0,1970,0,1,4,0,0,0,0,1969,11,31,3,16,0,0,0] ); +// Dates around 2000 - addNewTestCase( new Date(-1), - "new Date(-1)", - [-1,1969,11,31,3,23,59,59,999,1969,11,31,3,15,59,59,999] ); - addNewTestCase( new Date(28799999), - "new Date(28799999)", - [28799999,1970,0,1,4,7,59,59,999,1969,11,31,3,23,59,59,999] ); - addNewTestCase( new Date(28800000), - "new Date(28800000)", - [28800000,1970,0,1,4,8,0,0,0,1970,0,1,4,0,0,0,0] ); +addNewTestCase( new Date(946684799999), + "new Date(946684799999)", + [946684799999,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); +addNewTestCase( new Date(946713599999), + "new Date(946713599999)", + [946713599999,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); +addNewTestCase( new Date(946684800000), + "new Date(946684800000)", + [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); +addNewTestCase( new Date(946713600000), + "new Date(946713600000)", + [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); - // Dates around 2000 +// Dates around 1900 - addNewTestCase( new Date(946684799999), - "new Date(946684799999)", - [946684799999,1999,11,31,5,23,59,59,999,1999,11,31,5,15,59,59,999] ); - addNewTestCase( new Date(946713599999), - "new Date(946713599999)", - [946713599999,2000,0,1,6,7,59,59,999,1999,11,31,5,23,59,59,999] ); - addNewTestCase( new Date(946684800000), - "new Date(946684800000)", - [946684800000,2000,0,1,6,0,0,0,0,1999,11,31,5, 16,0,0,0] ); - addNewTestCase( new Date(946713600000), - "new Date(946713600000)", - [946713600000,2000,0,1,6,8,0,0,0,2000,0,1,6,0,0,0,0] ); +addNewTestCase( new Date(-2208988800000), + "new Date(-2208988800000)", + [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); - // Dates around 1900 +addNewTestCase( new Date(-2208988800001), + "new Date(-2208988800001)", + [-2208988800001,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); - addNewTestCase( new Date(-2208988800000), - "new Date(-2208988800000)", - [-2208988800000,1900,0,1,1,0,0,0,0,1899,11,31,0,16,0,0,0] ); +addNewTestCase( new Date(-2208960000001), + "new Date(-2208960000001)", + [-2208960000001,1900,0,1,1,7,59,59,0,1899,11,31,0,23,59,59,999] ); +addNewTestCase( new Date(-2208960000000), + "new Date(-2208960000000)", + [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); +addNewTestCase( new Date(-2208959999999), + "new Date(-2208959999999)", + [-2208959999999,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); - addNewTestCase( new Date(-2208988800001), - "new Date(-2208988800001)", - [-2208988800001,1899,11,31,0,23,59,59,999,1899,11,31,0,15,59,59,999] ); +// Dates around Feb 29, 2000 - addNewTestCase( new Date(-2208960000001), - "new Date(-2208960000001)", - [-2208960000001,1900,0,1,1,7,59,59,0,1899,11,31,0,23,59,59,999] ); - addNewTestCase( new Date(-2208960000000), - "new Date(-2208960000000)", - [-2208960000000,1900,0,1,1,8,0,0,0,1900,0,1,1,0,0,0,0] ); - addNewTestCase( new Date(-2208959999999), - "new Date(-2208959999999)", - [-2208959999999,1900,0,1,1,8,0,0,1,1900,0,1,1,0,0,0,1] ); +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; +addNewTestCase( new Date(UTC_FEB_29_2000), + "new Date(" + UTC_FEB_29_2000 +")", + [UTC_FEB_29_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(PST_FEB_29_2000), + "new Date(" + PST_FEB_29_2000 +")", + [PST_FEB_29_2000,2000,0,1,6,8.0,0,0,2000,0,1,6,0,0,0,0]); - // Dates around Feb 29, 2000 +// Dates around Jan 1 2005 - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - var PST_FEB_29_2000 = UTC_FEB_29_2000 + 8*msPerHour; - addNewTestCase( new Date(UTC_FEB_29_2000), - "new Date(" + UTC_FEB_29_2000 +")", - [UTC_FEB_29_2000,2000,0,1,6,0,0,0,0,1999,11,31,5,16,0,0,0] ); - addNewTestCase( new Date(PST_FEB_29_2000), - "new Date(" + PST_FEB_29_2000 +")", - [PST_FEB_29_2000,2000,0,1,6,8.0,0,0,2000,0,1,6,0,0,0,0]); +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); +var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; - // Dates around Jan 1 2005 +addNewTestCase( new Date(UTC_JAN_1_2005), + "new Date("+ UTC_JAN_1_2005 +")", + [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); +addNewTestCase( new Date(PST_JAN_1_2005), + "new Date("+ PST_JAN_1_2005 +")", + [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - var PST_JAN_1_2005 = UTC_JAN_1_2005 + 8*msPerHour; - addNewTestCase( new Date(UTC_JAN_1_2005), - "new Date("+ UTC_JAN_1_2005 +")", - [UTC_JAN_1_2005,2005,0,1,6,0,0,0,0,2004,11,31,5,16,0,0,0] ); - addNewTestCase( new Date(PST_JAN_1_2005), - "new Date("+ PST_JAN_1_2005 +")", - [PST_JAN_1_2005,2005,0,1,6,8,0,0,0,2005,0,1,6,0,0,0,0] ); +test(); -} function addNewTestCase( DateCase, DateString, ResultArray ) { - DateCase = DateCase; + DateCase = DateCase; - item = testcases.length; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, "Date.parse(" + DateCase.toString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toString()) ); - testcases[item++] = new TestCase( SECTION, "Date.parse(" + DateCase.toGMTString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toGMTString()) ); + new TestCase( SECTION, DateString+".getTime()", ResultArray[TIME], DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", ResultArray[TIME], DateCase.valueOf() ); + new TestCase( SECTION, "Date.parse(" + DateCase.toString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toString()) ); + new TestCase( SECTION, "Date.parse(" + DateCase.toGMTString() +")", Math.floor(ResultArray[TIME]/1000)*1000, Date.parse(DateCase.toGMTString()) ); /* - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() z inutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", ResultArray[UTC_YEAR], DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", ResultArray[UTC_MONTH], DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", ResultArray[UTC_DATE], DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", ResultArray[UTC_DAY], DateCase.getUTCDay() z inutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", ResultArray[UTC_SECONDS],DateCase.getUTCSeconds() ); +// new TestCase( SECTION, DateString+".getUTCMilliseconds()", ResultArray[UTC_MS], DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); +new TestCase( SECTION, DateString+".getFullYear()", ResultArray[YEAR], DateCase.getFullYear() ); +new TestCase( SECTION, DateString+".getMonth()", ResultArray[MONTH], DateCase.getMonth() ); +new TestCase( SECTION, DateString+".getDate()", ResultArray[DATE], DateCase.getDate() ); +new TestCase( SECTION, DateString+".getDay()", ResultArray[DAY], DateCase.getDay() ); +new TestCase( SECTION, DateString+".getHours()", ResultArray[HOURS], DateCase.getHours() ); +new TestCase( SECTION, DateString+".getMinutes()", ResultArray[MINUTES], DateCase.getMinutes() ); +new TestCase( SECTION, DateString+".getSeconds()", ResultArray[SECONDS], DateCase.getSeconds() ); +// new TestCase( SECTION, DateString+".getMilliseconds()", ResultArray[MS], DateCase.getMilliseconds() ); */ } -function test() { - for( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - stopTest(); - - // all tests must return an array of TestCase objects - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Date/15.9.4.3.js b/mozilla/js/tests/ecma/Date/15.9.4.3.js index b9e84ce1e25..5d619924de4 100644 --- a/mozilla/js/tests/ecma/Date/15.9.4.3.js +++ b/mozilla/js/tests/ecma/Date/15.9.4.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -36,189 +37,172 @@ * ***** END LICENSE BLOCK ***** */ - var testcases = new Array(); - var SECTION = "15.9.4.3"; - var TITLE = "Date.UTC( year, month, date, hours, minutes, seconds, ms )"; +var testcases = new Array(); +var SECTION = "15.9.4.3"; +var TITLE = "Date.UTC( year, month, date, hours, minutes, seconds, ms )"; - getTestCases(); - test(); +// Dates around 1970 -function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; -} +addNewTestCase( Date.UTC( 1970,0,1,0,0,0,0), + "Date.UTC( 1970,0,1,0,0,0,0)", + utc(1970,0,1,0,0,0,0) ); -function utc( year, month, date, hours, minutes, seconds, ms ) { - d = new MyDate(); - d.year = Number(year); +addNewTestCase( Date.UTC( 1969,11,31,23,59,59,999), + "Date.UTC( 1969,11,31,23,59,59,999)", + utc(1969,11,31,23,59,59,999) ); +addNewTestCase( Date.UTC( 1972,1,29,23,59,59,999), + "Date.UTC( 1972,1,29,23,59,59,999)", + utc(1972,1,29,23,59,59,999) ); +addNewTestCase( Date.UTC( 1972,2,1,23,59,59,999), + "Date.UTC( 1972,2,1,23,59,59,999)", + utc(1972,2,1,23,59,59,999) ); +addNewTestCase( Date.UTC( 1968,1,29,23,59,59,999), + "Date.UTC( 1968,1,29,23,59,59,999)", + utc(1968,1,29,23,59,59,999) ); +addNewTestCase( Date.UTC( 1968,2,1,23,59,59,999), + "Date.UTC( 1968,2,1,23,59,59,999)", + utc(1968,2,1,23,59,59,999) ); +addNewTestCase( Date.UTC( 1969,0,1,0,0,0,0), + "Date.UTC( 1969,0,1,0,0,0,0)", + utc(1969,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 1969,11,31,23,59,59,1000), + "Date.UTC( 1969,11,31,23,59,59,1000)", + utc(1970,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 1969,Number.NaN,31,23,59,59,999), + "Date.UTC( 1969,Number.NaN,31,23,59,59,999)", + utc(1969,Number.NaN,31,23,59,59,999) ); - if (month) - d.month = Number(month); - if (date) - d.date = Number(date); - if (hours) - d.hours = Number(hours); - if (minutes) - d.minutes = Number(minutes); - if (seconds) - d.seconds = Number(seconds); - if (ms) - d.ms = Number(ms); +// Dates around 2000 - if ( isNaN(d.year) && 0 <= ToInteger(d.year) && d.year <= 99 ) { - d.year = 1900 + ToInteger(d.year); - } +addNewTestCase( Date.UTC( 1999,11,31,23,59,59,999), + "Date.UTC( 1999,11,31,23,59,59,999)", + utc(1999,11,31,23,59,59,999) ); +addNewTestCase( Date.UTC( 2000,0,1,0,0,0,0), + "Date.UTC( 2000,0,1,0,0,0,0)", + utc(2000,0,1,0,0,0,0) ); - if (isNaN(month) || isNaN(year) || isNaN(date) || isNaN(hours) || - isNaN(minutes) || isNaN(seconds) || isNaN(ms) ) { - d.year = Number.NaN; - d.month = Number.NaN; - d.date = Number.NaN; - d.hours = Number.NaN; - d.minutes = Number.NaN; - d.seconds = Number.NaN; - d.ms = Number.NaN; - d.value = Number.NaN; - d.time = Number.NaN; - d.day =Number.NaN; - return d; - } +// Dates around 1900 +addNewTestCase( Date.UTC( 1899,11,31,23,59,59,999), + "Date.UTC( 1899,11,31,23,59,59,999)", + utc(1899,11,31,23,59,59,999) ); +addNewTestCase( Date.UTC( 1900,0,1,0,0,0,0), + "Date.UTC( 1900,0,1,0,0,0,0)", + utc(1900,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 1973,0,1,0,0,0,0), + "Date.UTC( 1973,0,1,0,0,0,0)", + utc(1973,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 1776,6,4,12,36,13,111), + "Date.UTC( 1776,6,4,12,36,13,111)", + utc(1776,6,4,12,36,13,111) ); +addNewTestCase( Date.UTC( 2525,9,18,15,30,1,123), + "Date.UTC( 2525,9,18,15,30,1,123)", + utc(2525,9,18,15,30,1,123) ); - d.day = MakeDay( d.year, d.month, d.date ); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = (TimeClip( MakeDate(d.day,d.time))); +// Dates around 29 Feb 2000 - return d; -} +addNewTestCase( Date.UTC( 2000,1,29,0,0,0,0 ), + "Date.UTC( 2000,1,29,0,0,0,0 )", + utc(2000,1,29,0,0,0,0) ); +addNewTestCase( Date.UTC( 2000,1,29,8,0,0,0 ), + "Date.UTC( 2000,1,29,8,0,0,0 )", + utc(2000,1,29,8,0,0,0) ); -function UTCTime( t ) { - sign = ( t < 0 ) ? -1 : 1; - return ( (t +(TZ_DIFF*msPerHour)) ); -} +// Dates around 1 Jan 2005 -function getTestCases() { +addNewTestCase( Date.UTC( 2005,0,1,0,0,0,0 ), + "Date.UTC( 2005,0,1,0,0,0,0 )", + utc(2005,0,1,0,0,0,0) ); +addNewTestCase( Date.UTC( 2004,11,31,16,0,0,0 ), + "Date.UTC( 2004,11,31,16,0,0,0 )", + utc(2004,11,31,16,0,0,0) ); - // Dates around 1970 - - addNewTestCase( Date.UTC( 1970,0,1,0,0,0,0), - "Date.UTC( 1970,0,1,0,0,0,0)", - utc(1970,0,1,0,0,0,0) ); - - addNewTestCase( Date.UTC( 1969,11,31,23,59,59,999), - "Date.UTC( 1969,11,31,23,59,59,999)", - utc(1969,11,31,23,59,59,999) ); - addNewTestCase( Date.UTC( 1972,1,29,23,59,59,999), - "Date.UTC( 1972,1,29,23,59,59,999)", - utc(1972,1,29,23,59,59,999) ); - addNewTestCase( Date.UTC( 1972,2,1,23,59,59,999), - "Date.UTC( 1972,2,1,23,59,59,999)", - utc(1972,2,1,23,59,59,999) ); - addNewTestCase( Date.UTC( 1968,1,29,23,59,59,999), - "Date.UTC( 1968,1,29,23,59,59,999)", - utc(1968,1,29,23,59,59,999) ); - addNewTestCase( Date.UTC( 1968,2,1,23,59,59,999), - "Date.UTC( 1968,2,1,23,59,59,999)", - utc(1968,2,1,23,59,59,999) ); - addNewTestCase( Date.UTC( 1969,0,1,0,0,0,0), - "Date.UTC( 1969,0,1,0,0,0,0)", - utc(1969,0,1,0,0,0,0) ); - addNewTestCase( Date.UTC( 1969,11,31,23,59,59,1000), - "Date.UTC( 1969,11,31,23,59,59,1000)", - utc(1970,0,1,0,0,0,0) ); - addNewTestCase( Date.UTC( 1969,Number.NaN,31,23,59,59,999), - "Date.UTC( 1969,Number.NaN,31,23,59,59,999)", - utc(1969,Number.NaN,31,23,59,59,999) ); - - // Dates around 2000 - - addNewTestCase( Date.UTC( 1999,11,31,23,59,59,999), - "Date.UTC( 1999,11,31,23,59,59,999)", - utc(1999,11,31,23,59,59,999) ); - addNewTestCase( Date.UTC( 2000,0,1,0,0,0,0), - "Date.UTC( 2000,0,1,0,0,0,0)", - utc(2000,0,1,0,0,0,0) ); - - // Dates around 1900 - addNewTestCase( Date.UTC( 1899,11,31,23,59,59,999), - "Date.UTC( 1899,11,31,23,59,59,999)", - utc(1899,11,31,23,59,59,999) ); - addNewTestCase( Date.UTC( 1900,0,1,0,0,0,0), - "Date.UTC( 1900,0,1,0,0,0,0)", - utc(1900,0,1,0,0,0,0) ); - addNewTestCase( Date.UTC( 1973,0,1,0,0,0,0), - "Date.UTC( 1973,0,1,0,0,0,0)", - utc(1973,0,1,0,0,0,0) ); - addNewTestCase( Date.UTC( 1776,6,4,12,36,13,111), - "Date.UTC( 1776,6,4,12,36,13,111)", - utc(1776,6,4,12,36,13,111) ); - addNewTestCase( Date.UTC( 2525,9,18,15,30,1,123), - "Date.UTC( 2525,9,18,15,30,1,123)", - utc(2525,9,18,15,30,1,123) ); - - // Dates around 29 Feb 2000 - - addNewTestCase( Date.UTC( 2000,1,29,0,0,0,0 ), - "Date.UTC( 2000,1,29,0,0,0,0 )", - utc(2000,1,29,0,0,0,0) ); - addNewTestCase( Date.UTC( 2000,1,29,8,0,0,0 ), - "Date.UTC( 2000,1,29,8,0,0,0 )", - utc(2000,1,29,8,0,0,0) ); - - // Dates around 1 Jan 2005 - - addNewTestCase( Date.UTC( 2005,0,1,0,0,0,0 ), - "Date.UTC( 2005,0,1,0,0,0,0 )", - utc(2005,0,1,0,0,0,0) ); - addNewTestCase( Date.UTC( 2004,11,31,16,0,0,0 ), - "Date.UTC( 2004,11,31,16,0,0,0 )", - utc(2004,11,31,16,0,0,0) ); -} +test(); function addNewTestCase( DateCase, DateString, ExpectDate) { - DateCase = DateCase; + DateCase = DateCase; - item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); - testcases[item++] = new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); + new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); + new TestCase( SECTION, DateString, ExpectDate.value, DateCase ); /* - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", ExpectDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", ExpectDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", ExpectDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", ExpectDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", ExpectDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", ExpectDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", ExpectDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", ExpectDate.ms, DateCase.getUTCMilliseconds() ); +new TestCase( SECTION, DateString+".getUTCFullYear()", ExpectDate.year, DateCase.getUTCFullYear() ); +new TestCase( SECTION, DateString+".getUTCMonth()", ExpectDate.month, DateCase.getUTCMonth() ); +new TestCase( SECTION, DateString+".getUTCDate()", ExpectDate.date, DateCase.getUTCDate() ); +new TestCase( SECTION, DateString+".getUTCDay()", ExpectDate.day, DateCase.getUTCDay() ); +new TestCase( SECTION, DateString+".getUTCHours()", ExpectDate.hours, DateCase.getUTCHours() ); +new TestCase( SECTION, DateString+".getUTCMinutes()", ExpectDate.minutes,DateCase.getUTCMinutes() ); +new TestCase( SECTION, DateString+".getUTCSeconds()", ExpectDate.seconds,DateCase.getUTCSeconds() ); +new TestCase( SECTION, DateString+".getUTCMilliseconds()", ExpectDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", ExpectDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", ExpectDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", ExpectDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", ExpectDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", ExpectDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", ExpectDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", ExpectDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", ExpectDate.ms, DateCase.getMilliseconds() ); +new TestCase( SECTION, DateString+".getFullYear()", ExpectDate.year, DateCase.getFullYear() ); +new TestCase( SECTION, DateString+".getMonth()", ExpectDate.month, DateCase.getMonth() ); +new TestCase( SECTION, DateString+".getDate()", ExpectDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", ExpectDate.day, DateCase.getDay() ); +new TestCase( SECTION, DateString+".getHours()", ExpectDate.hours, DateCase.getHours() ); +new TestCase( SECTION, DateString+".getMinutes()", ExpectDate.minutes, DateCase.getMinutes() ); +new TestCase( SECTION, DateString+".getSeconds()", ExpectDate.seconds, DateCase.getSeconds() ); +new TestCase( SECTION, DateString+".getMilliseconds()", ExpectDate.ms, DateCase.getMilliseconds() ); */ } -function test() { - for( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = " + - testcases[tc].actual ); - } - - stopTest(); - return testcases; +function MyDate() { + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } + +function utc( year, month, date, hours, minutes, seconds, ms ) { + d = new MyDate(); + d.year = Number(year); + + if (month) + d.month = Number(month); + if (date) + d.date = Number(date); + if (hours) + d.hours = Number(hours); + if (minutes) + d.minutes = Number(minutes); + if (seconds) + d.seconds = Number(seconds); + if (ms) + d.ms = Number(ms); + + if ( isNaN(d.year) && 0 <= ToInteger(d.year) && d.year <= 99 ) { + d.year = 1900 + ToInteger(d.year); + } + + if (isNaN(month) || isNaN(year) || isNaN(date) || isNaN(hours) || + isNaN(minutes) || isNaN(seconds) || isNaN(ms) ) { + d.year = Number.NaN; + d.month = Number.NaN; + d.date = Number.NaN; + d.hours = Number.NaN; + d.minutes = Number.NaN; + d.seconds = Number.NaN; + d.ms = Number.NaN; + d.value = Number.NaN; + d.time = Number.NaN; + d.day =Number.NaN; + return d; + } + + d.day = MakeDay( d.year, d.month, d.date ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = (TimeClip( MakeDate(d.day,d.time))); + + return d; +} + +function UTCTime( t ) { + sign = ( t < 0 ) ? -1 : 1; + return ( (t +(TZ_DIFF*msPerHour)) ); +} + diff --git a/mozilla/js/tests/ecma/Date/15.9.5.1.js b/mozilla/js/tests/ecma/Date/15.9.5.1.js index 458bf4541f0..c11795e8c3e 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,41 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.1.js - ECMA Section: 15.9.5.1 Date.prototype.constructor - Description: - The initial value of Date.prototype.constructor is the built-in Date - constructor. - Author: christine@netscape.com - Date: 12 november 1997 +/** + File Name: 15.9.5.1.js + ECMA Section: 15.9.5.1 Date.prototype.constructor + Description: + The initial value of Date.prototype.constructor is the built-in Date + constructor. + + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.constructor"; +var SECTION = "15.9.5.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.constructor"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.constructor == Date", - true, - Date.prototype.constructor == Date ); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Date.prototype.constructor == Date", + true, + Date.prototype.constructor == Date ); +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-1.js b/mozilla/js/tests/ecma/Date/15.9.5.10-1.js index ef6b913c2f6..dafa805b09e 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,97 +35,84 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( now ); +addTestCase( now ); /* - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); - addTestCase( DST_START_1998 ); - addTestCase( DST_START_1998-1 ); - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( time ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDate()", - DateFromTime(LocalTime(t)), - (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + new TestCase( SECTION, + "(new Date("+t+")).getDate()", + DateFromTime(LocalTime(t)), + (new Date(t)).getDate() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-10.js b/mozilla/js/tests/ecma/Date/15.9.5.10-10.js index 56a7d131908..d5cba5e03de 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-10.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-10.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,88 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( DST_START_1998+1 ); +addTestCase( DST_START_1998+1 ); /* - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-11.js b/mozilla/js/tests/ecma/Date/15.9.5.10-11.js index 727f3ce45f2..d417cc11c74 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-11.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-11.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,87 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( DST_END_1998 ); +addTestCase( DST_END_1998 ); /* - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-12.js b/mozilla/js/tests/ecma/Date/15.9.5.10-12.js index ee752f2bf54..e7b794471fa 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-12.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-12.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,86 +35,73 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( DST_END_1998-1 ); +addTestCase( DST_END_1998-1 ); /* - addTestCase( DST_END_1998+1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-13.js b/mozilla/js/tests/ecma/Date/15.9.5.10-13.js index b4b09432883..b174e935c80 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-13.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-13.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,70 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); +addTestCase( DST_END_1998+1 ); - addTestCase( DST_END_1998+1 ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-2.js b/mozilla/js/tests/ecma/Date/15.9.5.10-2.js index 351f5c562b7..6e421a29659 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,96 +35,83 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ); - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) +var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( time ); +addTestCase( time ); /* - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); - addTestCase( DST_START_1998 ); - addTestCase( DST_START_1998-1 ); - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +testcases[tc++] = new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-3.js b/mozilla/js/tests/ecma/Date/15.9.5.10-3.js index 331a8271c41..6863c1700c2 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,95 +35,82 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( TIME_1970 ); +addTestCase( TIME_1970 ); /* - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); - addTestCase( DST_START_1998 ); - addTestCase( DST_START_1998-1 ); - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-4.js b/mozilla/js/tests/ecma/Date/15.9.5.10-4.js index daf046d745f..8aa11808f69 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,80 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ); - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) +var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( TIME_1900 ); +addTestCase( TIME_1900 ); /* - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); - addTestCase( DST_START_1998 ); - addTestCase( DST_START_1998-1 ); - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-5.js b/mozilla/js/tests/ecma/Date/15.9.5.10-5.js index 62e54c78fb2..86e7d64a39c 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,81 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); + +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ); - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) +var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( TIME_2000 ); +addTestCase( TIME_2000 ); /* - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); - addTestCase( DST_START_1998 ); - addTestCase( DST_START_1998-1 ); - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-6.js b/mozilla/js/tests/ecma/Date/15.9.5.10-6.js index 45a5e54bd44..cb4a6b1f1a8 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,92 +35,79 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ); - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) +var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_FEB_29_2000 ); /* - addTestCase( UTC_JAN_1_2005 ); - addTestCase( DST_START_1998 ); - addTestCase( DST_START_1998-1 ); - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( UTC_JAN_1_2005 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-7.js b/mozilla/js/tests/ecma/Date/15.9.5.10-7.js index 82dcc0823fe..236c1610da1 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,91 +35,78 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) + var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( UTC_JAN_1_2005 ); +addTestCase( UTC_JAN_1_2005 ); /* - addTestCase( DST_START_1998 ); - addTestCase( DST_START_1998-1 ); - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( DST_START_1998 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-8.js b/mozilla/js/tests/ecma/Date/15.9.5.10-8.js index 33b749ab09a..688086c76c2 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-8.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,90 +35,77 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ); - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) +var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( DST_START_1998 ); +addTestCase( DST_START_1998 ); /* - addTestCase( DST_START_1998-1 ); - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( DST_START_1998-1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.10-9.js b/mozilla/js/tests/ecma/Date/15.9.5.10-9.js index 165773816c8..35826456fc2 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.10-9.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.10-9.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,89 +35,76 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.10.js - ECMA Section: 15.9.5.10 - Description: Date.prototype.getDate + File Name: 15.9.5.10.js + ECMA Section: 15.9.5.10 + Description: Date.prototype.getDate - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return DateFromTime(LocalTime(t)). + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return DateFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDate()"; +var SECTION = "15.9.5.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +// some daylight savings time cases - // some daylight savings time cases +var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ); - var DST_START_1998 = UTC( GetFirstSundayInApril(TimeFromYear(1998)) + 2*msPerHour ) +var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - var DST_END_1998 = UTC( GetLastSundayInOctober(TimeFromYear(1998)) + 2*msPerHour ); - - addTestCase( DST_START_1998-1 ); +addTestCase( DST_START_1998-1 ); /* - addTestCase( DST_START_1998+1 ); - addTestCase( DST_END_1998 ); - addTestCase( DST_END_1998-1 ); - addTestCase( DST_END_1998+1 ); + addTestCase( DST_START_1998+1 ); + addTestCase( DST_END_1998 ); + addTestCase( DST_END_1998-1 ); + addTestCase( DST_END_1998+1 ); */ - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDate()", - NaN, - (new Date(NaN)).getDate() ); +new TestCase( SECTION, + "(new Date(NaN)).getDate()", + NaN, + (new Date(NaN)).getDate() ); + +new TestCase( SECTION, + "Date.prototype.getDate.length", + 0, + Date.prototype.getDate.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDate.length", - 0, - Date.prototype.getDate.length ); - test(); function addTestCase( t ) { - for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, + for ( d = 0; d < TimeInMonth(MonthFromTime(t)); d+= msPerDay ) { + t += d; + testcases[tc++] = new TestCase( SECTION, "(new Date("+t+")).getDate()", DateFromTime(LocalTime(t)), (new Date(t)).getDate() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.11-1.js b/mozilla/js/tests/ecma/Date/15.9.5.11-1.js index d03d44406ad..84bb8384c8f 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.11-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.11-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,67 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.11.js - ECMA Section: 15.9.5.11 - Description: Date.prototype.getUTCDate + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate 1.Let t be this time value. 2.If t is NaN, return NaN. 1.Return DateFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDate()"; +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +addTestCase( now ); - addTestCase( now ); - - test() +test(); function addTestCase( t ) { - for ( var m = 0; m < 11; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); - for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDate()", - DateFromTime((t)), - (new Date(t)).getUTCDate() ); + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCDate()", - DateFromTime((t+1)), - (new Date(t+1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCDate()", - DateFromTime((t-1)), - (new Date(t-1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); */ - } } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.11-2.js b/mozilla/js/tests/ecma/Date/15.9.5.11-2.js index 04e8699fdcb..4f3344f60bc 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.11-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.11-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,82 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.11 - ECMA Section: 15.9.5.11 - Description: Date.prototype.getUTCDate + File Name: 15.9.5.11 + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate 1.Let t be this time value. 2.If t is NaN, return NaN. 1.Return DateFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDate()"; +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } +addTestCase( time ); - addTestCase( time ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 11; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); - for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDate()", - DateFromTime((t)), - (new Date(t)).getUTCDate() ); + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCDate()", - DateFromTime((t+1)), - (new Date(t+1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCDate()", - DateFromTime((t-1)), - (new Date(t-1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); */ - } } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.11-3.js b/mozilla/js/tests/ecma/Date/15.9.5.11-3.js index e17570a0f48..27dfd4db15b 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.11-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.11-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,77 +35,64 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.11.js - ECMA Section: 15.9.5.11 - Description: Date.prototype.getUTCDate + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate 1.Let t be this time value. 2.If t is NaN, return NaN. 1.Return DateFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDate()"; +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +addTestCase( TIME_1970 ); - addTestCase( TIME_1970 ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 11; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); - for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDate()", - DateFromTime((t)), - (new Date(t)).getUTCDate() ); + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCDate()", - DateFromTime((t+1)), - (new Date(t+1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCDate()", - DateFromTime((t-1)), - (new Date(t-1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); */ - } } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.11-4.js b/mozilla/js/tests/ecma/Date/15.9.5.11-4.js index ef9c265cc75..3d90207871b 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.11-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.11-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,77 +35,64 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.11.js - ECMA Section: 15.9.5.11 - Description: Date.prototype.getUTCDate + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate 1.Let t be this time value. 2.If t is NaN, return NaN. 1.Return DateFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDate()"; +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +addTestCase( TIME_1900 ); - addTestCase( TIME_1900 ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 11; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); - for ( var d = 0; d < TimeInMonth( m ); d += 7* msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDate()", - DateFromTime((t)), - (new Date(t)).getUTCDate() ); + for ( var d = 0; d < TimeInMonth( m ); d += 7* msPerDay ) { + t += d; + new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCDate()", - DateFromTime((t+1)), - (new Date(t+1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCDate()", - DateFromTime((t-1)), - (new Date(t-1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); */ - } } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.11-5.js b/mozilla/js/tests/ecma/Date/15.9.5.11-5.js index 1ed21cf908c..d362b310547 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.11-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.11-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,77 +35,64 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.11.js - ECMA Section: 15.9.5.11 - Description: Date.prototype.getUTCDate + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate 1.Let t be this time value. 2.If t is NaN, return NaN. 1.Return DateFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDate()"; +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +addTestCase( TIME_2000 ); - addTestCase( TIME_2000 ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 11; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); - for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDate()", - DateFromTime((t)), - (new Date(t)).getUTCDate() ); + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCDate()", - DateFromTime((t+1)), - (new Date(t+1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCDate()", - DateFromTime((t-1)), - (new Date(t-1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); */ - } } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.11-6.js b/mozilla/js/tests/ecma/Date/15.9.5.11-6.js index 20265ffdd05..290ffceee21 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.11-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.11-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,66 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.11.js - ECMA Section: 15.9.5.11 - Description: Date.prototype.getUTCDate + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate 1.Let t be this time value. 2.If t is NaN, return NaN. 1.Return DateFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDate()"; +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); - var UTC_FEB_29_2000 = TIME_2000 + ( 30 * msPerDay ) + ( 29 * msPerDay ); +addTestCase( UTC_FEB_29_2000 ); + +test(); - addTestCase( UTC_FEB_29_2000 ); - test(); function addTestCase( t ) { - for ( var m = 0; m < 11; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); - for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDate()", - DateFromTime((t)), - (new Date(t)).getUTCDate() ); + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCDate()", - DateFromTime((t+1)), - (new Date(t+1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCDate()", - DateFromTime((t-1)), - (new Date(t-1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); */ - } } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.11-7.js b/mozilla/js/tests/ecma/Date/15.9.5.11-7.js index 17b77738d60..ec5cfc2162e 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.11-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.11-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,67 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.11.js - ECMA Section: 15.9.5.11 - Description: Date.prototype.getUTCDate + File Name: 15.9.5.11.js + ECMA Section: 15.9.5.11 + Description: Date.prototype.getUTCDate 1.Let t be this time value. 2.If t is NaN, return NaN. 1.Return DateFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDate()"; +var SECTION = "15.9.5.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDate()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( UTC_JAN_1_2005 ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 11; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 11; m++ ) { + t += TimeInMonth(m); - for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { - t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDate()", - DateFromTime((t)), - (new Date(t)).getUTCDate() ); + for ( var d = 0; d < TimeInMonth( m ); d += 7*msPerDay ) { + t += d; + new TestCase( SECTION, + "(new Date("+t+")).getUTCDate()", + DateFromTime((t)), + (new Date(t)).getUTCDate() ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCDate()", - DateFromTime((t+1)), - (new Date(t+1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCDate()", + DateFromTime((t+1)), + (new Date(t+1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCDate()", - DateFromTime((t-1)), - (new Date(t-1)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCDate()", + DateFromTime((t-1)), + (new Date(t-1)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getUTCDate() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", - DateFromTime((t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getUTCDate() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCDate()", + DateFromTime((t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getUTCDate() ); */ - } } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.12-1.js b/mozilla/js/tests/ecma/Date/15.9.5.12-1.js index bd0aa99e6e8..6eed40fe25e 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.12-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.12-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,91 +35,78 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.12.js - ECMA Section: 15.9.5.12 - Description: Date.prototype.getDay + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return WeekDay(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDay()"; +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( now ); +addTestCase( now ); /* - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( time ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDay()", - NaN, - (new Date(NaN)).getDay() ); + new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDay.length", - 0, - Date.prototype.getDay.length ); + new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); */ - test(); +test(); + function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDay()", - WeekDay(LocalTime(t)), - (new Date(t)).getDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.12-2.js b/mozilla/js/tests/ecma/Date/15.9.5.12-2.js index 3018e89e49f..22d2f467e83 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.12-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.12-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,90 +35,77 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.12.js - ECMA Section: 15.9.5.12 - Description: Date.prototype.getDay + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return WeekDay(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDay()"; +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( time ); +addTestCase( time ); /* - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDay()", - NaN, - (new Date(NaN)).getDay() ); + new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDay.length", - 0, - Date.prototype.getDay.length ); + new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); */ - test(); +test(); + function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDay()", - WeekDay(LocalTime(t)), - (new Date(t)).getDay() ); - } + testcases[tc++] = new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.12-3.js b/mozilla/js/tests/ecma/Date/15.9.5.12-3.js index 1bb2e81ddb3..62abbdf34b9 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.12-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.12-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,89 +35,76 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.12.js - ECMA Section: 15.9.5.12 - Description: Date.prototype.getDay + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return WeekDay(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDay()"; +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( TIME_1970 ); +addTestCase( TIME_1970 ); /* - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDay()", - NaN, - (new Date(NaN)).getDay() ); + new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDay.length", - 0, - Date.prototype.getDay.length ); + new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); */ - test(); +test(); + function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDay()", - WeekDay(LocalTime(t)), - (new Date(t)).getDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.12-4.js b/mozilla/js/tests/ecma/Date/15.9.5.12-4.js index 449b3106912..a17673d74d3 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.12-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.12-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,88 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.12.js - ECMA Section: 15.9.5.12 - Description: Date.prototype.getDay + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return WeekDay(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDay()"; +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( TIME_1900 ); +addTestCase( TIME_1900 ); /* - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDay()", - NaN, - (new Date(NaN)).getDay() ); + new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDay.length", - 0, - Date.prototype.getDay.length ); + new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); */ - test(); +test(); + function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDay()", - WeekDay(LocalTime(t)), - (new Date(t)).getDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.12-5.js b/mozilla/js/tests/ecma/Date/15.9.5.12-5.js index 15d2fb9f456..e24ee6aaebc 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.12-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.12-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,87 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.12.js - ECMA Section: 15.9.5.12 - Description: Date.prototype.getDay + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return WeekDay(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDay()"; +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( TIME_2000 ); +addTestCase( TIME_2000 ); /* - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDay()", - NaN, - (new Date(NaN)).getDay() ); + new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDay.length", - 0, - Date.prototype.getDay.length ); + new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); */ - test(); +test(); + function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDay()", - WeekDay(LocalTime(t)), - (new Date(t)).getDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.12-6.js b/mozilla/js/tests/ecma/Date/15.9.5.12-6.js index bc4e4970330..721c48d35d6 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.12-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.12-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,86 +35,73 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.12.js - ECMA Section: 15.9.5.12 - Description: Date.prototype.getDay + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return WeekDay(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDay()"; +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_FEB_29_2000 ); /* - addTestCase( UTC_JAN_1_2005 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDay()", - NaN, - (new Date(NaN)).getDay() ); + new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDay.length", - 0, - Date.prototype.getDay.length ); + new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); */ - test(); +test(); + function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDay()", - WeekDay(LocalTime(t)), - (new Date(t)).getDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.12-7.js b/mozilla/js/tests/ecma/Date/15.9.5.12-7.js index a3f17d4fed5..f4dfb279b64 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.12-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.12-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,71 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.12.js - ECMA Section: 15.9.5.12 - Description: Date.prototype.getDay + File Name: 15.9.5.12.js + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return WeekDay(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDay()"; +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( UTC_JAN_1_2005 ); +addTestCase( UTC_JAN_1_2005 ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDay()", - NaN, - (new Date(NaN)).getDay() ); + new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDay.length", - 0, - Date.prototype.getDay.length ); + new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); */ - test(); +test(); + function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDay()", - WeekDay(LocalTime(t)), - (new Date(t)).getDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.12-8.js b/mozilla/js/tests/ecma/Date/15.9.5.12-8.js index 9d02cb31a6a..dd41d801340 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.12-8.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.12-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.12 - ECMA Section: 15.9.5.12 - Description: Date.prototype.getDay + File Name: 15.9.5.12 + ECMA Section: 15.9.5.12 + Description: Date.prototype.getDay - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return WeekDay(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return WeekDay(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getDay()"; +var SECTION = "15.9.5.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +new TestCase( SECTION, + "(new Date(NaN)).getDay()", + NaN, + (new Date(NaN)).getDay() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getDay()", - NaN, - (new Date(NaN)).getDay() ); +new TestCase( SECTION, + "Date.prototype.getDay.length", + 0, + Date.prototype.getDay.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getDay.length", - 0, - Date.prototype.getDay.length ); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*6 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getDay()", - WeekDay(LocalTime(t)), - (new Date(t)).getDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getDay()", + WeekDay(LocalTime(t)), + (new Date(t)).getDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.13-1.js b/mozilla/js/tests/ecma/Date/15.9.5.13-1.js index a0ab3e32c69..0174a4cae81 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.13-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.13-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,60 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.13.js - ECMA Section: 15.9.5.13 - Description: Date.prototype.getUTCDay + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay 1.Let t be this time value. 2.If t is NaN, return NaN. 3.Return WeekDay(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDay()"; +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +addTestCase( now ); - addTestCase( now ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDay()", - WeekDay((t)), - (new Date(t)).getUTCDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.13-2.js b/mozilla/js/tests/ecma/Date/15.9.5.13-2.js index b93ce909ae1..70bb2f2e6fb 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.13-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.13-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,48 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.13 - ECMA Section: 15.9.5.13 - Description: Date.prototype.getUTCDay + File Name: 15.9.5.13 + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay 1.Let t be this time value. 2.If t is NaN, return NaN. 3.Return WeekDay(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDay()"; +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } +addTestCase( time ); +test(); - addTestCase( time ); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDay()", - WeekDay((t)), - (new Date(t)).getUTCDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.13-3.js b/mozilla/js/tests/ecma/Date/15.9.5.13-3.js index d7b38598bc9..2a6ebdf8ffa 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.13-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.13-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,44 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.13.js - ECMA Section: 15.9.5.13 - Description: Date.prototype.getUTCDay + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay 1.Let t be this time value. 2.If t is NaN, return NaN. 3.Return WeekDay(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDay()"; +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +addTestCase( TIME_1970 ); - addTestCase( TIME_1970 ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDay()", - WeekDay((t)), - (new Date(t)).getUTCDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.13-4.js b/mozilla/js/tests/ecma/Date/15.9.5.13-4.js index 54e46bc0081..bf9e831eb98 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.13-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.13-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,44 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.13.js - ECMA Section: 15.9.5.13 - Description: Date.prototype.getUTCDay + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay 1.Let t be this time value. 2.If t is NaN, return NaN. 3.Return WeekDay(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDay()"; +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +addTestCase( TIME_1900 ); - addTestCase( TIME_1900 ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDay()", - WeekDay((t)), - (new Date(t)).getUTCDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.13-5.js b/mozilla/js/tests/ecma/Date/15.9.5.13-5.js index dc89262d0b2..231f1191dd9 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.13-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.13-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,44 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.13.js - ECMA Section: 15.9.5.13 - Description: Date.prototype.getUTCDay + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay 1.Let t be this time value. 2.If t is NaN, return NaN. 3.Return WeekDay(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDay()"; +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +addTestCase( TIME_2000 ); - addTestCase( TIME_2000 ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*14 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDay()", - WeekDay((t)), - (new Date(t)).getUTCDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.13-6.js b/mozilla/js/tests/ecma/Date/15.9.5.13-6.js index 6e1b117b8e0..41769aec491 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.13-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.13-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,60 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.13.js - ECMA Section: 15.9.5.13 - Description: Date.prototype.getUTCDay + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay 1.Let t be this time value. 2.If t is NaN, return NaN. 3.Return WeekDay(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDay()"; +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get time for 29 feb 2000 - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +addTestCase( UTC_FEB_29_2000 ); +test(); - addTestCase( UTC_FEB_29_2000 ); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDay()", - WeekDay((t)), - (new Date(t)).getUTCDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.13-7.js b/mozilla/js/tests/ecma/Date/15.9.5.13-7.js index 89f829f4049..4faec39f165 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.13-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.13-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,49 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.13.js - ECMA Section: 15.9.5.13 - Description: Date.prototype.getUTCDay + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay 1.Let t be this time value. 2.If t is NaN, return NaN. 3.Return WeekDay(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDay()"; +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( UTC_JAN_1_2005 ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDay()", - WeekDay((t)), - (new Date(t)).getUTCDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.13-8.js b/mozilla/js/tests/ecma/Date/15.9.5.13-8.js index b0be7541859..db56cae16cc 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.13-8.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.13-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.13.js - ECMA Section: 15.9.5.13 - Description: Date.prototype.getUTCDay + File Name: 15.9.5.13.js + ECMA Section: 15.9.5.13 + Description: Date.prototype.getUTCDay 1.Let t be this time value. 2.If t is NaN, return NaN. 3.Return WeekDay(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCDay()"; +var SECTION = "15.9.5.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCDay()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +new TestCase( SECTION, + "(new Date(NaN)).getUTCDay()", + NaN, + (new Date(NaN)).getUTCDay() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCDay()", - NaN, - (new Date(NaN)).getUTCDay() ); +new TestCase( SECTION, + "Date.prototype.getUTCDay.length", + 0, + Date.prototype.getUTCDay.length ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCDay.length", - 0, - Date.prototype.getUTCDay.length ); +test(); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { - t += TimeInMonth(m); + for ( var m = 0; m < 12; m++ ) { + t += TimeInMonth(m); - for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { - t += d; + for ( d = 0; d < TimeInMonth(m); d+= msPerDay*7 ) { + t += d; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCDay()", - WeekDay((t)), - (new Date(t)).getUTCDay() ); - } + new TestCase( SECTION, + "(new Date("+t+")).getUTCDay()", + WeekDay((t)), + (new Date(t)).getUTCDay() ); } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.14.js b/mozilla/js/tests/ecma/Date/15.9.5.14.js index cc0f9c58bf5..0919648b831 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.14.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.14.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,82 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.14.js - ECMA Section: 15.9.5.14 - Description: Date.prototype.getHours - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return HourFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 +/** + File Name: 15.9.5.14.js + ECMA Section: 15.9.5.14 + Description: Date.prototype.getHours + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return HourFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.14"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getHours()"; +var SECTION = "15.9.5.14"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getHours()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getHours()", + NaN, + (new Date(NaN)).getHours() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getHours()", - NaN, - (new Date(NaN)).getHours() ); +new TestCase( SECTION, + "Date.prototype.getHours.length", + 0, + Date.prototype.getHours.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getHours.length", - 0, - Date.prototype.getHours.length ); - test(); function addTestCase( t ) { - for ( h = 0; h < 24; h+=4 ) { - t += msPerHour; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getHours()", - HourFromTime((LocalTime(t))), - (new Date(t)).getHours() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( h = 0; h < 24; h+=4 ) { + t += msPerHour; + new TestCase( SECTION, + "(new Date("+t+")).getHours()", + HourFromTime((LocalTime(t))), + (new Date(t)).getHours() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.15.js b/mozilla/js/tests/ecma/Date/15.9.5.15.js index 36b6ca31334..99ae14e3aa0 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.15.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.15.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,70 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.15.js - ECMA Section: 15.9.5.15 - Description: Date.prototype.getUTCHours + File Name: 15.9.5.15.js + ECMA Section: 15.9.5.15 + Description: Date.prototype.getUTCHours - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return HourFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return HourFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.15"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCHours()"; +var SECTION = "15.9.5.15"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCHours()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getUTCHours()", + NaN, + (new Date(NaN)).getUTCHours() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCHours()", - NaN, - (new Date(NaN)).getUTCHours() ); +new TestCase( SECTION, + "Date.prototype.getUTCHours.length", + 0, + Date.prototype.getUTCHours.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCHours.length", - 0, - Date.prototype.getUTCHours.length ); - test(); function addTestCase( t ) { - for ( h = 0; h < 24; h+=3 ) { - t += msPerHour; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCHours()", - HourFromTime((t)), - (new Date(t)).getUTCHours() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( h = 0; h < 24; h+=3 ) { + t += msPerHour; + new TestCase( SECTION, + "(new Date("+t+")).getUTCHours()", + HourFromTime((t)), + (new Date(t)).getUTCHours() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.16.js b/mozilla/js/tests/ecma/Date/15.9.5.16.js index ea2542fef6a..ad92a6c4313 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.16.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.16.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,82 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.16.js - ECMA Section: 15.9.5.16 - Description: Date.prototype.getMinutes - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return MinFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 +/** + File Name: 15.9.5.16.js + ECMA Section: 15.9.5.16 + Description: Date.prototype.getMinutes + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return MinFromTime(LocalTime(t)). + + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.16"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getMinutes()"; +var SECTION = "15.9.5.16"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getMinutes()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getMinutes()", + NaN, + (new Date(NaN)).getMinutes() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getMinutes()", - NaN, - (new Date(NaN)).getMinutes() ); +new TestCase( SECTION, + "Date.prototype.getMinutes.length", + 0, + Date.prototype.getMinutes.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getMinutes.length", - 0, - Date.prototype.getMinutes.length ); - test(); function addTestCase( t ) { - for ( m = 0; m <= 60; m+=10 ) { - t += msPerMinute; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getMinutes()", - MinFromTime((LocalTime(t))), - (new Date(t)).getMinutes() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( m = 0; m <= 60; m+=10 ) { + t += msPerMinute; + new TestCase( SECTION, + "(new Date("+t+")).getMinutes()", + MinFromTime((LocalTime(t))), + (new Date(t)).getMinutes() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.17.js b/mozilla/js/tests/ecma/Date/15.9.5.17.js index d748d94566c..3b822bc97b3 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.17.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.17.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,70 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.17.js - ECMA Section: 15.9.5.17 - Description: Date.prototype.getUTCMinutes + File Name: 15.9.5.17.js + ECMA Section: 15.9.5.17 + Description: Date.prototype.getUTCMinutes - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return MinFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MinFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.17"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMinutes()"; +var SECTION = "15.9.5.17"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMinutes()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getUTCMinutes()", + NaN, + (new Date(NaN)).getUTCMinutes() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCMinutes()", - NaN, - (new Date(NaN)).getUTCMinutes() ); +new TestCase( SECTION, + "Date.prototype.getUTCMinutes.length", + 0, + Date.prototype.getUTCMinutes.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCMinutes.length", - 0, - Date.prototype.getUTCMinutes.length ); - test(); function addTestCase( t ) { - for ( m = 0; m <= 60; m+=10 ) { - t += msPerMinute; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMinutes()", - MinFromTime(t), - (new Date(t)).getUTCMinutes() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( m = 0; m <= 60; m+=10 ) { + t += msPerMinute; + new TestCase( SECTION, + "(new Date("+t+")).getUTCMinutes()", + MinFromTime(t), + (new Date(t)).getUTCMinutes() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.18.js b/mozilla/js/tests/ecma/Date/15.9.5.18.js index 68f3d89cfee..6c7ffa83fb6 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.18.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.18.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,70 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.18.js - ECMA Section: 15.9.5.18 - Description: Date.prototype.getSeconds + File Name: 15.9.5.18.js + ECMA Section: 15.9.5.18 + Description: Date.prototype.getSeconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return SecFromTime(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return SecFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.18"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getSeconds()"; +var SECTION = "15.9.5.18"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getSeconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getSeconds()", + NaN, + (new Date(NaN)).getSeconds() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getSeconds()", - NaN, - (new Date(NaN)).getSeconds() ); +new TestCase( SECTION, + "Date.prototype.getSeconds.length", + 0, + Date.prototype.getSeconds.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getSeconds.length", - 0, - Date.prototype.getSeconds.length ); - test(); function addTestCase( t ) { - for ( m = 0; m <= 60; m+=10 ) { - t += 1000; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getSeconds()", - SecFromTime(LocalTime(t)), - (new Date(t)).getSeconds() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( m = 0; m <= 60; m+=10 ) { + t += 1000; + new TestCase( SECTION, + "(new Date("+t+")).getSeconds()", + SecFromTime(LocalTime(t)), + (new Date(t)).getSeconds() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.19.js b/mozilla/js/tests/ecma/Date/15.9.5.19.js index b4967b9daec..0716ed3a640 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.19.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.19.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,70 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.19.js - ECMA Section: 15.9.5.19 - Description: Date.prototype.getUTCSeconds + File Name: 15.9.5.19.js + ECMA Section: 15.9.5.19 + Description: Date.prototype.getUTCSeconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return SecFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return SecFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.19"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCSeconds()"; +var SECTION = "15.9.5.19"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCSeconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getUTCSeconds()", + NaN, + (new Date(NaN)).getUTCSeconds() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCSeconds()", - NaN, - (new Date(NaN)).getUTCSeconds() ); +new TestCase( SECTION, + "Date.prototype.getUTCSeconds.length", + 0, + Date.prototype.getUTCSeconds.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCSeconds.length", - 0, - Date.prototype.getUTCSeconds.length ); - test(); function addTestCase( t ) { - for ( m = 0; m <= 60; m+=10 ) { - t += 1000; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCSeconds()", - SecFromTime(t), - (new Date(t)).getUTCSeconds() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( m = 0; m <= 60; m+=10 ) { + t += 1000; + new TestCase( SECTION, + "(new Date("+t+")).getUTCSeconds()", + SecFromTime(t), + (new Date(t)).getUTCSeconds() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.2-1.js b/mozilla/js/tests/ecma/Date/15.9.5.2-1.js index e2949f1bf23..02fe596128d 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.2-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,134 +35,120 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.2.js - ECMA Section: 15.9.5.2 Date.prototype.toString - Description: - This function returns a string value. The contents of the string are - implementation dependent, but are intended to represent the Date in a - convenient, human-readable form in the current time zone. + File Name: 15.9.5.2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. - The toString function is not generic; it generates a runtime error if its - this value is not a Date object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.toString"; +var SECTION = "15.9.5.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.toString"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "Date.prototype.toString.length", + 0, + Date.prototype.toString.length ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.toString.length", - 0, - Date.prototype.toString.length ); +var now = new Date(); - var now = new Date(); +// can't test the content of the string, but can verify that the string is +// parsable by Date.parse - // can't test the content of the string, but can verify that the string is - // parsable by Date.parse +new TestCase( SECTION, + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", + true, + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); - testcases[tc++] = new TestCase( SECTION, - "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", - true, - Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); +new TestCase( SECTION, + "typeof now.toString()", + "string", + typeof now.toString() ); +// 1970 - testcases[tc++] = new TestCase( SECTION, - "typeof now.toString()", - "string", - typeof now.toString() ); - // 1970 +TZ_ADJUST = TZ_DIFF * msPerHour; - TZ_ADJUST = TZ_DIFF * msPerHour; +new TestCase( SECTION, + "Date.parse( (new Date(0)).toString() )", + 0, + Date.parse( (new Date(0)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date(0)).toString() )", - 0, - Date.parse( (new Date(0)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", + TZ_ADJUST, + Date.parse( (new Date(TZ_ADJUST)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", - TZ_ADJUST, - Date.parse( (new Date(TZ_ADJUST)).toString() ) ) +// 1900 +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900+")).toString() )", + TIME_1900, + Date.parse( (new Date(TIME_1900)).toString() ) ); - // 1900 - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TIME_1900+")).toString() )", - TIME_1900, - Date.parse( (new Date(TIME_1900)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", + TIME_1900 -TZ_ADJUST, + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", - TIME_1900 -TZ_ADJUST, - Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ) +// 2000 +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000+")).toString() )", + TIME_2000, + Date.parse( (new Date(TIME_2000)).toString() ) ); - // 2000 - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TIME_2000+")).toString() )", - TIME_2000, - Date.parse( (new Date(TIME_2000)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", + TIME_2000 -TZ_ADJUST, + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", - TIME_2000 -TZ_ADJUST, - Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ) +// 29 Feb 2000 - // 29 Feb 2000 +var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +new TestCase( SECTION, + "Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )", + UTC_29_FEB_2000, + Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) ); - var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )", - UTC_29_FEB_2000, - Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) ) - - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )", - UTC_29_FEB_2000-1000, - Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )", + UTC_29_FEB_2000-1000, + Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )", - UTC_29_FEB_2000-TZ_ADJUST, - Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) ) - // 2O05 +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )", + UTC_29_FEB_2000-TZ_ADJUST, + Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) ); +// 2O05 - var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )", - UTC_1_JAN_2005, - Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) ) +var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); +new TestCase( SECTION, + "Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )", + UTC_1_JAN_2005, + Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )", - UTC_1_JAN_2005-1000, - Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )", + UTC_1_JAN_2005-1000, + Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )", - UTC_1_JAN_2005-TZ_ADJUST, - Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )", + UTC_1_JAN_2005-TZ_ADJUST, + Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) ); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.5.2-2-n.js b/mozilla/js/tests/ecma/Date/15.9.5.2-2-n.js index ae50eff6938..b6647bf268f 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.2-2-n.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.2-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,59 +35,48 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.2-2.js - ECMA Section: 15.9.5.2 Date.prototype.toString - Description: - This function returns a string value. The contents of the string are - implementation dependent, but are intended to represent the Date in a - convenient, human-readable form in the current time zone. + File Name: 15.9.5.2-2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. - The toString function is not generic; it generates a runtime error if its - this value is not a Date object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - This verifies that calling toString on an object that is not a string - generates a runtime error. + This verifies that calling toString on an object that is not a string + generates a runtime error. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.toString"; +var SECTION = "15.9.5.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.toString"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var OBJ = new MyObject( new Date(0) ); - var OBJ = new MyObject( new Date(0) ); +DESCRIPTION = "var OBJ = new MyObject( new Date(0) ); OBJ.toString()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, - "var OBJ = new MyObject( new Date(0) ); OBJ.toString()", - "error", - OBJ.toString() ); - test(); +new TestCase( SECTION, + "var OBJ = new MyObject( new Date(0) ); OBJ.toString()", + "error", + eval("OBJ.toString()") ); +test(); function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - this.toString = Date.prototype.toString; - return this; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = Date.prototype.toString; + return this; } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.2.js b/mozilla/js/tests/ecma/Date/15.9.5.2.js index e2949f1bf23..02fe596128d 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,134 +35,120 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.2.js - ECMA Section: 15.9.5.2 Date.prototype.toString - Description: - This function returns a string value. The contents of the string are - implementation dependent, but are intended to represent the Date in a - convenient, human-readable form in the current time zone. + File Name: 15.9.5.2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. - The toString function is not generic; it generates a runtime error if its - this value is not a Date object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.toString"; +var SECTION = "15.9.5.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.toString"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "Date.prototype.toString.length", + 0, + Date.prototype.toString.length ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.toString.length", - 0, - Date.prototype.toString.length ); +var now = new Date(); - var now = new Date(); +// can't test the content of the string, but can verify that the string is +// parsable by Date.parse - // can't test the content of the string, but can verify that the string is - // parsable by Date.parse +new TestCase( SECTION, + "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", + true, + Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); - testcases[tc++] = new TestCase( SECTION, - "Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000", - true, - Math.abs(Date.parse(now.toString()) - now.valueOf()) < 1000 ); +new TestCase( SECTION, + "typeof now.toString()", + "string", + typeof now.toString() ); +// 1970 - testcases[tc++] = new TestCase( SECTION, - "typeof now.toString()", - "string", - typeof now.toString() ); - // 1970 +TZ_ADJUST = TZ_DIFF * msPerHour; - TZ_ADJUST = TZ_DIFF * msPerHour; +new TestCase( SECTION, + "Date.parse( (new Date(0)).toString() )", + 0, + Date.parse( (new Date(0)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date(0)).toString() )", - 0, - Date.parse( (new Date(0)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", + TZ_ADJUST, + Date.parse( (new Date(TZ_ADJUST)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TZ_ADJUST+")).toString() )", - TZ_ADJUST, - Date.parse( (new Date(TZ_ADJUST)).toString() ) ) +// 1900 +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900+")).toString() )", + TIME_1900, + Date.parse( (new Date(TIME_1900)).toString() ) ); - // 1900 - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TIME_1900+")).toString() )", - TIME_1900, - Date.parse( (new Date(TIME_1900)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", + TIME_1900 -TZ_ADJUST, + Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TIME_1900 -TZ_ADJUST+")).toString() )", - TIME_1900 -TZ_ADJUST, - Date.parse( (new Date(TIME_1900 -TZ_ADJUST)).toString() ) ) +// 2000 +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000+")).toString() )", + TIME_2000, + Date.parse( (new Date(TIME_2000)).toString() ) ); - // 2000 - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TIME_2000+")).toString() )", - TIME_2000, - Date.parse( (new Date(TIME_2000)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", + TIME_2000 -TZ_ADJUST, + Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+TIME_2000 -TZ_ADJUST+")).toString() )", - TIME_2000 -TZ_ADJUST, - Date.parse( (new Date(TIME_2000 -TZ_ADJUST)).toString() ) ) +// 29 Feb 2000 - // 29 Feb 2000 +var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +new TestCase( SECTION, + "Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )", + UTC_29_FEB_2000, + Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) ); - var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+UTC_29_FEB_2000+")).toString() )", - UTC_29_FEB_2000, - Date.parse( (new Date(UTC_29_FEB_2000)).toString() ) ) - - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )", - UTC_29_FEB_2000-1000, - Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-1000)+")).toString() )", + UTC_29_FEB_2000-1000, + Date.parse( (new Date(UTC_29_FEB_2000-1000)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )", - UTC_29_FEB_2000-TZ_ADJUST, - Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) ) - // 2O05 +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_29_FEB_2000-TZ_ADJUST)+")).toString() )", + UTC_29_FEB_2000-TZ_ADJUST, + Date.parse( (new Date(UTC_29_FEB_2000-TZ_ADJUST)).toString() ) ); +// 2O05 - var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )", - UTC_1_JAN_2005, - Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) ) +var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + +TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); +new TestCase( SECTION, + "Date.parse( (new Date("+UTC_1_JAN_2005+")).toString() )", + UTC_1_JAN_2005, + Date.parse( (new Date(UTC_1_JAN_2005)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )", - UTC_1_JAN_2005-1000, - Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-1000)+")).toString() )", + UTC_1_JAN_2005-1000, + Date.parse( (new Date(UTC_1_JAN_2005-1000)).toString() ) ); - testcases[tc++] = new TestCase( SECTION, - "Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )", - UTC_1_JAN_2005-TZ_ADJUST, - Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) ) +new TestCase( SECTION, + "Date.parse( (new Date("+(UTC_1_JAN_2005-TZ_ADJUST)+")).toString() )", + UTC_1_JAN_2005-TZ_ADJUST, + Date.parse( (new Date(UTC_1_JAN_2005-TZ_ADJUST)).toString() ) ); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Date/15.9.5.20.js b/mozilla/js/tests/ecma/Date/15.9.5.20.js index 6782eaa50dc..324995476bd 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.20.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.20.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,70 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.20.js - ECMA Section: 15.9.5.20 - Description: Date.prototype.getMilliseconds + File Name: 15.9.5.20.js + ECMA Section: 15.9.5.20 + Description: Date.prototype.getMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.20"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getMilliseconds()"; +var SECTION = "15.9.5.20"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getMilliseconds()", + NaN, + (new Date(NaN)).getMilliseconds() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getMilliseconds()", - NaN, - (new Date(NaN)).getMilliseconds() ); +new TestCase( SECTION, + "Date.prototype.getMilliseconds.length", + 0, + Date.prototype.getMilliseconds.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getMilliseconds.length", - 0, - Date.prototype.getMilliseconds.length ); - test(); function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getMilliseconds()", - msFromTime(LocalTime(t)), - (new Date(t)).getMilliseconds() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getMilliseconds()", + msFromTime(LocalTime(t)), + (new Date(t)).getMilliseconds() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.21-1.js b/mozilla/js/tests/ecma/Date/15.9.5.21-1.js index f8d9d6ef337..77eed428003 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.21-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.21-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.21.js - ECMA Section: 15.9.5.21 - Description: Date.prototype.getUTCMilliseconds + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.21"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMilliseconds()"; +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( now ); +addTestCase( now ); /* - addTestCase( time ); + addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCMilliseconds()", - NaN, - (new Date(NaN)).getUTCMilliseconds() ); + new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCMilliseconds.length", - 0, - Date.prototype.getUTCMilliseconds.length ); + new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); */ - test(); +test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMilliseconds()", - msFromTime(t), - (new Date(t)).getUTCMilliseconds() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.21-2.js b/mozilla/js/tests/ecma/Date/15.9.5.21-2.js index a25cec5f6a7..0cefc9b7d59 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.21-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.21-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.21.js - ECMA Section: 15.9.5.21 - Description: Date.prototype.getUTCMilliseconds + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.21"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMilliseconds()"; +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( time ); +addTestCase( time ); /* - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCMilliseconds()", - NaN, - (new Date(NaN)).getUTCMilliseconds() ); + new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCMilliseconds.length", - 0, - Date.prototype.getUTCMilliseconds.length ); + new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); */ - test(); -function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMilliseconds()", - msFromTime(t), - (new Date(t)).getUTCMilliseconds() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +test(); + +function addTestCase( t ) { + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.21-3.js b/mozilla/js/tests/ecma/Date/15.9.5.21-3.js index cf6a85fc7af..a6a70e71465 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.21-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.21-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,64 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.21.js - ECMA Section: 15.9.5.21 - Description: Date.prototype.getUTCMilliseconds + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.21"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMilliseconds()"; +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( TIME_1970 ); + +test(); - addTestCase( TIME_1970 ); - test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMilliseconds()", - msFromTime(t), - (new Date(t)).getUTCMilliseconds() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.21-4.js b/mozilla/js/tests/ecma/Date/15.9.5.21-4.js index d6f576771ed..79b825de9f2 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.21-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.21-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,64 +35,51 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.21.js - ECMA Section: 15.9.5.21 - Description: Date.prototype.getUTCMilliseconds + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.21"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMilliseconds()"; +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( TIME_1900 ); +test(); - addTestCase( TIME_1900 ); - test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMilliseconds()", - msFromTime(t), - (new Date(t)).getUTCMilliseconds() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.21-5.js b/mozilla/js/tests/ecma/Date/15.9.5.21-5.js index bc872683271..d1ac8597284 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.21-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.21-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,64 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.21.js - ECMA Section: 15.9.5.21 - Description: Date.prototype.getUTCMilliseconds + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.21"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMilliseconds()"; +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( TIME_2000 ); + +test(); - addTestCase( TIME_2000 ); - test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMilliseconds()", - msFromTime(t), - (new Date(t)).getUTCMilliseconds() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.21-6.js b/mozilla/js/tests/ecma/Date/15.9.5.21-6.js index a16720b2ae0..cc0a8e5e8fb 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.21-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.21-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.21.js - ECMA Section: 15.9.5.21 - Description: Date.prototype.getUTCMilliseconds + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.21"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMilliseconds()"; +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_FEB_29_2000 ); +test(); - test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMilliseconds()", - msFromTime(t), - (new Date(t)).getUTCMilliseconds() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.21-7.js b/mozilla/js/tests/ecma/Date/15.9.5.21-7.js index 251456ee3a4..334872b409d 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.21-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.21-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,64 +35,51 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.21.js - ECMA Section: 15.9.5.21 - Description: Date.prototype.getUTCMilliseconds + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.21"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMilliseconds()"; +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( UTC_JAN_1_2005 ); +test(); - addTestCase( UTC_JAN_1_2005 ); - test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMilliseconds()", - msFromTime(t), - (new Date(t)).getUTCMilliseconds() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.21-8.js b/mozilla/js/tests/ecma/Date/15.9.5.21-8.js index 2b391e5012c..82388246374 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.21-8.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.21-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,59 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.21.js - ECMA Section: 15.9.5.21 - Description: Date.prototype.getUTCMilliseconds + File Name: 15.9.5.21.js + ECMA Section: 15.9.5.21 + Description: Date.prototype.getUTCMilliseconds - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return msFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return msFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.21"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMilliseconds()"; +var SECTION = "15.9.5.21"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMilliseconds()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +new TestCase( SECTION, + "(new Date(NaN)).getUTCMilliseconds()", + NaN, + (new Date(NaN)).getUTCMilliseconds() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCMilliseconds()", - NaN, - (new Date(NaN)).getUTCMilliseconds() ); +new TestCase( SECTION, + "Date.prototype.getUTCMilliseconds.length", + 0, + Date.prototype.getUTCMilliseconds.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCMilliseconds.length", - 0, - Date.prototype.getUTCMilliseconds.length ); - test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMilliseconds()", - msFromTime(t), - (new Date(t)).getUTCMilliseconds() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCMilliseconds()", + msFromTime(t), + (new Date(t)).getUTCMilliseconds() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.22-1.js b/mozilla/js/tests/ecma/Date/15.9.5.22-1.js index 5f8280fdd23..6a0f4e48163 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.22-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.22-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,86 +35,73 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.22.js - ECMA Section: 15.9.5.22 - Description: Date.prototype.getTimezoneOffset + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset - Returns the difference between local time and UTC time in minutes. - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return (t - LocalTime(t)) / msPerMinute. + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.22"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTimezoneOffset()"; +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 - - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); // addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getTimezoneOffset()", - NaN, - (new Date(NaN)).getTimezoneOffset() ); +new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getTimezoneOffset.length", - 0, - Date.prototype.getTimezoneOffset.length ); +new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); + +test(); - test(); function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getTimezoneOffset()", - (t - LocalTime(t)) / msPerMinute, - (new Date(t)).getTimezoneOffset() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.22-2.js b/mozilla/js/tests/ecma/Date/15.9.5.22-2.js index 09f0d40f564..8df39133b80 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.22-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.22-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,85 +35,72 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.22.js - ECMA Section: 15.9.5.22 - Description: Date.prototype.getTimezoneOffset + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset - Returns the difference between local time and UTC time in minutes. - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return (t - LocalTime(t)) / msPerMinute. + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.22"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTimezoneOffset()"; +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( time ); +addTestCase( time ); /* - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( TIME_1970 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getTimezoneOffset()", - NaN, - (new Date(NaN)).getTimezoneOffset() ); + new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getTimezoneOffset.length", - 0, - Date.prototype.getTimezoneOffset.length ); + new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); */ - test(); -function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getTimezoneOffset()", - (t - LocalTime(t)) / msPerMinute, - (new Date(t)).getTimezoneOffset() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.22-3.js b/mozilla/js/tests/ecma/Date/15.9.5.22-3.js index 88aa740ce48..62fc49579b4 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.22-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.22-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,71 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.22.js - ECMA Section: 15.9.5.22 - Description: Date.prototype.getTimezoneOffset + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset - Returns the difference between local time and UTC time in minutes. - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return (t - LocalTime(t)) / msPerMinute. + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.22"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTimezoneOffset()"; +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( TIME_1970 ); +addTestCase( TIME_1970 ); /* - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( TIME_1900 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getTimezoneOffset()", - NaN, - (new Date(NaN)).getTimezoneOffset() ); + new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getTimezoneOffset.length", - 0, - Date.prototype.getTimezoneOffset.length ); + new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); */ - test(); -function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getTimezoneOffset()", - (t - LocalTime(t)) / msPerMinute, - (new Date(t)).getTimezoneOffset() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.22-4.js b/mozilla/js/tests/ecma/Date/15.9.5.22-4.js index a16c6e39670..8723ca6ad2b 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.22-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.22-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,70 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.22.js - ECMA Section: 15.9.5.22 - Description: Date.prototype.getTimezoneOffset + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset - Returns the difference between local time and UTC time in minutes. - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return (t - LocalTime(t)) / msPerMinute. + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.22"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTimezoneOffset()"; +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( TIME_1900 ); +addTestCase( TIME_1900 ); /* - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( TIME_2000 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getTimezoneOffset()", - NaN, - (new Date(NaN)).getTimezoneOffset() ); + new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getTimezoneOffset.length", - 0, - Date.prototype.getTimezoneOffset.length ); + new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); */ - test(); -function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getTimezoneOffset()", - (t - LocalTime(t)) / msPerMinute, - (new Date(t)).getTimezoneOffset() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.22-5.js b/mozilla/js/tests/ecma/Date/15.9.5.22-5.js index 8c89c3b7415..de190794aa5 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.22-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.22-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,82 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.22.js - ECMA Section: 15.9.5.22 - Description: Date.prototype.getTimezoneOffset + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset - Returns the difference between local time and UTC time in minutes. - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return (t - LocalTime(t)) / msPerMinute. + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.22"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTimezoneOffset()"; +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( TIME_2000 ); +addTestCase( TIME_2000 ); /* - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); + addTestCase( UTC_FEB_29_2000 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getTimezoneOffset()", - NaN, - (new Date(NaN)).getTimezoneOffset() ); + new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getTimezoneOffset.length", - 0, - Date.prototype.getTimezoneOffset.length ); + new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); */ - test(); -function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getTimezoneOffset()", - (t - LocalTime(t)) / msPerMinute, - (new Date(t)).getTimezoneOffset() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.22-6.js b/mozilla/js/tests/ecma/Date/15.9.5.22-6.js index fe760a1c06b..66d4bfc69f5 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.22-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.22-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.22.js - ECMA Section: 15.9.5.22 - Description: Date.prototype.getTimezoneOffset + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset - Returns the difference between local time and UTC time in minutes. - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return (t - LocalTime(t)) / msPerMinute. + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.22"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTimezoneOffset()"; +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_FEB_29_2000 ); /* - addTestCase( UTC_JAN_1_2005 ); + addTestCase( UTC_JAN_1_2005 ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getTimezoneOffset()", - NaN, - (new Date(NaN)).getTimezoneOffset() ); + new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getTimezoneOffset.length", - 0, - Date.prototype.getTimezoneOffset.length ); + new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); */ - test(); -function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getTimezoneOffset()", - (t - LocalTime(t)) / msPerMinute, - (new Date(t)).getTimezoneOffset() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.22-7.js b/mozilla/js/tests/ecma/Date/15.9.5.22-7.js index ccc08b1d506..6694627197a 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.22-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.22-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,79 +35,66 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.22.js - ECMA Section: 15.9.5.22 - Description: Date.prototype.getTimezoneOffset + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset - Returns the difference between local time and UTC time in minutes. - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return (t - LocalTime(t)) / msPerMinute. + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.22"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTimezoneOffset()"; +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( UTC_JAN_1_2005 ); +addTestCase( UTC_JAN_1_2005 ); /* - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getTimezoneOffset()", - NaN, - (new Date(NaN)).getTimezoneOffset() ); + new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getTimezoneOffset.length", - 0, - Date.prototype.getTimezoneOffset.length ); + new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); */ - test(); -function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getTimezoneOffset()", - (t - LocalTime(t)) / msPerMinute, - (new Date(t)).getTimezoneOffset() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function addTestCase( t ) { + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.22-8.js b/mozilla/js/tests/ecma/Date/15.9.5.22-8.js index 87e7ced55d0..bc5c8d04a28 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.22-8.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.22-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,76 +35,63 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.22.js - ECMA Section: 15.9.5.22 - Description: Date.prototype.getTimezoneOffset + File Name: 15.9.5.22.js + ECMA Section: 15.9.5.22 + Description: Date.prototype.getTimezoneOffset - Returns the difference between local time and UTC time in minutes. - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return (t - LocalTime(t)) / msPerMinute. + Returns the difference between local time and UTC time in minutes. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return (t - LocalTime(t)) / msPerMinute. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.22"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTimezoneOffset()"; +var SECTION = "15.9.5.22"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTimezoneOffset()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +new TestCase( SECTION, + "(new Date(NaN)).getTimezoneOffset()", + NaN, + (new Date(NaN)).getTimezoneOffset() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getTimezoneOffset()", - NaN, - (new Date(NaN)).getTimezoneOffset() ); +new TestCase( SECTION, + "Date.prototype.getTimezoneOffset.length", + 0, + Date.prototype.getTimezoneOffset.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getTimezoneOffset.length", - 0, - Date.prototype.getTimezoneOffset.length ); - test(); function addTestCase( t ) { - for ( m = 0; m <= 1000; m+=100 ) { - t++; - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getTimezoneOffset()", - (t - LocalTime(t)) / msPerMinute, - (new Date(t)).getTimezoneOffset() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( m = 0; m <= 1000; m+=100 ) { + t++; + new TestCase( SECTION, + "(new Date("+t+")).getTimezoneOffset()", + (t - LocalTime(t)) / msPerMinute, + (new Date(t)).getTimezoneOffset() ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-1.js b/mozilla/js/tests/ecma/Date/15.9.5.23-1.js index 46f221e110b..284d0c392cd 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,139 +35,122 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - var testcases = new Array(); - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - - getTestCases(); - test(); - -function getTestCases() { - var now = "now"; - addTestCase( 0, 0 ); +var now = "now"; +addTestCase( 0, 0 ); /* - addTestCase( now, -2208988800000 ); - addTestCase( now, -86400000 ); - addTestCase( now, 946684800000 ); + addTestCase( now, -2208988800000 ); + addTestCase( now, -86400000 ); + addTestCase( now, 946684800000 ); - // this daylight savings case fails -- need to fix date test functions + // this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, -2208988800000 ); - addTestCase( now, 946684800000 ); +addTestCase( now, -2208988800000 ); +addTestCase( now, 946684800000 ); - // this daylight savings case fails -- need to fix date test functions +// this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, 0 ); - addTestCase( now, String( TIME_1900 ) ); - addTestCase( now, String( TZ_DIFF* msPerHour ) ); - addTestCase( now, String( TIME_2000 ) ); +addTestCase( now, 0 ); +addTestCase( now, String( TIME_1900 ) ); +addTestCase( now, String( TZ_DIFF* msPerHour ) ); +addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } + function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-10.js b/mozilla/js/tests/ecma/Date/15.9.5.23-10.js index 35f2b3792bd..8789fb14685 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-10.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-10.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,138 +35,121 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - var testcases = new Array(); - - getTestCases(); - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - test(); - -function getTestCases() { - var now = "now"; - addTestCase( now, -2208988800000 ); +var now = "now"; +addTestCase( now, -2208988800000 ); /* - addTestCase( now, -86400000 ); - addTestCase( now, 946684800000 ); + addTestCase( now, -86400000 ); + addTestCase( now, 946684800000 ); - // this daylight savings case fails -- need to fix date test functions + // this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, -2208988800000 ); - addTestCase( now, 946684800000 ); +addTestCase( now, -2208988800000 ); +addTestCase( now, 946684800000 ); - // this daylight savings case fails -- need to fix date test functions +// this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, 0 ); - addTestCase( now, String( TIME_1900 ) ); - addTestCase( now, String( TZ_DIFF* msPerHour ) ); - addTestCase( now, String( TIME_2000 ) ); +addTestCase( now, 0 ); +addTestCase( now, String( TIME_1900 ) ); +addTestCase( now, String( TZ_DIFF* msPerHour ) ); +addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } + function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-11.js b/mozilla/js/tests/ecma/Date/15.9.5.23-11.js index 713ace56af6..b01b2c2f8ad 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-11.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-11.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,137 +35,121 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - var testcases = new Array(); - getTestCases(); - - test(); - -function getTestCases() { - var now = "now"; - addTestCase( now, -86400000 ); +var now = "now"; +addTestCase( now, -86400000 ); /* - addTestCase( now, 946684800000 ); + addTestCase( now, 946684800000 ); - // this daylight savings case fails -- need to fix date test functions + // this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, -2208988800000 ); - addTestCase( now, 946684800000 ); +addTestCase( now, -2208988800000 ); +addTestCase( now, 946684800000 ); - // this daylight savings case fails -- need to fix date test functions +// this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, 0 ); - addTestCase( now, String( TIME_1900 ) ); - addTestCase( now, String( TZ_DIFF* msPerHour ) ); - addTestCase( now, String( TIME_2000 ) ); +addTestCase( now, 0 ); +addTestCase( now, String( TIME_1900 ) ); +addTestCase( now, String( TZ_DIFF* msPerHour ) ); +addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); + function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-12.js b/mozilla/js/tests/ecma/Date/15.9.5.23-12.js index c3c2e6e4703..8ca123021c0 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-12.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-12.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,135 +35,116 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - var testcases = new Array(); - getTestCases(); - - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - test(); - -function getTestCases() { - var now = "now"; - addTestCase( now, 946684800000 ); +var now = "now"; +addTestCase( now, 946684800000 ); /* - // this daylight savings case fails -- need to fix date test functions +// this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, -2208988800000 ); - addTestCase( now, 946684800000 ); +addTestCase( now, -2208988800000 ); +addTestCase( now, 946684800000 ); - // this daylight savings case fails -- need to fix date test functions +// this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, 0 ); - addTestCase( now, String( TIME_1900 ) ); - addTestCase( now, String( TZ_DIFF* msPerHour ) ); - addTestCase( now, String( TIME_2000 ) ); +addTestCase( now, 0 ); +addTestCase( now, String( TIME_1900 ) ); +addTestCase( now, String( TZ_DIFF* msPerHour ) ); +addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-13.js b/mozilla/js/tests/ecma/Date/15.9.5.23-13.js index cb19f2a4405..54058b6faf7 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-13.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-13.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,132 +35,113 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - - var testcases = new Array(); - getTestCases(); - test(); - -function getTestCases() { - var now = "now"; - addTestCase( now, -2208988800000 ); +var now = "now"; +addTestCase( now, -2208988800000 ); /* - addTestCase( now, 946684800000 ); + addTestCase( now, 946684800000 ); - // this daylight savings case fails -- need to fix date test functions + // this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, 0 ); - addTestCase( now, String( TIME_1900 ) ); - addTestCase( now, String( TZ_DIFF* msPerHour ) ); - addTestCase( now, String( TIME_2000 ) ); +addTestCase( now, 0 ); +addTestCase( now, String( TIME_1900 ) ); +addTestCase( now, String( TZ_DIFF* msPerHour ) ); +addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-14.js b/mozilla/js/tests/ecma/Date/15.9.5.23-14.js index 6d806cabf1f..d6b6872b377 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-14.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-14.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,130 +35,111 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-14"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-14"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - - var testcases = new Array(); - getTestCases(); - test(); - -function getTestCases() { - var now = "now"; - addTestCase( now, 946684800000 ); +var now = "now"; +addTestCase( now, 946684800000 ); /* - // this daylight savings case fails -- need to fix date test functions +// this daylight savings case fails -- need to fix date test functions // addTestCase( now, -69609600000 ); - addTestCase( now, 0 ); - addTestCase( now, String( TIME_1900 ) ); - addTestCase( now, String( TZ_DIFF* msPerHour ) ); - addTestCase( now, String( TIME_2000 ) ); +addTestCase( now, 0 ); +addTestCase( now, String( TIME_1900 ) ); +addTestCase( now, String( TZ_DIFF* msPerHour ) ); +addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-15.js b/mozilla/js/tests/ecma/Date/15.9.5.23-15.js index b2a06586d6f..ef3bd452ce7 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-15.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-15.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,126 +35,108 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - var testcases = new Array(); - getTestCases(); - test(); - -function getTestCases() { - var now = "now"; - addTestCase( now, 0 ); +var now = "now"; +addTestCase( now, 0 ); /* - addTestCase( now, String( TIME_1900 ) ); - addTestCase( now, String( TZ_DIFF* msPerHour ) ); - addTestCase( now, String( TIME_2000 ) ); + addTestCase( now, String( TIME_1900 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-16.js b/mozilla/js/tests/ecma/Date/15.9.5.23-16.js index 67b685cac40..e19181e71be 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-16.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-16.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,125 +35,107 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - var testcases = new Array(); - getTestCases(); - test(); - -function getTestCases() { - var now = "now"; - addTestCase( now, String( TIME_1900 ) ); +var now = "now"; +addTestCase( now, String( TIME_1900 ) ); /* - addTestCase( now, String( TZ_DIFF* msPerHour ) ); - addTestCase( now, String( TIME_2000 ) ); + addTestCase( now, String( TZ_DIFF* msPerHour ) ); + addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-17.js b/mozilla/js/tests/ecma/Date/15.9.5.23-17.js index 19dcf43f99d..dcc5780d75f 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-17.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-17.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,124 +35,106 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - var testcases = new Array(); - getTestCases(); - test(); - -function getTestCases() { - var now = "now"; - addTestCase( now, String( TZ_DIFF* msPerHour ) ); +var now = "now"; +addTestCase( now, String( TZ_DIFF* msPerHour ) ); /* - addTestCase( now, String( TIME_2000 ) ); + addTestCase( now, String( TIME_2000 ) ); */ -} + +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-18.js b/mozilla/js/tests/ecma/Date/15.9.5.23-18.js index cf916003c95..554d35e23f0 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-18.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-18.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,121 +35,104 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-1.js - ECMA Section: 15.9.5.23 Date.prototype.setTime(time) - Description: + File Name: 15.9.5.23-1.js + ECMA Section: 15.9.5.23 Date.prototype.setTime(time) + Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); +writeHeaderToLog( SECTION + " Date.prototype.setTime(time)"); - var testcases = new Array(); - getTestCases(); - test(); +var now = "now"; +addTestCase( now, String( TIME_2000 ) ); -function getTestCases() { - var now = "now"; - addTestCase( now, String( TIME_2000 ) ); -} +test(); function addTestCase( startTime, setTime ) { - if ( startTime == "now" ) { - DateCase = new Date(); - } else { - DateCase = new Date( startTime ); - } + if ( startTime == "now" ) { + DateCase = new Date(); + } else { + DateCase = new Date( startTime ); + } + + DateCase.setTime( setTime ); + var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; + var UTCDate = UTCDateFromTime ( Number(setTime) ); + var LocalDate = LocalDateFromTime( Number(setTime) ); - DateCase.setTime( setTime ); - var DateString = "var d = new Date("+startTime+"); d.setTime("+setTime+"); d" ; - var UTCDate = UTCDateFromTime ( Number(setTime) ); - var LocalDate = LocalDateFromTime( Number(setTime) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes, DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds, DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); - return (d); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-2.js b/mozilla/js/tests/ecma/Date/15.9.5.23-2.js index 37b540d0e54..7d0606a2345 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,80 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-2.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); - - test_times = new Array( now, TIME_1970, TIME_1900, TIME_2000 ); +test_times = new Array( now, TIME_1970, TIME_1900, TIME_2000 ); - for ( var j = 0; j < test_times.length; j++ ) { - addTestCase( new Date(now), test_times[j] ); - } +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(now), test_times[j] ); +} - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).setTime()", - NaN, - (new Date(NaN)).setTime() ); +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.setTime.length", - 1, - Date.prototype.setTime.length ); - test(); function addTestCase( d, t ) { - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+t+")", - t, - d.setTime(t) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1.1)+")", - TimeClip(t+1.1), - d.setTime(t+1.1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1)+")", - t+1, - d.setTime(t+1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-1)+")", - t-1, - d.setTime(t-1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", - t-TZ_ADJUST, - d.setTime(t-TZ_ADJUST) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", - t+TZ_ADJUST, - d.setTime(t+TZ_ADJUST) ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-3-n.js b/mozilla/js/tests/ecma/Date/15.9.5.23-3-n.js index a0da4db6cf6..7161a1e8ed2 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-3-n.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,43 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-3-n.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: 15.9.5.23-3-n.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var MYDATE = new MyDate(TIME_1970); - var MYDATE = new MyDate(TIME_1970); +DESCRIPTION = "MYDATE.setTime(TIME_2000)"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, - "MYDATE.setTime(TIME_2000)", - "error", - MYDATE.setTime(TIME_2000) ); +new TestCase( SECTION, + "MYDATE.setTime(TIME_2000)", + "error", + eval("MYDATE.setTime(TIME_2000)") ); + +test(); function MyDate(value) { - this.value = value; - this.setTime = Date.prototype.setTime; - return this; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + this.value = value; + this.setTime = Date.prototype.setTime; + return this; } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-4.js b/mozilla/js/tests/ecma/Date/15.9.5.23-4.js index d1905e099f9..52ccf0457da 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,108 +35,94 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-2.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, - UTC_FEB_29_2000, UTC_JAN_1_2005 ); +test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); - for ( var j = 0; j < test_times.length; j++ ) { - addTestCase( new Date(time), test_times[j] ); - } +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(time), test_times[j] ); +} - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).setTime()", - NaN, - (new Date(NaN)).setTime() ); +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.setTime.length", - 1, - Date.prototype.setTime.length ); - test(); +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); function addTestCase( d, t ) { - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+t+")", - t, - d.setTime(t) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1.1)+")", - TimeClip(t+1.1), - d.setTime(t+1.1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1)+")", - t+1, - d.setTime(t+1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-1)+")", - t-1, - d.setTime(t-1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", - t-TZ_ADJUST, - d.setTime(t-TZ_ADJUST) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", - t+TZ_ADJUST, - d.setTime(t+TZ_ADJUST) ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-5.js b/mozilla/js/tests/ecma/Date/15.9.5.23-5.js index 1cd47300b32..f2b02c84cff 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,108 +35,95 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-2.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, - UTC_FEB_29_2000, UTC_JAN_1_2005 ); +test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); - for ( var j = 0; j < test_times.length; j++ ) { - addTestCase( new Date(TIME_1970), test_times[j] ); - } +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_1970), test_times[j] ); +} - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).setTime()", - NaN, - (new Date(NaN)).setTime() ); +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.setTime.length", - 1, - Date.prototype.setTime.length ); - test(); function addTestCase( d, t ) { - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+t+")", - t, - d.setTime(t) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1.1)+")", - TimeClip(t+1.1), - d.setTime(t+1.1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1)+")", - t+1, - d.setTime(t+1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-1)+")", - t-1, - d.setTime(t-1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", - t-TZ_ADJUST, - d.setTime(t-TZ_ADJUST) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", - t+TZ_ADJUST, - d.setTime(t+TZ_ADJUST) ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-6.js b/mozilla/js/tests/ecma/Date/15.9.5.23-6.js index 9f9e4663150..1672763ae2b 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,108 +35,94 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-2.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, - UTC_FEB_29_2000, UTC_JAN_1_2005 ); +test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); - for ( var j = 0; j < test_times.length; j++ ) { - addTestCase( new Date(TIME_1900), test_times[j] ); - } +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_1900), test_times[j] ); +} - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).setTime()", - NaN, - (new Date(NaN)).setTime() ); +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.setTime.length", - 1, - Date.prototype.setTime.length ); - test(); +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); function addTestCase( d, t ) { - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+t+")", - t, - d.setTime(t) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1.1)+")", - TimeClip(t+1.1), - d.setTime(t+1.1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1)+")", - t+1, - d.setTime(t+1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-1)+")", - t-1, - d.setTime(t-1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", - t-TZ_ADJUST, - d.setTime(t-TZ_ADJUST) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", - t+TZ_ADJUST, - d.setTime(t+TZ_ADJUST) ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-7.js b/mozilla/js/tests/ecma/Date/15.9.5.23-7.js index 2062f18ce4e..408000957e3 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,108 +35,95 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-2.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, - UTC_FEB_29_2000, UTC_JAN_1_2005 ); +test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); - for ( var j = 0; j < test_times.length; j++ ) { - addTestCase( new Date(TIME_2000), test_times[j] ); - } +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(TIME_2000), test_times[j] ); +} - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).setTime()", - NaN, - (new Date(NaN)).setTime() ); +new TestCase( SECTION, + "(new Date(NaN)).setTime()", + NaN, + (new Date(NaN)).setTime() ); + +new TestCase( SECTION, + "Date.prototype.setTime.length", + 1, + Date.prototype.setTime.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.setTime.length", - 1, - Date.prototype.setTime.length ); - test(); function addTestCase( d, t ) { - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+t+")", - t, - d.setTime(t) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1.1)+")", - TimeClip(t+1.1), - d.setTime(t+1.1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1)+")", - t+1, - d.setTime(t+1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-1)+")", - t-1, - d.setTime(t-1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", - t-TZ_ADJUST, - d.setTime(t-TZ_ADJUST) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", - t+TZ_ADJUST, - d.setTime(t+TZ_ADJUST) ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-8.js b/mozilla/js/tests/ecma/Date/15.9.5.23-8.js index 41b590a906a..daaabe7d6a8 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-8.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,97 +35,84 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-2.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 - - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, - UTC_FEB_29_2000, UTC_JAN_1_2005 ); +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); - for ( var j = 0; j < test_times.length; j++ ) { - addTestCase( new Date(UTC_FEB_29_2000), test_times[j] ); - } +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(UTC_FEB_29_2000), test_times[j] ); +} + +test(); - test(); function addTestCase( d, t ) { - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+t+")", - t, - d.setTime(t) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1.1)+")", - TimeClip(t+1.1), - d.setTime(t+1.1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1)+")", - t+1, - d.setTime(t+1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-1)+")", - t-1, - d.setTime(t-1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", - t-TZ_ADJUST, - d.setTime(t-TZ_ADJUST) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", - t+TZ_ADJUST, - d.setTime(t+TZ_ADJUST) ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.23-9.js b/mozilla/js/tests/ecma/Date/15.9.5.23-9.js index 13f4c81f9f6..12a42e5a59b 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.23-9.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.23-9.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,98 +35,85 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.23-2.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: 15.9.5.23-2.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.23-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.setTime()"; +var SECTION = "15.9.5.23-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.setTime()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, - UTC_FEB_29_2000, UTC_JAN_1_2005 ); +test_times = new Array( now, time, TIME_1970, TIME_1900, TIME_2000, + UTC_FEB_29_2000, UTC_JAN_1_2005 ); - for ( var j = 0; j < test_times.length; j++ ) { - addTestCase( new Date(UTC_JAN_1_2005), test_times[j] ); - } +for ( var j = 0; j < test_times.length; j++ ) { + addTestCase( new Date(UTC_JAN_1_2005), test_times[j] ); +} + +test(); - test(); function addTestCase( d, t ) { - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+t+")", - t, - d.setTime(t) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+t+")", + t, + d.setTime(t) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1.1)+")", - TimeClip(t+1.1), - d.setTime(t+1.1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1.1)+")", + TimeClip(t+1.1), + d.setTime(t+1.1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+1)+")", - t+1, - d.setTime(t+1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+1)+")", + t+1, + d.setTime(t+1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-1)+")", - t-1, - d.setTime(t-1) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-1)+")", + t-1, + d.setTime(t-1) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", - t-TZ_ADJUST, - d.setTime(t-TZ_ADJUST) ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t-TZ_ADJUST)+")", + t-TZ_ADJUST, + d.setTime(t-TZ_ADJUST) ); - testcases[tc++] = new TestCase( SECTION, - "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", - t+TZ_ADJUST, - d.setTime(t+TZ_ADJUST) ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "( "+d+" ).setTime("+(t+TZ_ADJUST)+")", + t+TZ_ADJUST, + d.setTime(t+TZ_ADJUST) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.24-1.js b/mozilla/js/tests/ecma/Date/15.9.5.24-1.js index b6de886fab1..97d04befc7f 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.24-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.24-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,133 +35,116 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.24-1.js - ECMA Section: 15.9.5.24 Date.prototype.setTime(time) - Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var TITLE = "Date.prototype.setTime" - var SECTION = "15.9.5.24-1"; - var VERSION = "ECMA_1"; - startTest(); +var TITLE = "Date.prototype.setTime" +var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - - addTestCase( 0, 0 ); +addTestCase( 0, 0 ); /* - addTestCase( 0, -86400000 ); - addTestCase( 0, -2208988800000 ); - addTestCase( 0, 946684800000 ); + addTestCase( 0, -86400000 ); + addTestCase( 0, -2208988800000 ); + addTestCase( 0, 946684800000 ); // This test case is incorrect. Need to fix the DaylightSavings functions in // shell.js for this to work properly. // addTestCase( 0, -69609600000 ); // addTestCase( 0, "-69609600000" ); - addTestCase( 0, "0" ); - addTestCase( 0, "-2208988800000" ); - addTestCase( 0, "-86400000" ); - addTestCase( 0, "946684800000" ); +addTestCase( 0, "0" ); +addTestCase( 0, "-2208988800000" ); +addTestCase( 0, "-86400000" ); +addTestCase( 0, "946684800000" ); */ -} + +test(); + function addTestCase( startms, newms ) { - var DateCase = new Date( startms ); - DateCase.setMilliseconds( newms ); - var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; - var UTCDate = UTCDateFromTime( Number(newms) ); - var LocalDate = LocalDateFromTime( Number(newms) ); + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.24-2.js b/mozilla/js/tests/ecma/Date/15.9.5.24-2.js index 4ac264cf9e0..8bb17caf7ac 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.24-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.24-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,132 +35,115 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.24-1.js - ECMA Section: 15.9.5.24 Date.prototype.setTime(time) - Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var TITLE = "Date.prototype.setTime" - var SECTION = "15.9.5.24-1"; - var VERSION = "ECMA_1"; - startTest(); +var TITLE = "Date.prototype.setTime" +var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - - addTestCase( 0, -86400000 ); +addTestCase( 0, -86400000 ); /* - addTestCase( 0, -2208988800000 ); - addTestCase( 0, 946684800000 ); + addTestCase( 0, -2208988800000 ); + addTestCase( 0, 946684800000 ); // This test case is incorrect. Need to fix the DaylightSavings functions in // shell.js for this to work properly. // addTestCase( 0, -69609600000 ); // addTestCase( 0, "-69609600000" ); - addTestCase( 0, "0" ); - addTestCase( 0, "-2208988800000" ); - addTestCase( 0, "-86400000" ); - addTestCase( 0, "946684800000" ); +addTestCase( 0, "0" ); +addTestCase( 0, "-2208988800000" ); +addTestCase( 0, "-86400000" ); +addTestCase( 0, "946684800000" ); */ -} + +test(); + function addTestCase( startms, newms ) { - var DateCase = new Date( startms ); - DateCase.setMilliseconds( newms ); - var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; - var UTCDate = UTCDateFromTime( Number(newms) ); - var LocalDate = LocalDateFromTime( Number(newms) ); + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.24-3.js b/mozilla/js/tests/ecma/Date/15.9.5.24-3.js index 0d3a472c576..5e87e69d399 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.24-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.24-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,131 +35,114 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.24-1.js - ECMA Section: 15.9.5.24 Date.prototype.setTime(time) - Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var TITLE = "Date.prototype.setTime" - var SECTION = "15.9.5.24-1"; - var VERSION = "ECMA_1"; - startTest(); +var TITLE = "Date.prototype.setTime" +var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - - addTestCase( 0, -2208988800000 ); +addTestCase( 0, -2208988800000 ); /* - addTestCase( 0, 946684800000 ); + addTestCase( 0, 946684800000 ); // This test case is incorrect. Need to fix the DaylightSavings functions in // shell.js for this to work properly. // addTestCase( 0, -69609600000 ); // addTestCase( 0, "-69609600000" ); - addTestCase( 0, "0" ); - addTestCase( 0, "-2208988800000" ); - addTestCase( 0, "-86400000" ); - addTestCase( 0, "946684800000" ); +addTestCase( 0, "0" ); +addTestCase( 0, "-2208988800000" ); +addTestCase( 0, "-86400000" ); +addTestCase( 0, "946684800000" ); */ -} + +test(); + function addTestCase( startms, newms ) { - var DateCase = new Date( startms ); - DateCase.setMilliseconds( newms ); - var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; - var UTCDate = UTCDateFromTime( Number(newms) ); - var LocalDate = LocalDateFromTime( Number(newms) ); + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.24-4.js b/mozilla/js/tests/ecma/Date/15.9.5.24-4.js index 55652de03c6..f946223a7cb 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.24-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.24-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.24-1.js - ECMA Section: 15.9.5.24 Date.prototype.setTime(time) - Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var TITLE = "Date.prototype.setTime" - var SECTION = "15.9.5.24-1"; - var VERSION = "ECMA_1"; - startTest(); +var TITLE = "Date.prototype.setTime" +var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - - addTestCase( 0, 946684800000 ); +addTestCase( 0, 946684800000 ); /* // This test case is incorrect. Need to fix the DaylightSavings functions in @@ -82,82 +65,83 @@ function getTestCases() { // addTestCase( 0, -69609600000 ); // addTestCase( 0, "-69609600000" ); - addTestCase( 0, "0" ); - addTestCase( 0, "-2208988800000" ); - addTestCase( 0, "-86400000" ); - addTestCase( 0, "946684800000" ); +addTestCase( 0, "0" ); +addTestCase( 0, "-2208988800000" ); +addTestCase( 0, "-86400000" ); +addTestCase( 0, "946684800000" ); */ -} + +test(); + function addTestCase( startms, newms ) { - var DateCase = new Date( startms ); - DateCase.setMilliseconds( newms ); - var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; - var UTCDate = UTCDateFromTime( Number(newms) ); - var LocalDate = LocalDateFromTime( Number(newms) ); + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.24-5.js b/mozilla/js/tests/ecma/Date/15.9.5.24-5.js index 70e38c71c63..90069e4130c 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.24-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.24-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,123 +35,106 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.24-1.js - ECMA Section: 15.9.5.24 Date.prototype.setTime(time) - Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var TITLE = "Date.prototype.setTime" - var SECTION = "15.9.5.24-1"; - var VERSION = "ECMA_1"; - startTest(); +var TITLE = "Date.prototype.setTime" +var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - - addTestCase( 0, "0" ); +addTestCase( 0, "0" ); /* - addTestCase( 0, "-2208988800000" ); - addTestCase( 0, "-86400000" ); - addTestCase( 0, "946684800000" ); + addTestCase( 0, "-2208988800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); */ -} + +test(); + function addTestCase( startms, newms ) { - var DateCase = new Date( startms ); - DateCase.setMilliseconds( newms ); - var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; - var UTCDate = UTCDateFromTime( Number(newms) ); - var LocalDate = LocalDateFromTime( Number(newms) ); + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.24-6.js b/mozilla/js/tests/ecma/Date/15.9.5.24-6.js index 2f0326700df..26a38bf62bb 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.24-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.24-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,122 +35,105 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.24-1.js - ECMA Section: 15.9.5.24 Date.prototype.setTime(time) - Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var TITLE = "Date.prototype.setTime" - var SECTION = "15.9.5.24-1"; - var VERSION = "ECMA_1"; - startTest(); +var TITLE = "Date.prototype.setTime" +var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - - addTestCase( 0, "-2208988800000" ); +addTestCase( 0, "-2208988800000" ); /* - addTestCase( 0, "-86400000" ); - addTestCase( 0, "946684800000" ); + addTestCase( 0, "-86400000" ); + addTestCase( 0, "946684800000" ); */ -} + +test(); + function addTestCase( startms, newms ) { - var DateCase = new Date( startms ); - DateCase.setMilliseconds( newms ); - var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; - var UTCDate = UTCDateFromTime( Number(newms) ); - var LocalDate = LocalDateFromTime( Number(newms) ); + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.24-7.js b/mozilla/js/tests/ecma/Date/15.9.5.24-7.js index 45fb7a18099..436987a7ad7 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.24-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.24-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,121 +35,104 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.24-1.js - ECMA Section: 15.9.5.24 Date.prototype.setTime(time) - Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var TITLE = "Date.prototype.setTime" - var SECTION = "15.9.5.24-1"; - var VERSION = "ECMA_1"; - startTest(); +var TITLE = "Date.prototype.setTime" +var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - - addTestCase( 0, "-86400000" ); +addTestCase( 0, "-86400000" ); /* - addTestCase( 0, "946684800000" ); + addTestCase( 0, "946684800000" ); */ -} + +test(); + function addTestCase( startms, newms ) { - var DateCase = new Date( startms ); - DateCase.setMilliseconds( newms ); - var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; - var UTCDate = UTCDateFromTime( Number(newms) ); - var LocalDate = LocalDateFromTime( Number(newms) ); + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.24-8.js b/mozilla/js/tests/ecma/Date/15.9.5.24-8.js index 5db2766af90..d7cc324e346 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.24-8.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.24-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,117 +35,100 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.24-1.js - ECMA Section: 15.9.5.24 Date.prototype.setTime(time) - Description: - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + File Name: 15.9.5.24-1.js + ECMA Section: 15.9.5.24 Date.prototype.setTime(time) + Description: + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var TITLE = "Date.prototype.setTime" - var SECTION = "15.9.5.24-1"; - var VERSION = "ECMA_1"; - startTest(); +var TITLE = "Date.prototype.setTime" +var SECTION = "15.9.5.24-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); +writeHeaderToLog( SECTION + " Date.prototype.setMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); +addTestCase( 0, "946684800000" ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - addTestCase( 0, "946684800000" ); -} function addTestCase( startms, newms ) { - var DateCase = new Date( startms ); - DateCase.setMilliseconds( newms ); - var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; - var UTCDate = UTCDateFromTime( Number(newms) ); - var LocalDate = LocalDateFromTime( Number(newms) ); + var DateCase = new Date( startms ); + DateCase.setMilliseconds( newms ); + var DateString = "var date = new Date("+ startms +"); date.setMilliseconds("+ newms +"); date"; + var UTCDate = UTCDateFromTime( Number(newms) ); + var LocalDate = LocalDateFromTime( Number(newms) ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.25-1.js b/mozilla/js/tests/ecma/Date/15.9.5.25-1.js index d656a0a8c34..0af879d8f9c 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.25-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.25-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 15.9.5.25-1.js ECMA Section: 15.9.5.25 Date.prototype.setUTCMilliseconds(ms) @@ -53,25 +55,6 @@ writeHeaderToLog( SECTION + " Date.prototype.setUTCMilliseconds(ms)"); - var testcases = new Array(); - getTestCases(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { addNewTestCase( 0, 0, "TDATE = new Date(0);(TDATE).setUTCMilliseconds(0);TDATE", UTCDateFromTime(SetUTCMilliseconds(0,0)), LocalDateFromTime(SetUTCMilliseconds(0,0)) ); @@ -125,39 +108,40 @@ function getTestCases() { addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('946684800000');TEST_DATE", UTCDateFromTime(946684800000), LocalDateFromTime(946684800000) ); addNewTestCase( "TEST_DATE = new Date(0);(TEST_DATE).setMilliseconds('-69609600000');TEST_DATE", UTCDateFromTime(-69609600000), LocalDateFromTime(-69609600000) ); */ -} + +test(); + function addNewTestCase( initialTime, ms, DateString, UTCDate, LocalDate) { DateCase = new Date(initialTime); DateCase.setUTCMilliseconds(ms); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, + new TestCase( SECTION, DateString+".toString=Object.prototype.toString;"+DateString+".toString()", "[object Date]", DateCase.toString() ); diff --git a/mozilla/js/tests/ecma/Date/15.9.5.26-1.js b/mozilla/js/tests/ecma/Date/15.9.5.26-1.js index 503b87d07f9..d7937571b7c 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.26-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.26-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,185 +35,168 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 15.9.5.26-1.js - ECMA Section: 15.9.5.26 Date.prototype.setSeconds(sec [,ms]) - Description: + ECMA Section: 15.9.5.26 Date.prototype.setSeconds(sec [,ms]) + Description: - If ms is not specified, this behaves as if ms were specified with the - value getMilliseconds( ). + If ms is not specified, this behaves as if ms were specified with the + value getMilliseconds( ). - 1. Let t be the result of LocalTime(this time value). - 2. Call ToNumber(sec). - 3. If ms is not specified, compute msFromTime(t); otherwise, call - ToNumber(ms). - 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), - Result(3)). - 5. Compute UTC(MakeDate(Day(t), Result(4))). - 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). - 7. Return the value of the [[Value]] property of the this value. + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(sec). + 3. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), + Result(3)). + 5. Compute UTC(MakeDate(Day(t), Result(4))). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.26-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.26-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setSeconds(sec [,ms] )"); +writeHeaderToLog( SECTION + " Date.prototype.setSeconds(sec [,ms] )"); - var testcases = new Array(); - getTestCases(); - test(); +addNewTestCase( 0, 0, 0, + "TDATE = new Date(0);(TDATE).setSeconds(0,0);TDATE", + UTCDateFromTime(SetSeconds(0,0,0)), + LocalDateFromTime(SetSeconds(0,0,0)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( 28800000,59,999, + "TDATE = new Date(28800000);(TDATE).setSeconds(59,999);TDATE", + UTCDateFromTime(SetSeconds(28800000,59,999)), + LocalDateFromTime(SetSeconds(28800000,59,999)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( 28800000,999,999, + "TDATE = new Date(28800000);(TDATE).setSeconds(999,999);TDATE", + UTCDateFromTime(SetSeconds(28800000,999,999)), + LocalDateFromTime(SetSeconds(28800000,999,999)) ); -function getTestCases() { - addNewTestCase( 0, 0, 0, - "TDATE = new Date(0);(TDATE).setSeconds(0,0);TDATE", - UTCDateFromTime(SetSeconds(0,0,0)), - LocalDateFromTime(SetSeconds(0,0,0)) ); +addNewTestCase( 28800000,999, void 0, + "TDATE = new Date(28800000);(TDATE).setSeconds(999);TDATE", + UTCDateFromTime(SetSeconds(28800000,999,0)), + LocalDateFromTime(SetSeconds(28800000,999,0)) ); - addNewTestCase( 28800000,59,999, - "TDATE = new Date(28800000);(TDATE).setSeconds(59,999);TDATE", - UTCDateFromTime(SetSeconds(28800000,59,999)), - LocalDateFromTime(SetSeconds(28800000,59,999)) ); +addNewTestCase( 28800000,-28800, void 0, + "TDATE = new Date(28800000);(TDATE).setSeconds(-28800);TDATE", + UTCDateFromTime(SetSeconds(28800000,-28800)), + LocalDateFromTime(SetSeconds(28800000,-28800)) ); - addNewTestCase( 28800000,999,999, - "TDATE = new Date(28800000);(TDATE).setSeconds(999,999);TDATE", - UTCDateFromTime(SetSeconds(28800000,999,999)), - LocalDateFromTime(SetSeconds(28800000,999,999)) ); +addNewTestCase( 946684800000,1234567,void 0, + "TDATE = new Date(946684800000);(TDATE).setSeconds(1234567);TDATE", + UTCDateFromTime(SetSeconds(946684800000,1234567)), + LocalDateFromTime(SetSeconds(946684800000,1234567)) ); - addNewTestCase( 28800000,999, void 0, - "TDATE = new Date(28800000);(TDATE).setSeconds(999);TDATE", - UTCDateFromTime(SetSeconds(28800000,999,0)), - LocalDateFromTime(SetSeconds(28800000,999,0)) ); - - addNewTestCase( 28800000,-28800, void 0, - "TDATE = new Date(28800000);(TDATE).setSeconds(-28800);TDATE", - UTCDateFromTime(SetSeconds(28800000,-28800)), - LocalDateFromTime(SetSeconds(28800000,-28800)) ); - - addNewTestCase( 946684800000,1234567,void 0, - "TDATE = new Date(946684800000);(TDATE).setSeconds(1234567);TDATE", - UTCDateFromTime(SetSeconds(946684800000,1234567)), - LocalDateFromTime(SetSeconds(946684800000,1234567)) ); - - addNewTestCase( -2208988800000,59,999, - "TDATE = new Date(-2208988800000);(TDATE).setSeconds(59,999);TDATE", - UTCDateFromTime(SetSeconds(-2208988800000,59,999)), - LocalDateFromTime(SetSeconds(-2208988800000,59,999)) ); +addNewTestCase( -2208988800000,59,999, + "TDATE = new Date(-2208988800000);(TDATE).setSeconds(59,999);TDATE", + UTCDateFromTime(SetSeconds(-2208988800000,59,999)), + LocalDateFromTime(SetSeconds(-2208988800000,59,999)) ); /* - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", - UTCDateFromTime(SetUTCMilliseconds(0,-999)), - LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); */ -} -function addNewTestCase( startTime, sec, ms, DateString,UTCDate, LocalDate) { - DateCase = new Date( startTime ); - if ( ms != void 0 ) { - DateCase.setSeconds( sec, ms ); - } else { - DateCase.setSeconds( sec ); - } - var item = testcases.length; +test(); + +function addNewTestCase( startTime, sec, ms, DateString,UTCDate, LocalDate) { + DateCase = new Date( startTime ); + if ( ms != void 0 ) { + DateCase.setSeconds( sec, ms ); + } else { + DateCase.setSeconds( sec ); + } + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetSeconds( t, s, m ) { - var MS = ( m == void 0 ) ? msFromTime(t) : Number( m ); - var TIME = LocalTime( t ); - var SEC = Number(s); - var RESULT4 = MakeTime( HourFromTime( TIME ), - MinFromTime( TIME ), - SEC, - MS ); - var UTC_TIME = UTC(MakeDate(Day(TIME), RESULT4)); - return ( TimeClip(UTC_TIME) ); + var MS = ( m == void 0 ) ? msFromTime(t) : Number( m ); + var TIME = LocalTime( t ); + var SEC = Number(s); + var RESULT4 = MakeTime( HourFromTime( TIME ), + MinFromTime( TIME ), + SEC, + MS ); + var UTC_TIME = UTC(MakeDate(Day(TIME), RESULT4)); + return ( TimeClip(UTC_TIME) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.27-1.js b/mozilla/js/tests/ecma/Date/15.9.5.27-1.js index 8e077c9b219..2eb588c0757 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.27-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.27-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,184 +35,168 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.27-1.js - ECMA Section: 15.9.5.27 Date.prototype.setUTCSeconds(sec [,ms]) - Description: + File Name: 15.9.5.27-1.js + ECMA Section: 15.9.5.27 Date.prototype.setUTCSeconds(sec [,ms]) + Description: - If ms is not specified, this behaves as if ms were specified with the - value getUTCMilliseconds( ). + If ms is not specified, this behaves as if ms were specified with the + value getUTCMilliseconds( ). - 1. Let t be this time value. - 2. Call ToNumber(sec). - 3. If ms is not specified, compute msFromTime(t); otherwise, call - ToNumber(ms) - 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), Result(3)) - 5. Compute MakeDate(Day(t), Result(4)). - 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). - 7. Return the value of the [[Value]] property of the this value. + 1. Let t be this time value. + 2. Call ToNumber(sec). + 3. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms) + 4. Compute MakeTime(HourFromTime(t), MinFromTime(t), Result(2), Result(3)) + 5. Compute MakeDate(Day(t), Result(4)). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.27-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.27-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCSeconds(sec [,ms] )"); +writeHeaderToLog( SECTION + " Date.prototype.setUTCSeconds(sec [,ms] )"); - getTestCases(); - test(); +addNewTestCase( 0, 0, 0, "TDATE = new Date(0);(TDATE).setUTCSeconds(0,0);TDATE", + UTCDateFromTime(SetUTCSeconds(0,0,0)), + LocalDateFromTime(SetUTCSeconds(0,0,0)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( 28800000,59,999, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(59,999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,59,999)), + LocalDateFromTime(SetUTCSeconds(28800000,59,999)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( 28800000,999,999, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999,999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,999,999)), + LocalDateFromTime(SetUTCSeconds(28800000,999,999)) ); -function getTestCases() { - addNewTestCase( 0, 0, 0, "TDATE = new Date(0);(TDATE).setUTCSeconds(0,0);TDATE", - UTCDateFromTime(SetUTCSeconds(0,0,0)), - LocalDateFromTime(SetUTCSeconds(0,0,0)) ); +addNewTestCase( 28800000, 999, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,999,0)), + LocalDateFromTime(SetUTCSeconds(28800000,999,0)) ); - addNewTestCase( 28800000,59,999, - "TDATE = new Date(28800000);(TDATE).setUTCSeconds(59,999);TDATE", - UTCDateFromTime(SetUTCSeconds(28800000,59,999)), - LocalDateFromTime(SetUTCSeconds(28800000,59,999)) ); +addNewTestCase( 28800000, -28800, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCSeconds(-28800);TDATE", + UTCDateFromTime(SetUTCSeconds(28800000,-28800)), + LocalDateFromTime(SetUTCSeconds(28800000,-28800)) ); - addNewTestCase( 28800000,999,999, - "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999,999);TDATE", - UTCDateFromTime(SetUTCSeconds(28800000,999,999)), - LocalDateFromTime(SetUTCSeconds(28800000,999,999)) ); +addNewTestCase( 946684800000, 1234567, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCSeconds(1234567);TDATE", + UTCDateFromTime(SetUTCSeconds(946684800000,1234567)), + LocalDateFromTime(SetUTCSeconds(946684800000,1234567)) ); - addNewTestCase( 28800000, 999, void 0, - "TDATE = new Date(28800000);(TDATE).setUTCSeconds(999);TDATE", - UTCDateFromTime(SetUTCSeconds(28800000,999,0)), - LocalDateFromTime(SetUTCSeconds(28800000,999,0)) ); - - addNewTestCase( 28800000, -28800, void 0, - "TDATE = new Date(28800000);(TDATE).setUTCSeconds(-28800);TDATE", - UTCDateFromTime(SetUTCSeconds(28800000,-28800)), - LocalDateFromTime(SetUTCSeconds(28800000,-28800)) ); - - addNewTestCase( 946684800000, 1234567, void 0, - "TDATE = new Date(946684800000);(TDATE).setUTCSeconds(1234567);TDATE", - UTCDateFromTime(SetUTCSeconds(946684800000,1234567)), - LocalDateFromTime(SetUTCSeconds(946684800000,1234567)) ); - - addNewTestCase( -2208988800000,59,999, - "TDATE = new Date(-2208988800000);(TDATE).setUTCSeconds(59,999);TDATE", - UTCDateFromTime(SetUTCSeconds(-2208988800000,59,999)), - LocalDateFromTime(SetUTCSeconds(-2208988800000,59,999)) ); +addNewTestCase( -2208988800000,59,999, + "TDATE = new Date(-2208988800000);(TDATE).setUTCSeconds(59,999);TDATE", + UTCDateFromTime(SetUTCSeconds(-2208988800000,59,999)), + LocalDateFromTime(SetUTCSeconds(-2208988800000,59,999)) ); /* - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", - UTCDateFromTime(SetUTCMilliseconds(0,-999)), - LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); */ -} + +test(); + function addNewTestCase( startTime, sec, ms, DateString, UTCDate, LocalDate) { - DateCase = new Date( startTime ); - if ( ms == void 0) { - DateCase.setSeconds( sec ); - } else { - DateCase.setSeconds( sec, ms ); - } + DateCase = new Date( startTime ); + if ( ms == void 0) { + DateCase.setSeconds( sec ); + } else { + DateCase.setSeconds( sec, ms ); + } - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCSeconds( t, s, m ) { - var TIME = t; - var SEC = Number(s); - var MS = ( m == void 0 ) ? msFromTime(TIME) : Number( m ); - var RESULT4 = MakeTime( HourFromTime( TIME ), - MinFromTime( TIME ), - SEC, - MS ); - return ( TimeClip(MakeDate(Day(TIME), RESULT4)) ); + var TIME = t; + var SEC = Number(s); + var MS = ( m == void 0 ) ? msFromTime(TIME) : Number( m ); + var RESULT4 = MakeTime( HourFromTime( TIME ), + MinFromTime( TIME ), + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME), RESULT4)) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.28-1.js b/mozilla/js/tests/ecma/Date/15.9.5.28-1.js index f03796d3107..2966d1f4c35 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.28-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.28-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,198 +35,181 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.28-1.js - ECMA Section: 15.9.5.28 Date.prototype.setMinutes(min [, sec [, ms ]] ) - Description: - If sec is not specified, this behaves as if sec were specified with the - value getSeconds ( ). + File Name: 15.9.5.28-1.js + ECMA Section: 15.9.5.28 Date.prototype.setMinutes(min [, sec [, ms ]] ) + Description: + If sec is not specified, this behaves as if sec were specified with the + value getSeconds ( ). - If ms is not specified, this behaves as if ms were specified with the - value getMilliseconds( ). + If ms is not specified, this behaves as if ms were specified with the + value getMilliseconds( ). - 1. Let t be the result of LocalTime(this time value). - 2. Call ToNumber(min). - 3. If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec). - 4. If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms). - 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). - 6. Compute UTC(MakeDate(Day(t), Result(5))). - 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). - 8. Return the value of the [[Value]] property of the this value. + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(min). + 3. If sec is not specified, compute SecFromTime(t); otherwise, call ToNumber(sec). + 4. If ms is not specified, compute msFromTime(t); otherwise, call ToNumber(ms). + 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). + 6. Compute UTC(MakeDate(Day(t), Result(5))). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.28-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.28-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMinutes(sec [,ms] )"); +writeHeaderToLog( SECTION + " Date.prototype.setMinutes(sec [,ms] )"); - getTestCases(); - test(); +addNewTestCase( 0, 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setMinutes(0);TDATE", + UTCDateFromTime(SetMinutes(0,0,0,0)), + LocalDateFromTime(SetMinutes(0,0,0,0)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( 28800000, 59, 59, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(59,59);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,59)), + LocalDateFromTime(SetMinutes(28800000,59,59)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( 28800000, 59, 59, 999, + "TDATE = new Date(28800000);(TDATE).setMinutes(59,59,999);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,59,999)), + LocalDateFromTime(SetMinutes(28800000,59,59,999)) ); -function getTestCases() { - addNewTestCase( 0, 0, void 0, void 0, - "TDATE = new Date(0);(TDATE).setMinutes(0);TDATE", - UTCDateFromTime(SetMinutes(0,0,0,0)), - LocalDateFromTime(SetMinutes(0,0,0,0)) ); +addNewTestCase( 28800000, 59, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(59);TDATE", + UTCDateFromTime(SetMinutes(28800000,59,0)), + LocalDateFromTime(SetMinutes(28800000,59,0)) ); - addNewTestCase( 28800000, 59, 59, void 0, - "TDATE = new Date(28800000);(TDATE).setMinutes(59,59);TDATE", - UTCDateFromTime(SetMinutes(28800000,59,59)), - LocalDateFromTime(SetMinutes(28800000,59,59)) ); +addNewTestCase( 28800000, -480, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setMinutes(-480);TDATE", + UTCDateFromTime(SetMinutes(28800000,-480)), + LocalDateFromTime(SetMinutes(28800000,-480)) ); - addNewTestCase( 28800000, 59, 59, 999, - "TDATE = new Date(28800000);(TDATE).setMinutes(59,59,999);TDATE", - UTCDateFromTime(SetMinutes(28800000,59,59,999)), - LocalDateFromTime(SetMinutes(28800000,59,59,999)) ); +addNewTestCase( 946684800000, 1234567, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setMinutes(1234567);TDATE", + UTCDateFromTime(SetMinutes(946684800000,1234567)), + LocalDateFromTime(SetMinutes(946684800000,1234567)) ); - addNewTestCase( 28800000, 59, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setMinutes(59);TDATE", - UTCDateFromTime(SetMinutes(28800000,59,0)), - LocalDateFromTime(SetMinutes(28800000,59,0)) ); +addNewTestCase( -2208988800000,59, 59, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59);TDATE", + UTCDateFromTime(SetMinutes(-2208988800000,59,59)), + LocalDateFromTime(SetMinutes(-2208988800000,59,59)) ); - addNewTestCase( 28800000, -480, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setMinutes(-480);TDATE", - UTCDateFromTime(SetMinutes(28800000,-480)), - LocalDateFromTime(SetMinutes(28800000,-480)) ); - - addNewTestCase( 946684800000, 1234567, void 0, void 0, - "TDATE = new Date(946684800000);(TDATE).setMinutes(1234567);TDATE", - UTCDateFromTime(SetMinutes(946684800000,1234567)), - LocalDateFromTime(SetMinutes(946684800000,1234567)) ); - - addNewTestCase( -2208988800000,59, 59, void 0, - "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59);TDATE", - UTCDateFromTime(SetMinutes(-2208988800000,59,59)), - LocalDateFromTime(SetMinutes(-2208988800000,59,59)) ); - - addNewTestCase( -2208988800000, 59, 59, 999, - "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59,999);TDATE", - UTCDateFromTime(SetMinutes(-2208988800000,59,59,999)), - LocalDateFromTime(SetMinutes(-2208988800000,59,59,999)) ); +addNewTestCase( -2208988800000, 59, 59, 999, + "TDATE = new Date(-2208988800000);(TDATE).setMinutes(59,59,999);TDATE", + UTCDateFromTime(SetMinutes(-2208988800000,59,59,999)), + LocalDateFromTime(SetMinutes(-2208988800000,59,59,999)) ); /* - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", - UTCDateFromTime(SetUTCMilliseconds(0,-999)), - LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); */ -} +test(); + function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { - DateCase = new Date( time ); + DateCase = new Date( time ); - if ( sec == void 0 ) { - DateCase.setMinutes( min ); + if ( sec == void 0 ) { + DateCase.setMinutes( min ); + } else { + if ( ms == void 0 ) { + DateCase.setMinutes( min, sec ); } else { - if ( ms == void 0 ) { - DateCase.setMinutes( min, sec ); - } else { - DateCase.setMinutes( min, sec, ms ); - } + DateCase.setMinutes( min, sec, ms ); } + } - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetMinutes( t, min, sec, ms ) { - var TIME = LocalTime(t); - var MIN = Number(min); - var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); - var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); - var RESULT5 = MakeTime( HourFromTime( TIME ), - MIN, - SEC, - MS ); - return ( TimeClip(UTC( MakeDate(Day(TIME),RESULT5))) ); + var TIME = LocalTime(t); + var MIN = Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT5 = MakeTime( HourFromTime( TIME ), + MIN, + SEC, + MS ); + return ( TimeClip(UTC( MakeDate(Day(TIME),RESULT5))) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.29-1.js b/mozilla/js/tests/ecma/Date/15.9.5.29-1.js index 3ea01a34956..ce9d1c700f1 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.29-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.29-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,192 +35,175 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.29-1.js - ECMA Section: 15.9.5.29 Date.prototype.setUTCMinutes(min [, sec [, ms ]] ) - Description: - If sec is not specified, this behaves as if sec were specified with the - value getUTCSeconds ( ). + File Name: 15.9.5.29-1.js + ECMA Section: 15.9.5.29 Date.prototype.setUTCMinutes(min [, sec [, ms ]] ) + Description: + If sec is not specified, this behaves as if sec were specified with the + value getUTCSeconds ( ). - If ms is not specified, this behaves as if ms were specified with the value - getUTCMilliseconds( ). + If ms is not specified, this behaves as if ms were specified with the value + getUTCMilliseconds( ). - 1. Let t be this time value. - 2. Call ToNumber(min). - 3. If sec is not specified, compute SecFromTime(t); otherwise, call - ToNumber(sec). - 4. If ms is not specified, compute msFromTime(t); otherwise, call - ToNumber(ms). - 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). - 6. Compute MakeDate(Day(t), Result(5)). - 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). - 8. Return the value of the [[Value]] property of the this value. + 1. Let t be this time value. + 2. Call ToNumber(min). + 3. If sec is not specified, compute SecFromTime(t); otherwise, call + ToNumber(sec). + 4. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 5. Compute MakeTime(HourFromTime(t), Result(2), Result(3), Result(4)). + 6. Compute MakeDate(Day(t), Result(5)). + 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). + 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.29-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.29-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCMinutes( min [, sec, ms] )"); +writeHeaderToLog( SECTION + " Date.prototype.setUTCMinutes( min [, sec, ms] )"); - getTestCases(); - test(); +addNewTestCase( 0, 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setUTCMinutes(0);TDATE", + UTCDateFromTime(SetUTCMinutes(0,0,0,0)), + LocalDateFromTime(SetUTCMinutes(0,0,0,0)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( 28800000, 59, 59, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59,59)), + LocalDateFromTime(SetUTCMinutes(28800000,59,59)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( 28800000, 59, 59, 999, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59,999);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59,59,999)), + LocalDateFromTime(SetUTCMinutes(28800000,59,59,999)) ); -function getTestCases() { - addNewTestCase( 0, 0, void 0, void 0, - "TDATE = new Date(0);(TDATE).setUTCMinutes(0);TDATE", - UTCDateFromTime(SetUTCMinutes(0,0,0,0)), - LocalDateFromTime(SetUTCMinutes(0,0,0,0)) ); +addNewTestCase( 28800000, 59, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,59)), + LocalDateFromTime(SetUTCMinutes(28800000,59)) ); - addNewTestCase( 28800000, 59, 59, void 0, - "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59);TDATE", - UTCDateFromTime(SetUTCMinutes(28800000,59,59)), - LocalDateFromTime(SetUTCMinutes(28800000,59,59)) ); +addNewTestCase( 28800000, -480, 0, 0, + "TDATE = new Date(28800000);(TDATE).setUTCMinutes(-480);TDATE", + UTCDateFromTime(SetUTCMinutes(28800000,-480)), + LocalDateFromTime(SetUTCMinutes(28800000,-480)) ); - addNewTestCase( 28800000, 59, 59, 999, - "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59,59,999);TDATE", - UTCDateFromTime(SetUTCMinutes(28800000,59,59,999)), - LocalDateFromTime(SetUTCMinutes(28800000,59,59,999)) ); +addNewTestCase( 946684800000, 1234567, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCMinutes(1234567);TDATE", + UTCDateFromTime(SetUTCMinutes(946684800000,1234567)), + LocalDateFromTime(SetUTCMinutes(946684800000,1234567)) ); - addNewTestCase( 28800000, 59, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setUTCMinutes(59);TDATE", - UTCDateFromTime(SetUTCMinutes(28800000,59)), - LocalDateFromTime(SetUTCMinutes(28800000,59)) ); - - addNewTestCase( 28800000, -480, 0, 0, - "TDATE = new Date(28800000);(TDATE).setUTCMinutes(-480);TDATE", - UTCDateFromTime(SetUTCMinutes(28800000,-480)), - LocalDateFromTime(SetUTCMinutes(28800000,-480)) ); - - addNewTestCase( 946684800000, 1234567, void 0, void 0, - "TDATE = new Date(946684800000);(TDATE).setUTCMinutes(1234567);TDATE", - UTCDateFromTime(SetUTCMinutes(946684800000,1234567)), - LocalDateFromTime(SetUTCMinutes(946684800000,1234567)) ); - - addNewTestCase( -2208988800000, 59, 999, void 0, - "TDATE = new Date(-2208988800000);(TDATE).setUTCMinutes(59,999);TDATE", - UTCDateFromTime(SetUTCMinutes(-2208988800000,59,999)), - LocalDateFromTime(SetUTCMinutes(-2208988800000,59,999)) ); +addNewTestCase( -2208988800000, 59, 999, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setUTCMinutes(59,999);TDATE", + UTCDateFromTime(SetUTCMinutes(-2208988800000,59,999)), + LocalDateFromTime(SetUTCMinutes(-2208988800000,59,999)) ); /* - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", - UTCDateFromTime(SetUTCMilliseconds(0,-999)), - LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); */ -} +test(); + function addNewTestCase( time, min, sec, ms, DateString, UTCDate, LocalDate) { - var DateCase = new Date( time ); + var DateCase = new Date( time ); - if ( sec == void 0 ) { - DateCase.setUTCMinutes( min ); + if ( sec == void 0 ) { + DateCase.setUTCMinutes( min ); + } else { + if ( ms == void 0 ) { + DateCase.setUTCMinutes( min, sec ); } else { - if ( ms == void 0 ) { - DateCase.setUTCMinutes( min, sec ); - } else { - DateCase.setUTCMinutes( min, sec, ms ); - } + DateCase.setUTCMinutes( min, sec, ms ); } + } - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); +// new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); -// testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); +// new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCMinutes( t, min, sec, ms ) { - var TIME = t; - var MIN = Number(min); - var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); - var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); - var RESULT5 = MakeTime( HourFromTime( TIME ), - MIN, - SEC, - MS ); - return ( TimeClip(MakeDate(Day(TIME),RESULT5)) ); + var TIME = t; + var MIN = Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT5 = MakeTime( HourFromTime( TIME ), + MIN, + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME),RESULT5)) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.3-1-n.js b/mozilla/js/tests/ecma/Date/15.9.5.3-1-n.js index a2a12d6ee72..9faa8ceadf5 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.3-1-n.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.3-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,55 +35,44 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.3-1.js - ECMA Section: 15.9.5.3-1 Date.prototype.valueOf - Description: + File Name: 15.9.5.3-1.js + ECMA Section: 15.9.5.3-1 Date.prototype.valueOf + Description: - The valueOf function returns a number, which is this time value. + The valueOf function returns a number, which is this time value. - The valueOf function is not generic; it generates a runtime error if - its this value is not a Date object. Therefore it cannot be transferred - to other kinds of objects for use as a method. + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.3-1-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.valueOf"; +var SECTION = "15.9.5.3-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.valueOf"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var OBJ = new MyObject( new Date(0) ); - var OBJ = new MyObject( new Date(0) ); +DESCRIPTION = "var OBJ = new MyObject( new Date(0) ); OBJ.valueOf()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, - "var OBJ = new MyObject( new Date(0) ); OBJ.valueOf()", - "error", - OBJ.valueOf() ); - test(); +new TestCase( SECTION, + "var OBJ = new MyObject( new Date(0) ); OBJ.valueOf()", + "error", + eval("OBJ.valueOf()") ); +test(); function MyObject( value ) { - this.value = value; - this.valueOf = Date.prototype.valueOf; + this.value = value; + this.valueOf = Date.prototype.valueOf; // The following line causes an infinte loop // this.toString = new Function( "return this+\"\";"); - return this; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return this; } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.3-2.js b/mozilla/js/tests/ecma/Date/15.9.5.3-2.js index d66e67107d8..68594b10a38 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.3-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,89 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.3-2.js - ECMA Section: 15.9.5.3-2 Date.prototype.valueOf - Description: + File Name: 15.9.5.3-2.js + ECMA Section: 15.9.5.3-2 Date.prototype.valueOf + Description: - The valueOf function returns a number, which is this time value. + The valueOf function returns a number, which is this time value. - The valueOf function is not generic; it generates a runtime error if - its this value is not a Date object. Therefore it cannot be transferred - to other kinds of objects for use as a method. + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.valueOf"; +var SECTION = "15.9.5.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.valueOf"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; +var now = (new Date()).valueOf(); +var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_29_FEB_2000 ); +addTestCase( UTC_1_JAN_2005 ); - var TZ_ADJUST = TZ_DIFF * msPerHour; - var now = (new Date()).valueOf(); - var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - - addTestCase( now ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_29_FEB_2000 ); - addTestCase( UTC_1_JAN_2005 ); - - test(); +test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+").valueOf()", - t, - (new Date(t)).valueOf() ); + new TestCase( SECTION, + "(new Date("+t+").valueOf()", + t, + (new Date(t)).valueOf() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+").valueOf()", - t+1, - (new Date(t+1)).valueOf() ); + new TestCase( SECTION, + "(new Date("+(t+1)+").valueOf()", + t+1, + (new Date(t+1)).valueOf() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+").valueOf()", - t-1, - (new Date(t-1)).valueOf() ); + new TestCase( SECTION, + "(new Date("+(t-1)+").valueOf()", + t-1, + (new Date(t-1)).valueOf() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+").valueOf()", - t-TZ_ADJUST, - (new Date(t-TZ_ADJUST)).valueOf() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+").valueOf()", + t-TZ_ADJUST, + (new Date(t-TZ_ADJUST)).valueOf() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+").valueOf()", - t+TZ_ADJUST, - (new Date(t+TZ_ADJUST)).valueOf() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+").valueOf()", + t+TZ_ADJUST, + (new Date(t+TZ_ADJUST)).valueOf() ); } function MyObject( value ) { - this.value = value; - this.valueOf = Date.prototype.valueOf; - this.toString = new Function( "return this+\"\";"); - return this; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + this.value = value; + this.valueOf = Date.prototype.valueOf; + this.toString = new Function( "return this+\"\";"); + return this; } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.30-1.js b/mozilla/js/tests/ecma/Date/15.9.5.30-1.js index 4308c62c68d..609342754b9 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.30-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.30-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,197 +35,179 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.30-1.js - ECMA Section: 15.9.5.30 Date.prototype.setHours(hour [, min [, sec [, ms ]]] ) - Description: - If min is not specified, this behaves as if min were specified with the - value getMinutes( ). If sec is not specified, this behaves as if sec were - specified with the value getSeconds ( ). If ms is not specified, this - behaves as if ms were specified with the value getMilliseconds( ). + File Name: 15.9.5.30-1.js + ECMA Section: 15.9.5.30 Date.prototype.setHours(hour [, min [, sec [, ms ]]] ) + Description: + If min is not specified, this behaves as if min were specified with the + value getMinutes( ). If sec is not specified, this behaves as if sec were + specified with the value getSeconds ( ). If ms is not specified, this + behaves as if ms were specified with the value getMilliseconds( ). - 1. Let t be the result of LocalTime(this time value). - 2. Call ToNumber(hour). - 3. If min is not specified, compute MinFromTime(t); otherwise, call - ToNumber(min). - 4. If sec is not specified, compute SecFromTime(t); otherwise, call - ToNumber(sec). - 5. If ms is not specified, compute msFromTime(t); otherwise, call - ToNumber(ms). - 6. Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). - 7. Compute UTC(MakeDate(Day(t), Result(6))). - 8. Set the [[Value]] property of the this value to TimeClip(Result(7)). - 9. Return the value of the [[Value]] property of the this value. + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(hour). + 3. If min is not specified, compute MinFromTime(t); otherwise, call + ToNumber(min). + 4. If sec is not specified, compute SecFromTime(t); otherwise, call + ToNumber(sec). + 5. If ms is not specified, compute msFromTime(t); otherwise, call + ToNumber(ms). + 6. Compute MakeTime(Result(2), Result(3), Result(4), Result(5)). + 7. Compute UTC(MakeDate(Day(t), Result(6))). + 8. Set the [[Value]] property of the this value to TimeClip(Result(7)). + 9. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.30-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.30-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setHours( hour [, min, sec, ms] )"); +writeHeaderToLog( SECTION + " Date.prototype.setHours( hour [, min, sec, ms] )"); - getTestCases(); - test(); +addNewTestCase( 0,0,0,0,void 0, + "TDATE = new Date(0);(TDATE).setHours(0);TDATE" ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( 28800000, 23, 59, 999,void 0, + "TDATE = new Date(28800000);(TDATE).setHours(23,59,999);TDATE" ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( 28800000, 999, 999, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(999,999);TDATE" ); -function getTestCases() { - addNewTestCase( 0,0,0,0,void 0, - "TDATE = new Date(0);(TDATE).setHours(0);TDATE" ); +addNewTestCase( 28800000,999,0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(999);TDATE" ); - addNewTestCase( 28800000, 23, 59, 999,void 0, - "TDATE = new Date(28800000);(TDATE).setHours(23,59,999);TDATE" ); +addNewTestCase( 28800000,-8, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setHours(-8);TDATE" ); - addNewTestCase( 28800000, 999, 999, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setHours(999,999);TDATE" ); - - addNewTestCase( 28800000,999,0, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setHours(999);TDATE" ); - - addNewTestCase( 28800000,-8, void 0, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setHours(-8);TDATE" ); - - addNewTestCase( 946684800000,8760, void 0, void 0, void 0, +addNewTestCase( 946684800000,8760, void 0, void 0, void 0, "TDATE = new Date(946684800000);(TDATE).setHours(8760);TDATE" ); - addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 999, - "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,999)" ); +addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 999, + "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,999)" ); - addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 1000, - "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,1000)" ); +addNewTestCase( TIME_2000 - msPerDay, 23, 59, 59, 1000, + "d = new Date( " + (TIME_2000-msPerDay) +"); d.setHours(23,59,59,1000)" ); /* - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setHours(59,999);TDATE", - UTCDateFromTime(SetHours(-2208988800000,59,999)), - LocalDateFromTime(SetHours(-2208988800000,59,999)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setHours(59,999);TDATE", + UTCDateFromTime(SetHours(-2208988800000,59,999)), + LocalDateFromTime(SetHours(-2208988800000,59,999)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", - UTCDateFromTime(SetUTCMilliseconds(0,-999)), - LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); */ -} +test(); + function addNewTestCase( time, hours, min, sec, ms, DateString) { - var UTCDate = UTCDateFromTime( SetHours( time, hours, min, sec, ms )); - var LocalDate = LocalDateFromTime( SetHours( time, hours, min, sec, ms )); + var UTCDate = UTCDateFromTime( SetHours( time, hours, min, sec, ms )); + var LocalDate = LocalDateFromTime( SetHours( time, hours, min, sec, ms )); - var DateCase = new Date( time ); + var DateCase = new Date( time ); - if ( min == void 0 ) { - DateCase.setHours( hours ); + if ( min == void 0 ) { + DateCase.setHours( hours ); + } else { + if ( sec == void 0 ) { + DateCase.setHours( hours, min ); } else { - if ( sec == void 0 ) { - DateCase.setHours( hours, min ); - } else { - if ( ms == void 0 ) { - DateCase.setHours( hours, min, sec ); - } else { - DateCase.setHours( hours, min, sec, ms ); - } - } + if ( ms == void 0 ) { + DateCase.setHours( hours, min, sec ); + } else { + DateCase.setHours( hours, min, sec, ms ); + } } + } - var item = testcases.length; + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + DateCase.toString = Object.prototype.toString; - DateCase.toString = Object.prototype.toString; - - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.day = WeekDay( t ); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( t ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - return (d); + return (d); } function SetHours( t, hour, min, sec, ms ) { - var TIME = LocalTime(t); - var HOUR = Number(hour); - var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); - var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); - var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); - var RESULT6 = MakeTime( HOUR, - MIN, - SEC, - MS ); - var UTC_TIME = UTC( MakeDate(Day(TIME), RESULT6) ); - return ( TimeClip(UTC_TIME) ); + var TIME = LocalTime(t); + var HOUR = Number(hour); + var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT6 = MakeTime( HOUR, + MIN, + SEC, + MS ); + var UTC_TIME = UTC( MakeDate(Day(TIME), RESULT6) ); + return ( TimeClip(UTC_TIME) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.31-1.js b/mozilla/js/tests/ecma/Date/15.9.5.31-1.js index d3773bd55c4..d47359988b8 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.31-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.31-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,13 +35,14 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.31-1.js - ECMA Section: 15.9.5.31 Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] ) - Description: - If min is not specified, this behaves as if min were specified with the value getUTCMinutes( ). - If sec is not specified, this behaves as if sec were specified with the value getUTCSeconds ( ). - If ms is not specified, this behaves as if ms were specified with the value getUTCMilliseconds( ). + File Name: 15.9.5.31-1.js + ECMA Section: 15.9.5.31 Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] ) + Description: + If min is not specified, this behaves as if min were specified with the value getUTCMinutes( ). + If sec is not specified, this behaves as if sec were specified with the value getUTCSeconds ( ). + If ms is not specified, this behaves as if ms were specified with the value getUTCMilliseconds( ). 1.Let t be this time value. 2.Call ToNumber(hour). @@ -52,176 +54,158 @@ 8.Set the [[Value]] property of the this value to TimeClip(Result(7)). 1.Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.31-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.31-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setUTCHours(hour [, min [, sec [, ms ]]] )"); - getTestCases(); - test(); +addNewTestCase( 0, 0, void 0, void 0, void 0, + "TDATE = new Date(0);(TDATE).setUTCHours(0);TDATE", + UTCDateFromTime(SetUTCHours(0,0,0,0)), + LocalDateFromTime(SetUTCHours(0,0,0,0)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( 28800000, 23, 59, 999, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(23,59,999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,23,59,999)), + LocalDateFromTime(SetUTCHours(28800000,23,59,999)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( 28800000,999,999, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(999,999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,999,999)), + LocalDateFromTime(SetUTCHours(28800000,999,999)) ); -function getTestCases() { - addNewTestCase( 0, 0, void 0, void 0, void 0, - "TDATE = new Date(0);(TDATE).setUTCHours(0);TDATE", - UTCDateFromTime(SetUTCHours(0,0,0,0)), - LocalDateFromTime(SetUTCHours(0,0,0,0)) ); +addNewTestCase( 28800000, 999, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(999);TDATE", + UTCDateFromTime(SetUTCHours(28800000,999,0)), + LocalDateFromTime(SetUTCHours(28800000,999,0)) ); - addNewTestCase( 28800000, 23, 59, 999, void 0, - "TDATE = new Date(28800000);(TDATE).setUTCHours(23,59,999);TDATE", - UTCDateFromTime(SetUTCHours(28800000,23,59,999)), - LocalDateFromTime(SetUTCHours(28800000,23,59,999)) ); +addNewTestCase( 28800000, -8670, void 0, void 0, void 0, + "TDATE = new Date(28800000);(TDATE).setUTCHours(-8670);TDATE", + UTCDateFromTime(SetUTCHours(28800000,-8670)), + LocalDateFromTime(SetUTCHours(28800000,-8670)) ); - addNewTestCase( 28800000,999,999, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setUTCHours(999,999);TDATE", - UTCDateFromTime(SetUTCHours(28800000,999,999)), - LocalDateFromTime(SetUTCHours(28800000,999,999)) ); +addNewTestCase( 946684800000, 1234567, void 0, void 0, void 0, + "TDATE = new Date(946684800000);(TDATE).setUTCHours(1234567);TDATE", + UTCDateFromTime(SetUTCHours(946684800000,1234567)), + LocalDateFromTime(SetUTCHours(946684800000,1234567)) ); - addNewTestCase( 28800000, 999, void 0, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setUTCHours(999);TDATE", - UTCDateFromTime(SetUTCHours(28800000,999,0)), - LocalDateFromTime(SetUTCHours(28800000,999,0)) ); - - addNewTestCase( 28800000, -8670, void 0, void 0, void 0, - "TDATE = new Date(28800000);(TDATE).setUTCHours(-8670);TDATE", - UTCDateFromTime(SetUTCHours(28800000,-8670)), - LocalDateFromTime(SetUTCHours(28800000,-8670)) ); - - addNewTestCase( 946684800000, 1234567, void 0, void 0, void 0, - "TDATE = new Date(946684800000);(TDATE).setUTCHours(1234567);TDATE", - UTCDateFromTime(SetUTCHours(946684800000,1234567)), - LocalDateFromTime(SetUTCHours(946684800000,1234567)) ); - - addNewTestCase( -2208988800000, 59, 999, void 0, void 0, - "TDATE = new Date(-2208988800000);(TDATE).setUTCHours(59,999);TDATE", - UTCDateFromTime(SetUTCHours(-2208988800000,59,999)), - LocalDateFromTime(SetUTCHours(-2208988800000,59,999)) ); +addNewTestCase( -2208988800000, 59, 999, void 0, void 0, + "TDATE = new Date(-2208988800000);(TDATE).setUTCHours(59,999);TDATE", + UTCDateFromTime(SetUTCHours(-2208988800000,59,999)), + LocalDateFromTime(SetUTCHours(-2208988800000,59,999)) ); /* - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456789);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456789)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,123456)) ); - addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", - UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), - LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); + addNewTestCase( "TDATE = new Date(-2208988800000);(TDATE).setUTCMilliseconds(-123456);TDATE", + UTCDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)), + LocalDateFromTime(SetUTCMilliseconds(-2208988800000,-123456)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", - UTCDateFromTime(SetUTCMilliseconds(0,-999)), - LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMilliseconds(-999);TDATE", + UTCDateFromTime(SetUTCMilliseconds(0,-999)), + LocalDateFromTime(SetUTCMilliseconds(0,-999)) ); */ -} +test(); + function addNewTestCase( time, hours, min, sec, ms, DateString, UTCDate, LocalDate) { - DateCase = new Date(time); - if ( min == void 0 ) { - DateCase.setUTCHours( hours ); + DateCase = new Date(time); + if ( min == void 0 ) { + DateCase.setUTCHours( hours ); + } else { + if ( sec == void 0 ) { + DateCase.setUTCHours( hours, min ); } else { - if ( sec == void 0 ) { - DateCase.setUTCHours( hours, min ); - } else { - if ( ms == void 0 ) { - DateCase.setUTCHours( hours, min, sec ); - } else { - DateCase.setUTCHours( hours, min, sec, ms ); - } - } + if ( ms == void 0 ) { + DateCase.setUTCHours( hours, min, sec ); + } else { + DateCase.setUTCHours( hours, min, sec, ms ); + } } + } - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCHours( t, hour, min, sec, ms ) { - var TIME = t; - var HOUR = Number(hour); - var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); - var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); - var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); - var RESULT6 = MakeTime( HOUR, - MIN, - SEC, - MS ); - return ( TimeClip(MakeDate(Day(TIME), RESULT6)) ); + var TIME = t; + var HOUR = Number(hour); + var MIN = ( min == void 0) ? MinFromTime(TIME) : Number(min); + var SEC = ( sec == void 0) ? SecFromTime(TIME) : Number(sec); + var MS = ( ms == void 0 ) ? msFromTime(TIME) : Number(ms); + var RESULT6 = MakeTime( HOUR, + MIN, + SEC, + MS ); + return ( TimeClip(MakeDate(Day(TIME), RESULT6)) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.32-1.js b/mozilla/js/tests/ecma/Date/15.9.5.32-1.js index 59fb514648e..64127f761b4 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.32-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.32-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,139 +35,122 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 15.9.5.32-1.js - ECMA Section: 15.9.5.32 Date.prototype.setDate(date) - Description: - 1. Let t be the result of LocalTime(this time value). - 2. Call ToNumber(date). - 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). - 4. Compute UTC(MakeDate(Result(3), TimeWithinDay(t))). - 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). - 6. Return the value of the [[Value]] property of the this value. +/** + File Name: 15.9.5.32-1.js + ECMA Section: 15.9.5.32 Date.prototype.setDate(date) + Description: + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(date). + 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). + 4. Compute UTC(MakeDate(Result(3), TimeWithinDay(t))). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.32-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.32-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setDate(date) "); +writeHeaderToLog( SECTION + " Date.prototype.setDate(date) "); - getTestCases(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - addNewTestCase( 0, 1, - "TDATE = new Date(0);(TDATE).setDate(1);TDATE" ); +addNewTestCase( 0, 1, + "TDATE = new Date(0);(TDATE).setDate(1);TDATE" ); /* - addNewTestCase( "TDATE = new Date(86400000);(TDATE).setDate(1);TDATE", - UTCDateFromTime(SetDate(86400000,1)), - LocalDateFromTime(SetDate(86400000,1)) ); + addNewTestCase( "TDATE = new Date(86400000);(TDATE).setDate(1);TDATE", + UTCDateFromTime(SetDate(86400000,1)), + LocalDateFromTime(SetDate(86400000,1)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1972)), - LocalDateFromTime(SetUTCFullYear(0,1972)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1968)), - LocalDateFromTime(SetUTCFullYear(0,1968)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1969)), - LocalDateFromTime(SetUTCFullYear(0,1969)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); */ -} + +test(); + function addNewTestCase( t, d, DateString ) { - var DateCase = new Date( t ); - DateCase.setDate( d ); + var DateCase = new Date( t ); + DateCase.setDate( d ); - var UTCDate = UTCDateFromTime(SetDate(t, d)); - var LocalDate=LocalDateFromTime(SetDate(t,d)); + var UTCDate = UTCDateFromTime(SetDate(t, d)); + var LocalDate=LocalDateFromTime(SetDate(t,d)); - var item = testcases.length; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetDate( t, date ) { - var T = LocalTime( t ); - var DATE = Number( date ); - var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); - var UTC_DATE = UTC( MakeDate(RESULT3, TimeWithinDay(T)) ); - return ( TimeClip(UTC_DATE) ); + var T = LocalTime( t ); + var DATE = Number( date ); + var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); + var UTC_DATE = UTC( MakeDate(RESULT3, TimeWithinDay(T)) ); + return ( TimeClip(UTC_DATE) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.33-1.js b/mozilla/js/tests/ecma/Date/15.9.5.33-1.js index 580671875a5..5e17440ab01 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.33-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.33-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,138 +35,121 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 15.9.5.33-1.js - ECMA Section: 15.9.5.33 Date.prototype.setUTCDate(date) - Description: - 1. Let t be this time value. - 2. Call ToNumber(date). - 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). - 4. Compute MakeDate(Result(3), TimeWithinDay(t)). - 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). - 6. Return the value of the [[Value]] property of the this value. +/** + File Name: 15.9.5.33-1.js + ECMA Section: 15.9.5.33 Date.prototype.setUTCDate(date) + Description: + 1. Let t be this time value. + 2. Call ToNumber(date). + 3. Compute MakeDay(YearFromTime(t), MonthFromTime(t), Result(2)). + 4. Compute MakeDate(Result(3), TimeWithinDay(t)). + 5. Set the [[Value]] property of the this value to TimeClip(Result(4)). + 6. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.33-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.33-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCDate(date) "); +writeHeaderToLog( SECTION + " Date.prototype.setUTCDate(date) "); - getTestCases(); - test(); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(31);TDATE", + UTCDateFromTime(SetUTCDate(0,31)), + LocalDateFromTime(SetUTCDate(0,31)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(1);TDATE", + UTCDateFromTime(SetUTCDate(0,1)), + LocalDateFromTime(SetUTCDate(0,1)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(31);TDATE", - UTCDateFromTime(SetUTCDate(0,31)), - LocalDateFromTime(SetUTCDate(0,31)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCDate(1);TDATE", - UTCDateFromTime(SetUTCDate(0,1)), - LocalDateFromTime(SetUTCDate(0,1)) ); - - addNewTestCase( "TDATE = new Date(86400000);(TDATE).setUTCDate(1);TDATE", - UTCDateFromTime(SetUTCDate(86400000,1)), - LocalDateFromTime(SetUTCDate(86400000,1)) ); +addNewTestCase( "TDATE = new Date(86400000);(TDATE).setUTCDate(1);TDATE", + UTCDateFromTime(SetUTCDate(86400000,1)), + LocalDateFromTime(SetUTCDate(86400000,1)) ); /* - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1972)), - LocalDateFromTime(SetUTCFullYear(0,1972)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1968)), - LocalDateFromTime(SetUTCFullYear(0,1968)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1969)), - LocalDateFromTime(SetUTCFullYear(0,1969)) ); + addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); */ -} + +test(); + function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); + DateCase = eval( DateString ); - var item = testcases.length; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCDate( t, date ) { - var T = t; - var DATE = Number( date ); - var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); - return ( TimeClip(MakeDate(RESULT3, TimeWithinDay(t))) ); + var T = t; + var DATE = Number( date ); + var RESULT3 = MakeDay(YearFromTime(T), MonthFromTime(T), DATE ); + return ( TimeClip(MakeDate(RESULT3, TimeWithinDay(t))) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.34-1.js b/mozilla/js/tests/ecma/Date/15.9.5.34-1.js index f3c3445dc70..9161792a870 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.34-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.34-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,202 +35,186 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.34-1.js - ECMA Section: 15.9.5.34 Date.prototype.setMonth(mon [, date ] ) - Description: - If date is not specified, this behaves as if date were specified with the - value getDate( ). + File Name: 15.9.5.34-1.js + ECMA Section: 15.9.5.34 Date.prototype.setMonth(mon [, date ] ) + Description: + If date is not specified, this behaves as if date were specified with the + value getDate( ). - 1. Let t be the result of LocalTime(this time value). - 2. Call ToNumber(date). - 3. If date is not specified, compute DateFromTime(t); otherwise, call ToNumber(date). - 4. Compute MakeDay(YearFromTime(t), Result(2), Result(3)). - 5. Compute UTC(MakeDate(Result(4), TimeWithinDay(t))). - 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). - 7. Return the value of the [[Value]] property of the this value. + 1. Let t be the result of LocalTime(this time value). + 2. Call ToNumber(date). + 3. If date is not specified, compute DateFromTime(t); otherwise, call ToNumber(date). + 4. Compute MakeDay(YearFromTime(t), Result(2), Result(3)). + 5. Compute UTC(MakeDate(Result(4), TimeWithinDay(t))). + 6. Set the [[Value]] property of the this value to TimeClip(Result(5)). + 7. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.34-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.34-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setMonth(mon [, date ] )"); +writeHeaderToLog( SECTION + " Date.prototype.setMonth(mon [, date ] )"); - var now = (new Date()).valueOf(); +var now = (new Date()).valueOf(); - getFunctionCases(); - getTestCases(); - test(); +getFunctionCases(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// regression test for http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112404 +d = new Date(0); +d.setMonth(1,1,1,1,1,1); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getFunctionCases() { - // some tests for all functions - testcases[testcases.length] = new TestCase( - SECTION, - "Date.prototype.setMonth.length", - 2, - Date.prototype.setMonth.length ); - - testcases[testcases.length] = new TestCase( - SECTION, - "typeof Date.prototype.setMonth", - "function", - typeof Date.prototype.setMonth ); +addNewTestCase( + "TDATE = new Date(0); TDATE.setMonth(1,1,1,1,1,1); TDATE", + UTCDateFromTime(SetMonth(0,1,1)), + LocalDateFromTime(SetMonth(0,1,1)) ); -/* +// whatever today is - testcases[testcases.length] = new TestCase( - SECTION, - "delete Date.prototype.setMonth", - false, - delete Date.prototype.setMonth ); -*/ +addNewTestCase( "TDATE = new Date(now); (TDATE).setMonth(11,31); TDATE", + UTCDateFromTime(SetMonth(now,11,31)), + LocalDateFromTime(SetMonth(now,11,31)) ); -} +// 1970 +addNewTestCase( "TDATE = new Date(0);(TDATE).setMonth(0,1);TDATE", + UTCDateFromTime(SetMonth(0,0,1)), + LocalDateFromTime(SetMonth(0,0,1)) ); -function getTestCases() { - // regression test for http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112404 - d = new Date(0); - d.setMonth(1,1,1,1,1,1); - - addNewTestCase( - "TDATE = new Date(0); TDATE.setMonth(1,1,1,1,1,1); TDATE", - UTCDateFromTime(SetMonth(0,1,1)), - LocalDateFromTime(SetMonth(0,1,1)) ); - - - // whatever today is - - addNewTestCase( "TDATE = new Date(now); (TDATE).setMonth(11,31); TDATE", - UTCDateFromTime(SetMonth(now,11,31)), - LocalDateFromTime(SetMonth(now,11,31)) ); - - // 1970 - - addNewTestCase( "TDATE = new Date(0);(TDATE).setMonth(0,1);TDATE", - UTCDateFromTime(SetMonth(0,0,1)), - LocalDateFromTime(SetMonth(0,0,1)) ); - - addNewTestCase( "TDATE = new Date("+TIME_1900+"); "+ - "(TDATE).setMonth(11,31); TDATE", - UTCDateFromTime( SetMonth(TIME_1900,11,31) ), - LocalDateFromTime( SetMonth(TIME_1900,11,31) ) ); +addNewTestCase( "TDATE = new Date("+TIME_1900+"); "+ + "(TDATE).setMonth(11,31); TDATE", + UTCDateFromTime( SetMonth(TIME_1900,11,31) ), + LocalDateFromTime( SetMonth(TIME_1900,11,31) ) ); /* - addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(11,23,59,999);TDATE", - UTCDateFromTime(SetMonth(28800000,11,23,59,999)), - LocalDateFromTime(SetMonth(28800000,11,23,59,999)) ); + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(11,23,59,999);TDATE", + UTCDateFromTime(SetMonth(28800000,11,23,59,999)), + LocalDateFromTime(SetMonth(28800000,11,23,59,999)) ); - addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(99,99);TDATE", - UTCDateFromTime(SetMonth(28800000,99,99)), - LocalDateFromTime(SetMonth(28800000,99,99)) ); + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(99,99);TDATE", + UTCDateFromTime(SetMonth(28800000,99,99)), + LocalDateFromTime(SetMonth(28800000,99,99)) ); - addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(11);TDATE", - UTCDateFromTime(SetMonth(28800000,11,0)), - LocalDateFromTime(SetMonth(28800000,11,0)) ); + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(11);TDATE", + UTCDateFromTime(SetMonth(28800000,11,0)), + LocalDateFromTime(SetMonth(28800000,11,0)) ); - addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(-11);TDATE", - UTCDateFromTime(SetMonth(28800000,-11)), - LocalDateFromTime(SetMonth(28800000,-11)) ); + addNewTestCase( "TDATE = new Date(28800000);(TDATE).setMonth(-11);TDATE", + UTCDateFromTime(SetMonth(28800000,-11)), + LocalDateFromTime(SetMonth(28800000,-11)) ); - // 1900 + // 1900 // addNewTestCase( "TDATE = new Date(); (TDATE).setMonth(11,31); TDATE;" */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; + + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); +} + +function getFunctionCases() { + // some tests for all functions + new TestCase( + SECTION, + "Date.prototype.setMonth.length", + 2, + Date.prototype.setMonth.length ); + + new TestCase( + SECTION, + "typeof Date.prototype.setMonth", + "function", + typeof Date.prototype.setMonth ); + + +/* + +new TestCase( +SECTION, +"delete Date.prototype.setMonth", +false, +delete Date.prototype.setMonth ); +*/ - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetMonth( t, mon, date ) { - var TIME = LocalTime(t); - var MONTH = Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(TIME) : Number( date ); - var DAY = MakeDay( YearFromTime(TIME), MONTH, DATE ); - return ( TimeClip (UTC(MakeDate( DAY, TimeWithinDay(TIME) ))) ); + var TIME = LocalTime(t); + var MONTH = Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(TIME) : Number( date ); + var DAY = MakeDay( YearFromTime(TIME), MONTH, DATE ); + return ( TimeClip (UTC(MakeDate( DAY, TimeWithinDay(TIME) ))) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.35-1.js b/mozilla/js/tests/ecma/Date/15.9.5.35-1.js index 824d86fd145..6a0cbf01359 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.35-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.35-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,125 +35,105 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 15.9.5.35-1.js - ECMA Section: 15.9.5.35 Date.prototype.setUTCMonth(mon [,date]) - Description: - Author: christine@netscape.com - Date: 12 november 1997 +/** + File Name: 15.9.5.35-1.js + ECMA Section: 15.9.5.35 Date.prototype.setUTCMonth(mon [,date]) + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.35-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.35-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCMonth(mon [,date] ) "); +writeHeaderToLog( SECTION + " Date.prototype.setUTCMonth(mon [,date] ) "); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(0);TDATE", + UTCDateFromTime(SetUTCMonth(0,0)), + LocalDateFromTime(SetUTCMonth(0,0)) ); - getTestCases(); - test(); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(11);TDATE", + UTCDateFromTime(SetUTCMonth(0,11)), + LocalDateFromTime(SetUTCMonth(0,11)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(3,4);TDATE", + UTCDateFromTime(SetUTCMonth(0,3,4)), + LocalDateFromTime(SetUTCMonth(0,3,4)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(0);TDATE", - UTCDateFromTime(SetUTCMonth(0,0)), - LocalDateFromTime(SetUTCMonth(0,0)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(11);TDATE", - UTCDateFromTime(SetUTCMonth(0,11)), - LocalDateFromTime(SetUTCMonth(0,11)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCMonth(3,4);TDATE", - UTCDateFromTime(SetUTCMonth(0,3,4)), - LocalDateFromTime(SetUTCMonth(0,3,4)) ); - -} +test(); function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); + DateCase = eval( DateString ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCMonth( t, month, date ) { - var T = t; - var MONTH = Number( month ); - var DATE = ( date == void 0) ? DateFromTime(T) : Number( date ); + var T = t; + var MONTH = Number( month ); + var DATE = ( date == void 0) ? DateFromTime(T) : Number( date ); - var RESULT4 = MakeDay(YearFromTime(T), MONTH, DATE ); - var RESULT5 = MakeDate( RESULT4, TimeWithinDay(T)); + var RESULT4 = MakeDay(YearFromTime(T), MONTH, DATE ); + var RESULT5 = MakeDate( RESULT4, TimeWithinDay(T)); - return ( TimeClip(RESULT5) ); + return ( TimeClip(RESULT5) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.36-1.js b/mozilla/js/tests/ecma/Date/15.9.5.36-1.js index 72ecedbb402..66db3c1308c 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.36-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.36-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,227 +35,212 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.36-1.js - ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) - Description: - If mon is not specified, this behaves as if mon were specified with the - value getMonth( ). If date is not specified, this behaves as if date were - specified with the value getDate( ). +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). 1. Let t be the result of LocalTime(this time value); but if this time - value is NaN, let t be +0. + value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added test cases for Year 2000 Compatilibity Testing. + Added test cases for Year 2000 Compatilibity Testing. */ - var SECTION = "15.9.5.36-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// 1969 - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969);TDATE", + UTCDateFromTime(SetFullYear(0,1969)), + LocalDateFromTime(SetFullYear(0,1969)) ); - // 1969 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11);TDATE", + UTCDateFromTime(SetFullYear(0,1969,11)), + LocalDateFromTime(SetFullYear(0,1969,11)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969);TDATE", - UTCDateFromTime(SetFullYear(0,1969)), - LocalDateFromTime(SetFullYear(0,1969)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11);TDATE", - UTCDateFromTime(SetFullYear(0,1969,11)), - LocalDateFromTime(SetFullYear(0,1969,11)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11,31);TDATE", - UTCDateFromTime(SetFullYear(0,1969,11,31)), - LocalDateFromTime(SetFullYear(0,1969,11,31)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1969,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1969,11,31)), + LocalDateFromTime(SetFullYear(0,1969,11,31)) ); /* - // 1970 +// 1970 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", - UTCDateFromTime(SetFullYear(0,1970)), - LocalDateFromTime(SetFullYear(0,1970)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", +UTCDateFromTime(SetFullYear(0,1970)), +LocalDateFromTime(SetFullYear(0,1970)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", - UTCDateFromTime(SetFullYear(0,1970,0)), - LocalDateFromTime(SetFullYear(0,1970,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", +UTCDateFromTime(SetFullYear(0,1970,0)), +LocalDateFromTime(SetFullYear(0,1970,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,1970,0,1)), - LocalDateFromTime(SetFullYear(0,1970,0,1)) ); - // 1971 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", - UTCDateFromTime(SetFullYear(0,1971)), - LocalDateFromTime(SetFullYear(0,1971)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,1970,0,1)), +LocalDateFromTime(SetFullYear(0,1970,0,1)) ); +// 1971 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", +UTCDateFromTime(SetFullYear(0,1971)), +LocalDateFromTime(SetFullYear(0,1971)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", - UTCDateFromTime(SetFullYear(0,1971,0)), - LocalDateFromTime(SetFullYear(0,1971,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", +UTCDateFromTime(SetFullYear(0,1971,0)), +LocalDateFromTime(SetFullYear(0,1971,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,1971,0,1)), - LocalDateFromTime(SetFullYear(0,1971,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,1971,0,1)), +LocalDateFromTime(SetFullYear(0,1971,0,1)) ); - // 1999 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", - UTCDateFromTime(SetFullYear(0,1999)), - LocalDateFromTime(SetFullYear(0,1999)) ); +// 1999 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", +UTCDateFromTime(SetFullYear(0,1999)), +LocalDateFromTime(SetFullYear(0,1999)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", - UTCDateFromTime(SetFullYear(0,1999,11)), - LocalDateFromTime(SetFullYear(0,1999,11)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", +UTCDateFromTime(SetFullYear(0,1999,11)), +LocalDateFromTime(SetFullYear(0,1999,11)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", - UTCDateFromTime(SetFullYear(0,1999,11,31)), - LocalDateFromTime(SetFullYear(0,1999,11,31)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", +UTCDateFromTime(SetFullYear(0,1999,11,31)), +LocalDateFromTime(SetFullYear(0,1999,11,31)) ); - // 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0)), - LocalDateFromTime(SetFullYear(0,2000,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", +UTCDateFromTime(SetFullYear(0,2000,0)), +LocalDateFromTime(SetFullYear(0,2000,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0,1)), - LocalDateFromTime(SetFullYear(0,2000,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,0,1)), +LocalDateFromTime(SetFullYear(0,2000,0,1)) ); - // feb 29, 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// feb 29, 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1)), - LocalDateFromTime(SetFullYear(0,2000,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1)), +LocalDateFromTime(SetFullYear(0,2000,1)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1,29)), - LocalDateFromTime(SetFullYear(0,2000,1,29)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1,29)), +LocalDateFromTime(SetFullYear(0,2000,1,29)) ); - // Jan 1, 2005 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", - UTCDateFromTime(SetFullYear(0,2005)), - LocalDateFromTime(SetFullYear(0,2005)) ); +// Jan 1, 2005 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", +UTCDateFromTime(SetFullYear(0,2005)), +LocalDateFromTime(SetFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0)), - LocalDateFromTime(SetFullYear(0,2005,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0)), +LocalDateFromTime(SetFullYear(0,2005,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0,1)), - LocalDateFromTime(SetFullYear(0,2005,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0,1)), +LocalDateFromTime(SetFullYear(0,2005,0,1)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetFullYear( t, year, mon, date ) { - var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; - var YEAR = Number( year ); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); - var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); - return ( TimeClip(UTC_DATE) ); -} \ No newline at end of file + return ( TimeClip(UTC_DATE) ); +} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.36-2.js b/mozilla/js/tests/ecma/Date/15.9.5.36-2.js index 6172c0e9481..5317d8e2fa9 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.36-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.36-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,213 +35,198 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.36-1.js - ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) - Description: - If mon is not specified, this behaves as if mon were specified with the - value getMonth( ). If date is not specified, this behaves as if date were - specified with the value getDate( ). +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). 1. Let t be the result of LocalTime(this time value); but if this time - value is NaN, let t be +0. + value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added test cases for Year 2000 Compatilibity Testing. + Added test cases for Year 2000 Compatilibity Testing. */ - var SECTION = "15.9.5.36-2"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.36-2"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); +// 1970 -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", + UTCDateFromTime(SetFullYear(0,1970)), + LocalDateFromTime(SetFullYear(0,1970)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - // 1970 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0)), + LocalDateFromTime(SetFullYear(0,1970,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970);TDATE", - UTCDateFromTime(SetFullYear(0,1970)), - LocalDateFromTime(SetFullYear(0,1970)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0);TDATE", - UTCDateFromTime(SetFullYear(0,1970,0)), - LocalDateFromTime(SetFullYear(0,1970,0)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,1970,0,1)), - LocalDateFromTime(SetFullYear(0,1970,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1970,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1970,0,1)), + LocalDateFromTime(SetFullYear(0,1970,0,1)) ); /* - // 1971 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", - UTCDateFromTime(SetFullYear(0,1971)), - LocalDateFromTime(SetFullYear(0,1971)) ); +// 1971 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", +UTCDateFromTime(SetFullYear(0,1971)), +LocalDateFromTime(SetFullYear(0,1971)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", - UTCDateFromTime(SetFullYear(0,1971,0)), - LocalDateFromTime(SetFullYear(0,1971,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", +UTCDateFromTime(SetFullYear(0,1971,0)), +LocalDateFromTime(SetFullYear(0,1971,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,1971,0,1)), - LocalDateFromTime(SetFullYear(0,1971,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,1971,0,1)), +LocalDateFromTime(SetFullYear(0,1971,0,1)) ); - // 1999 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", - UTCDateFromTime(SetFullYear(0,1999)), - LocalDateFromTime(SetFullYear(0,1999)) ); +// 1999 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", +UTCDateFromTime(SetFullYear(0,1999)), +LocalDateFromTime(SetFullYear(0,1999)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", - UTCDateFromTime(SetFullYear(0,1999,11)), - LocalDateFromTime(SetFullYear(0,1999,11)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", +UTCDateFromTime(SetFullYear(0,1999,11)), +LocalDateFromTime(SetFullYear(0,1999,11)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", - UTCDateFromTime(SetFullYear(0,1999,11,31)), - LocalDateFromTime(SetFullYear(0,1999,11,31)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", +UTCDateFromTime(SetFullYear(0,1999,11,31)), +LocalDateFromTime(SetFullYear(0,1999,11,31)) ); - // 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0)), - LocalDateFromTime(SetFullYear(0,2000,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", +UTCDateFromTime(SetFullYear(0,2000,0)), +LocalDateFromTime(SetFullYear(0,2000,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0,1)), - LocalDateFromTime(SetFullYear(0,2000,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,0,1)), +LocalDateFromTime(SetFullYear(0,2000,0,1)) ); - // feb 29, 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// feb 29, 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1)), - LocalDateFromTime(SetFullYear(0,2000,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1)), +LocalDateFromTime(SetFullYear(0,2000,1)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1,29)), - LocalDateFromTime(SetFullYear(0,2000,1,29)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1,29)), +LocalDateFromTime(SetFullYear(0,2000,1,29)) ); - // Jan 1, 2005 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", - UTCDateFromTime(SetFullYear(0,2005)), - LocalDateFromTime(SetFullYear(0,2005)) ); +// Jan 1, 2005 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", +UTCDateFromTime(SetFullYear(0,2005)), +LocalDateFromTime(SetFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0)), - LocalDateFromTime(SetFullYear(0,2005,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0)), +LocalDateFromTime(SetFullYear(0,2005,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0,1)), - LocalDateFromTime(SetFullYear(0,2005,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0,1)), +LocalDateFromTime(SetFullYear(0,2005,0,1)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetFullYear( t, year, mon, date ) { - var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; - var YEAR = Number( year ); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); - var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); - return ( TimeClip(UTC_DATE) ); -} \ No newline at end of file + return ( TimeClip(UTC_DATE) ); +} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.36-3.js b/mozilla/js/tests/ecma/Date/15.9.5.36-3.js index 7fe7c0287be..a48cb9b2790 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.36-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.36-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,200 +35,185 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.36-1.js - ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) - Description: - If mon is not specified, this behaves as if mon were specified with the - value getMonth( ). If date is not specified, this behaves as if date were - specified with the value getDate( ). +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). 1. Let t be the result of LocalTime(this time value); but if this time - value is NaN, let t be +0. + value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added test cases for Year 2000 Compatilibity Testing. + Added test cases for Year 2000 Compatilibity Testing. */ - var SECTION = "15.9.5.36-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); +// 1971 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", + UTCDateFromTime(SetFullYear(0,1971)), + LocalDateFromTime(SetFullYear(0,1971)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0)), + LocalDateFromTime(SetFullYear(0,1971,0)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - // 1971 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971);TDATE", - UTCDateFromTime(SetFullYear(0,1971)), - LocalDateFromTime(SetFullYear(0,1971)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0);TDATE", - UTCDateFromTime(SetFullYear(0,1971,0)), - LocalDateFromTime(SetFullYear(0,1971,0)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,1971,0,1)), - LocalDateFromTime(SetFullYear(0,1971,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1971,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,1971,0,1)), + LocalDateFromTime(SetFullYear(0,1971,0,1)) ); /* - // 1999 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", - UTCDateFromTime(SetFullYear(0,1999)), - LocalDateFromTime(SetFullYear(0,1999)) ); +// 1999 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", +UTCDateFromTime(SetFullYear(0,1999)), +LocalDateFromTime(SetFullYear(0,1999)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", - UTCDateFromTime(SetFullYear(0,1999,11)), - LocalDateFromTime(SetFullYear(0,1999,11)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", +UTCDateFromTime(SetFullYear(0,1999,11)), +LocalDateFromTime(SetFullYear(0,1999,11)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", - UTCDateFromTime(SetFullYear(0,1999,11,31)), - LocalDateFromTime(SetFullYear(0,1999,11,31)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", +UTCDateFromTime(SetFullYear(0,1999,11,31)), +LocalDateFromTime(SetFullYear(0,1999,11,31)) ); - // 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0)), - LocalDateFromTime(SetFullYear(0,2000,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", +UTCDateFromTime(SetFullYear(0,2000,0)), +LocalDateFromTime(SetFullYear(0,2000,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0,1)), - LocalDateFromTime(SetFullYear(0,2000,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,0,1)), +LocalDateFromTime(SetFullYear(0,2000,0,1)) ); - // feb 29, 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// feb 29, 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1)), - LocalDateFromTime(SetFullYear(0,2000,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1)), +LocalDateFromTime(SetFullYear(0,2000,1)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1,29)), - LocalDateFromTime(SetFullYear(0,2000,1,29)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1,29)), +LocalDateFromTime(SetFullYear(0,2000,1,29)) ); - // Jan 1, 2005 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", - UTCDateFromTime(SetFullYear(0,2005)), - LocalDateFromTime(SetFullYear(0,2005)) ); +// Jan 1, 2005 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", +UTCDateFromTime(SetFullYear(0,2005)), +LocalDateFromTime(SetFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0)), - LocalDateFromTime(SetFullYear(0,2005,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0)), +LocalDateFromTime(SetFullYear(0,2005,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0,1)), - LocalDateFromTime(SetFullYear(0,2005,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0,1)), +LocalDateFromTime(SetFullYear(0,2005,0,1)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetFullYear( t, year, mon, date ) { - var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; - var YEAR = Number( year ); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); - var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); - return ( TimeClip(UTC_DATE) ); -} \ No newline at end of file + return ( TimeClip(UTC_DATE) ); +} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.36-4.js b/mozilla/js/tests/ecma/Date/15.9.5.36-4.js index a1f5fe58051..2a6a43c093e 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.36-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.36-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,187 +35,172 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.36-1.js - ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) - Description: - If mon is not specified, this behaves as if mon were specified with the - value getMonth( ). If date is not specified, this behaves as if date were - specified with the value getDate( ). +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). 1. Let t be the result of LocalTime(this time value); but if this time - value is NaN, let t be +0. + value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added test cases for Year 2000 Compatilibity Testing. + Added test cases for Year 2000 Compatilibity Testing. */ - var SECTION = "15.9.5.36-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); +// 1999 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", + UTCDateFromTime(SetFullYear(0,1999)), + LocalDateFromTime(SetFullYear(0,1999)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11)), + LocalDateFromTime(SetFullYear(0,1999,11)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - // 1999 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999);TDATE", - UTCDateFromTime(SetFullYear(0,1999)), - LocalDateFromTime(SetFullYear(0,1999)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11);TDATE", - UTCDateFromTime(SetFullYear(0,1999,11)), - LocalDateFromTime(SetFullYear(0,1999,11)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", - UTCDateFromTime(SetFullYear(0,1999,11,31)), - LocalDateFromTime(SetFullYear(0,1999,11,31)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(1999,11,31);TDATE", + UTCDateFromTime(SetFullYear(0,1999,11,31)), + LocalDateFromTime(SetFullYear(0,1999,11,31)) ); /* - // 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0)), - LocalDateFromTime(SetFullYear(0,2000,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", +UTCDateFromTime(SetFullYear(0,2000,0)), +LocalDateFromTime(SetFullYear(0,2000,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0,1)), - LocalDateFromTime(SetFullYear(0,2000,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,0,1)), +LocalDateFromTime(SetFullYear(0,2000,0,1)) ); - // feb 29, 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// feb 29, 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1)), - LocalDateFromTime(SetFullYear(0,2000,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1)), +LocalDateFromTime(SetFullYear(0,2000,1)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1,29)), - LocalDateFromTime(SetFullYear(0,2000,1,29)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1,29)), +LocalDateFromTime(SetFullYear(0,2000,1,29)) ); - // Jan 1, 2005 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", - UTCDateFromTime(SetFullYear(0,2005)), - LocalDateFromTime(SetFullYear(0,2005)) ); +// Jan 1, 2005 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", +UTCDateFromTime(SetFullYear(0,2005)), +LocalDateFromTime(SetFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0)), - LocalDateFromTime(SetFullYear(0,2005,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0)), +LocalDateFromTime(SetFullYear(0,2005,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0,1)), - LocalDateFromTime(SetFullYear(0,2005,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0,1)), +LocalDateFromTime(SetFullYear(0,2005,0,1)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetFullYear( t, year, mon, date ) { - var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; - var YEAR = Number( year ); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); - var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); - return ( TimeClip(UTC_DATE) ); -} \ No newline at end of file + return ( TimeClip(UTC_DATE) ); +} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.36-5.js b/mozilla/js/tests/ecma/Date/15.9.5.36-5.js index 9973412f854..0ce4fa4d05a 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.36-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.36-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,174 +35,160 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.36-1.js - ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) - Description: - If mon is not specified, this behaves as if mon were specified with the - value getMonth( ). If date is not specified, this behaves as if date were - specified with the value getDate( ). +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). 1. Let t be the result of LocalTime(this time value); but if this time - value is NaN, let t be +0. + value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added test cases for Year 2000 Compatilibity Testing. + Added test cases for Year 2000 Compatilibity Testing. */ - var SECTION = "15.9.5.36-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); +// 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0)), + LocalDateFromTime(SetFullYear(0,2000,0)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - // 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0)), - LocalDateFromTime(SetFullYear(0,2000,0)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,0,1)), - LocalDateFromTime(SetFullYear(0,2000,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,0,1)), + LocalDateFromTime(SetFullYear(0,2000,0,1)) ); /* - // feb 29, 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); +// feb 29, 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", +UTCDateFromTime(SetFullYear(0,2000)), +LocalDateFromTime(SetFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1)), - LocalDateFromTime(SetFullYear(0,2000,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1)), +LocalDateFromTime(SetFullYear(0,2000,1)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1,29)), - LocalDateFromTime(SetFullYear(0,2000,1,29)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", +UTCDateFromTime(SetFullYear(0,2000,1,29)), +LocalDateFromTime(SetFullYear(0,2000,1,29)) ); - // Jan 1, 2005 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", - UTCDateFromTime(SetFullYear(0,2005)), - LocalDateFromTime(SetFullYear(0,2005)) ); +// Jan 1, 2005 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", +UTCDateFromTime(SetFullYear(0,2005)), +LocalDateFromTime(SetFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0)), - LocalDateFromTime(SetFullYear(0,2005,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0)), +LocalDateFromTime(SetFullYear(0,2005,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0,1)), - LocalDateFromTime(SetFullYear(0,2005,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0,1)), +LocalDateFromTime(SetFullYear(0,2005,0,1)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetFullYear( t, year, mon, date ) { - var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; - var YEAR = Number( year ); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); - var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); - return ( TimeClip(UTC_DATE) ); -} \ No newline at end of file + return ( TimeClip(UTC_DATE) ); +} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.36-6.js b/mozilla/js/tests/ecma/Date/15.9.5.36-6.js index 79511edbfa9..5e7669d251a 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.36-6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.36-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,161 +35,146 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.36-1.js - ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) - Description: - If mon is not specified, this behaves as if mon were specified with the - value getMonth( ). If date is not specified, this behaves as if date were - specified with the value getDate( ). +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). 1. Let t be the result of LocalTime(this time value); but if this time - value is NaN, let t be +0. + value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added test cases for Year 2000 Compatilibity Testing. + Added test cases for Year 2000 Compatilibity Testing. */ - var SECTION = "15.9.5.36-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); +// feb 29, 2000 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", + UTCDateFromTime(SetFullYear(0,2000)), + LocalDateFromTime(SetFullYear(0,2000)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1)), + LocalDateFromTime(SetFullYear(0,2000,1)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - // feb 29, 2000 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000);TDATE", - UTCDateFromTime(SetFullYear(0,2000)), - LocalDateFromTime(SetFullYear(0,2000)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1)), - LocalDateFromTime(SetFullYear(0,2000,1)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", - UTCDateFromTime(SetFullYear(0,2000,1,29)), - LocalDateFromTime(SetFullYear(0,2000,1,29)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2000,1,29);TDATE", + UTCDateFromTime(SetFullYear(0,2000,1,29)), + LocalDateFromTime(SetFullYear(0,2000,1,29)) ); /* - // Jan 1, 2005 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", - UTCDateFromTime(SetFullYear(0,2005)), - LocalDateFromTime(SetFullYear(0,2005)) ); +// Jan 1, 2005 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", +UTCDateFromTime(SetFullYear(0,2005)), +LocalDateFromTime(SetFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0)), - LocalDateFromTime(SetFullYear(0,2005,0)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0)), +LocalDateFromTime(SetFullYear(0,2005,0)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0,1)), - LocalDateFromTime(SetFullYear(0,2005,0,1)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", +UTCDateFromTime(SetFullYear(0,2005,0,1)), +LocalDateFromTime(SetFullYear(0,2005,0,1)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetFullYear( t, year, mon, date ) { - var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; - var YEAR = Number( year ); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); - var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); - return ( TimeClip(UTC_DATE) ); -} \ No newline at end of file + return ( TimeClip(UTC_DATE) ); +} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.36-7.js b/mozilla/js/tests/ecma/Date/15.9.5.36-7.js index 928c8550729..ebea473b2f5 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.36-7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.36-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,146 +35,130 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.36-1.js - ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) - Description: - If mon is not specified, this behaves as if mon were specified with the - value getMonth( ). If date is not specified, this behaves as if date were - specified with the value getDate( ). +/** + File Name: 15.9.5.36-1.js + ECMA Section: 15.9.5.36 Date.prototype.setFullYear(year [, mon [, date ]] ) + Description: + + If mon is not specified, this behaves as if mon were specified with the + value getMonth( ). If date is not specified, this behaves as if date were + specified with the value getDate( ). 1. Let t be the result of LocalTime(this time value); but if this time - value is NaN, let t be +0. + value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute UTC(MakeDate(Result(5), TimeWithinDay(t))). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added test cases for Year 2000 Compatilibity Testing. + Added test cases for Year 2000 Compatilibity Testing. */ - var SECTION = "15.9.5.36-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.36-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); +// Jan 1, 2005 +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", + UTCDateFromTime(SetFullYear(0,2005)), + LocalDateFromTime(SetFullYear(0,2005)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0)), + LocalDateFromTime(SetFullYear(0,2005,0)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - // Jan 1, 2005 - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005);TDATE", - UTCDateFromTime(SetFullYear(0,2005)), - LocalDateFromTime(SetFullYear(0,2005)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", + UTCDateFromTime(SetFullYear(0,2005,0,1)), + LocalDateFromTime(SetFullYear(0,2005,0,1)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0)), - LocalDateFromTime(SetFullYear(0,2005,0)) ); +test(); - addNewTestCase( "TDATE = new Date(0);(TDATE).setFullYear(2005,0,1);TDATE", - UTCDateFromTime(SetFullYear(0,2005,0,1)), - LocalDateFromTime(SetFullYear(0,2005,0,1)) ); - -} function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); + DateCase = eval( DateString ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetFullYear( t, year, mon, date ) { - var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; - var YEAR = Number( year ); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var T = ( isNaN(t) ) ? 0 : LocalTime(t) ; + var YEAR = Number( year ); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); - var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); + var DAY = MakeDay( YEAR, MONTH, DATE ); + var UTC_DATE = UTC(MakeDate( DAY, TimeWithinDay(T))); - return ( TimeClip(UTC_DATE) ); -} \ No newline at end of file + return ( TimeClip(UTC_DATE) ); +} diff --git a/mozilla/js/tests/ecma/Date/15.9.5.37-1.js b/mozilla/js/tests/ecma/Date/15.9.5.37-1.js index 912ea8f800b..26f357c3698 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.37-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.37-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,217 +35,200 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 15.9.5.37-1.js - ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) - Description: +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: - If mon is not specified, this behaves as if mon were specified with the - value getUTCMonth( ). If date is not specified, this behaves as if date - were specified with the value getUTCDate( ). + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). 1. Let t be this time value; but if this time value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute MakeDate(Result(5), TimeWithinDay(t)). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added some Year 2000 test cases. + Added some Year 2000 test cases. */ - var SECTION = "15.9.5.37-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// Dates around 1970 - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1970);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1970)), + LocalDateFromTime(SetUTCFullYear(0,1970)) ); -function getTestCases() { +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1971);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1971)), + LocalDateFromTime(SetUTCFullYear(0,1971)) ); - // Dates around 1970 +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1972)), + LocalDateFromTime(SetUTCFullYear(0,1972)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1970);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1970)), - LocalDateFromTime(SetUTCFullYear(0,1970)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1968)), + LocalDateFromTime(SetUTCFullYear(0,1968)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1971);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1971)), - LocalDateFromTime(SetUTCFullYear(0,1971)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1972);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1972)), - LocalDateFromTime(SetUTCFullYear(0,1972)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1968);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1968)), - LocalDateFromTime(SetUTCFullYear(0,1968)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1969)), - LocalDateFromTime(SetUTCFullYear(0,1969)) ); - - addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1969)), - LocalDateFromTime(SetUTCFullYear(0,1969)) ); +addNewTestCase( "TDATE = new Date(0);(TDATE).setUTCFullYear(1969);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1969)), + LocalDateFromTime(SetUTCFullYear(0,1969)) ); /* - // Dates around 2000 +// Dates around 2000 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2000)), - LocalDateFromTime(SetUTCFullYear(0,2000)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2000)), +LocalDateFromTime(SetUTCFullYear(0,2000)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2001)), - LocalDateFromTime(SetUTCFullYear(0,2001)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2001)), +LocalDateFromTime(SetUTCFullYear(0,2001)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1999)), - LocalDateFromTime(SetUTCFullYear(0,1999)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1999)), +LocalDateFromTime(SetUTCFullYear(0,1999)) ); - // Dates around 29 February 2000 +// Dates around 29 February 2000 - var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + - 31*msPerDay + 28*msPerDay; +var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + +31*msPerDay + 28*msPerDay; - var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; +var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; - addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ - "TDATE.setUTCFullYear(2000);TDATE", - UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), - LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); +addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ +"TDATE.setUTCFullYear(2000);TDATE", +UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), +LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); - addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ - "TDATE.setUTCFullYear(2000);TDATE", - UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), - LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); +addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ +"TDATE.setUTCFullYear(2000);TDATE", +UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), +LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); - // Dates around 2005 +// Dates around 2005 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2005)), - LocalDateFromTime(SetUTCFullYear(0,2005)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2005)), +LocalDateFromTime(SetUTCFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2004)), - LocalDateFromTime(SetUTCFullYear(0,2004)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2004)), +LocalDateFromTime(SetUTCFullYear(0,2004)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2006)), - LocalDateFromTime(SetUTCFullYear(0,2006)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2006)), +LocalDateFromTime(SetUTCFullYear(0,2006)) ); - // Dates around 1900 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1900)), - LocalDateFromTime(SetUTCFullYear(0,1900)) ); +// Dates around 1900 +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1900)), +LocalDateFromTime(SetUTCFullYear(0,1900)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1899)), - LocalDateFromTime(SetUTCFullYear(0,1899)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1899)), +LocalDateFromTime(SetUTCFullYear(0,1899)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1901)), - LocalDateFromTime(SetUTCFullYear(0,1901)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1901)), +LocalDateFromTime(SetUTCFullYear(0,1901)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCFullYear( t, year, mon, date ) { - var T = ( t != t ) ? 0 : t; - var YEAR = Number(year); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); - return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.37-2.js b/mozilla/js/tests/ecma/Date/15.9.5.37-2.js index d83c1850bc8..c14ed47eadb 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.37-2.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.37-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,191 +35,174 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 15.9.5.37-1.js - ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) - Description: +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: - If mon is not specified, this behaves as if mon were specified with the - value getUTCMonth( ). If date is not specified, this behaves as if date - were specified with the value getUTCDate( ). + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). 1. Let t be this time value; but if this time value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute MakeDate(Result(5), TimeWithinDay(t)). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added some Year 2000 test cases. + Added some Year 2000 test cases. */ - var SECTION = "15.9.5.37-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// Dates around 2000 - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2000)), + LocalDateFromTime(SetUTCFullYear(0,2000)) ); -function getTestCases() { +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2001)), + LocalDateFromTime(SetUTCFullYear(0,2001)) ); - // Dates around 2000 - - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2000);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2000)), - LocalDateFromTime(SetUTCFullYear(0,2000)) ); - - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2001);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2001)), - LocalDateFromTime(SetUTCFullYear(0,2001)) ); - - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1999)), - LocalDateFromTime(SetUTCFullYear(0,1999)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1999);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1999)), + LocalDateFromTime(SetUTCFullYear(0,1999)) ); /* - // Dates around 29 February 2000 +// Dates around 29 February 2000 - var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + - 31*msPerDay + 28*msPerDay; +var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + +31*msPerDay + 28*msPerDay; - var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; +var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; - addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ - "TDATE.setUTCFullYear(2000);TDATE", - UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), - LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); +addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ +"TDATE.setUTCFullYear(2000);TDATE", +UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), +LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); - addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ - "TDATE.setUTCFullYear(2000);TDATE", - UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), - LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); +addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ +"TDATE.setUTCFullYear(2000);TDATE", +UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), +LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); - // Dates around 2005 +// Dates around 2005 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2005)), - LocalDateFromTime(SetUTCFullYear(0,2005)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2005)), +LocalDateFromTime(SetUTCFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2004)), - LocalDateFromTime(SetUTCFullYear(0,2004)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2004)), +LocalDateFromTime(SetUTCFullYear(0,2004)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2006)), - LocalDateFromTime(SetUTCFullYear(0,2006)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2006)), +LocalDateFromTime(SetUTCFullYear(0,2006)) ); - // Dates around 1900 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1900)), - LocalDateFromTime(SetUTCFullYear(0,1900)) ); +// Dates around 1900 +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1900)), +LocalDateFromTime(SetUTCFullYear(0,1900)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1899)), - LocalDateFromTime(SetUTCFullYear(0,1899)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1899)), +LocalDateFromTime(SetUTCFullYear(0,1899)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1901)), - LocalDateFromTime(SetUTCFullYear(0,1901)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1901)), +LocalDateFromTime(SetUTCFullYear(0,1901)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCFullYear( t, year, mon, date ) { - var T = ( t != t ) ? 0 : t; - var YEAR = Number(year); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); - return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.37-3.js b/mozilla/js/tests/ecma/Date/15.9.5.37-3.js index 7e11db978b3..b660c9ae069 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.37-3.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.37-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,177 +35,160 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 15.9.5.37-1.js - ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) - Description: +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: - If mon is not specified, this behaves as if mon were specified with the - value getUTCMonth( ). If date is not specified, this behaves as if date - were specified with the value getUTCDate( ). + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). 1. Let t be this time value; but if this time value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute MakeDate(Result(5), TimeWithinDay(t)). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added some Year 2000 test cases. + Added some Year 2000 test cases. */ - var SECTION = "15.9.5.37-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// Dates around 29 February 2000 - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + +31*msPerDay + 28*msPerDay; -function getTestCases() { +var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; - // Dates around 29 February 2000 +addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); - var UTC_FEB_29_1972 = TIME_1970 + TimeInYear(1970) + TimeInYear(1971) + - 31*msPerDay + 28*msPerDay; - - var PST_FEB_29_1972 = UTC_FEB_29_1972 - TZ_DIFF * msPerHour; - - addNewTestCase( "TDATE = new Date("+UTC_FEB_29_1972+"); "+ - "TDATE.setUTCFullYear(2000);TDATE", - UTCDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)), - LocalDateFromTime(SetUTCFullYear(UTC_FEB_29_1972,2000)) ); - - addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ - "TDATE.setUTCFullYear(2000);TDATE", - UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), - LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); +addNewTestCase( "TDATE = new Date("+PST_FEB_29_1972+"); "+ + "TDATE.setUTCFullYear(2000);TDATE", + UTCDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)), + LocalDateFromTime(SetUTCFullYear(PST_FEB_29_1972,2000)) ); /* - // Dates around 2005 +// Dates around 2005 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2005)), - LocalDateFromTime(SetUTCFullYear(0,2005)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2005)), +LocalDateFromTime(SetUTCFullYear(0,2005)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2004)), - LocalDateFromTime(SetUTCFullYear(0,2004)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2004)), +LocalDateFromTime(SetUTCFullYear(0,2004)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2006)), - LocalDateFromTime(SetUTCFullYear(0,2006)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", +UTCDateFromTime(SetUTCFullYear(0,2006)), +LocalDateFromTime(SetUTCFullYear(0,2006)) ); - // Dates around 1900 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1900)), - LocalDateFromTime(SetUTCFullYear(0,1900)) ); +// Dates around 1900 +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1900)), +LocalDateFromTime(SetUTCFullYear(0,1900)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1899)), - LocalDateFromTime(SetUTCFullYear(0,1899)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1899)), +LocalDateFromTime(SetUTCFullYear(0,1899)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1901)), - LocalDateFromTime(SetUTCFullYear(0,1901)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1901)), +LocalDateFromTime(SetUTCFullYear(0,1901)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCFullYear( t, year, mon, date ) { - var T = ( t != t ) ? 0 : t; - var YEAR = Number(year); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); - return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.37-4.js b/mozilla/js/tests/ecma/Date/15.9.5.37-4.js index 02116c80abc..56a101120dd 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.37-4.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.37-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,159 +35,142 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 15.9.5.37-1.js - ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) - Description: +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: - If mon is not specified, this behaves as if mon were specified with the - value getUTCMonth( ). If date is not specified, this behaves as if date - were specified with the value getUTCDate( ). + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). 1. Let t be this time value; but if this time value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute MakeDate(Result(5), TimeWithinDay(t)). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added some Year 2000 test cases. + Added some Year 2000 test cases. */ - var SECTION = "15.9.5.37-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); +// Dates around 2005 -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2005)), + LocalDateFromTime(SetUTCFullYear(0,2005)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2004)), + LocalDateFromTime(SetUTCFullYear(0,2004)) ); -function getTestCases() { - // Dates around 2005 - - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2005);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2005)), - LocalDateFromTime(SetUTCFullYear(0,2005)) ); - - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2004);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2004)), - LocalDateFromTime(SetUTCFullYear(0,2004)) ); - - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", - UTCDateFromTime(SetUTCFullYear(0,2006)), - LocalDateFromTime(SetUTCFullYear(0,2006)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(2006);TDATE", + UTCDateFromTime(SetUTCFullYear(0,2006)), + LocalDateFromTime(SetUTCFullYear(0,2006)) ); /* - // Dates around 1900 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1900)), - LocalDateFromTime(SetUTCFullYear(0,1900)) ); +// Dates around 1900 +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1900)), +LocalDateFromTime(SetUTCFullYear(0,1900)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1899)), - LocalDateFromTime(SetUTCFullYear(0,1899)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1899)), +LocalDateFromTime(SetUTCFullYear(0,1899)) ); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1901)), - LocalDateFromTime(SetUTCFullYear(0,1901)) ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", +UTCDateFromTime(SetUTCFullYear(0,1901)), +LocalDateFromTime(SetUTCFullYear(0,1901)) ); */ -} -function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); - var item = testcases.length; +test(); + +function addNewTestCase( DateString, UTCDate, LocalDate) { + DateCase = eval( DateString ); + // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCFullYear( t, year, mon, date ) { - var T = ( t != t ) ? 0 : t; - var YEAR = Number(year); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); - return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.37-5.js b/mozilla/js/tests/ecma/Date/15.9.5.37-5.js index 7d6a3fb0f7d..c14a690a82d 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.37-5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.37-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,142 +35,125 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 15.9.5.37-1.js - ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) - Description: +/** + File Name: 15.9.5.37-1.js + ECMA Section: 15.9.5.37 Date.prototype.setUTCFullYear(year [, mon [, date ]] ) + Description: - If mon is not specified, this behaves as if mon were specified with the - value getUTCMonth( ). If date is not specified, this behaves as if date - were specified with the value getUTCDate( ). + If mon is not specified, this behaves as if mon were specified with the + value getUTCMonth( ). If date is not specified, this behaves as if date + were specified with the value getUTCDate( ). 1. Let t be this time value; but if this time value is NaN, let t be +0. 2. Call ToNumber(year). 3. If mon is not specified, compute MonthFromTime(t); otherwise, call - ToNumber(mon). + ToNumber(mon). 4. If date is not specified, compute DateFromTime(t); otherwise, call - ToNumber(date). + ToNumber(date). 5. Compute MakeDay(Result(2), Result(3), Result(4)). 6. Compute MakeDate(Result(5), TimeWithinDay(t)). 7. Set the [[Value]] property of the this value to TimeClip(Result(6)). 8. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 - Added some Year 2000 test cases. + Added some Year 2000 test cases. */ - var SECTION = "15.9.5.37-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.9.5.37-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); +writeHeaderToLog( SECTION + " Date.prototype.setUTCFullYear(year [, mon [, date ]] )"); - getTestCases(); - test(); +// Dates around 1900 +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1900)), + LocalDateFromTime(SetUTCFullYear(0,1900)) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1899)), + LocalDateFromTime(SetUTCFullYear(0,1899)) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", + UTCDateFromTime(SetUTCFullYear(0,1901)), + LocalDateFromTime(SetUTCFullYear(0,1901)) ); -function getTestCases() { - // Dates around 1900 - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1900);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1900)), - LocalDateFromTime(SetUTCFullYear(0,1900)) ); +test(); - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1899);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1899)), - LocalDateFromTime(SetUTCFullYear(0,1899)) ); - - addNewTestCase( "TDATE = new Date(0); TDATE.setUTCFullYear(1901);TDATE", - UTCDateFromTime(SetUTCFullYear(0,1901)), - LocalDateFromTime(SetUTCFullYear(0,1901)) ); -} function addNewTestCase( DateString, UTCDate, LocalDate) { - DateCase = eval( DateString ); + DateCase = eval( DateString ); - var item = testcases.length; // fixed_year = ( ExpectDate.year >=1900 || ExpectDate.year < 2000 ) ? ExpectDate.year - 1900 : ExpectDate.year; - testcases[item++] = new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); - testcases[item++] = new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); + new TestCase( SECTION, DateString+".getTime()", UTCDate.value, DateCase.getTime() ); + new TestCase( SECTION, DateString+".valueOf()", UTCDate.value, DateCase.valueOf() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); + new TestCase( SECTION, DateString+".getUTCFullYear()", UTCDate.year, DateCase.getUTCFullYear() ); + new TestCase( SECTION, DateString+".getUTCMonth()", UTCDate.month, DateCase.getUTCMonth() ); + new TestCase( SECTION, DateString+".getUTCDate()", UTCDate.date, DateCase.getUTCDate() ); + new TestCase( SECTION, DateString+".getUTCDay()", UTCDate.day, DateCase.getUTCDay() ); + new TestCase( SECTION, DateString+".getUTCHours()", UTCDate.hours, DateCase.getUTCHours() ); + new TestCase( SECTION, DateString+".getUTCMinutes()", UTCDate.minutes,DateCase.getUTCMinutes() ); + new TestCase( SECTION, DateString+".getUTCSeconds()", UTCDate.seconds,DateCase.getUTCSeconds() ); + new TestCase( SECTION, DateString+".getUTCMilliseconds()", UTCDate.ms, DateCase.getUTCMilliseconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); - testcases[item++] = new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); - testcases[item++] = new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); - testcases[item++] = new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); - testcases[item++] = new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); + new TestCase( SECTION, DateString+".getFullYear()", LocalDate.year, DateCase.getFullYear() ); + new TestCase( SECTION, DateString+".getMonth()", LocalDate.month, DateCase.getMonth() ); + new TestCase( SECTION, DateString+".getDate()", LocalDate.date, DateCase.getDate() ); + new TestCase( SECTION, DateString+".getDay()", LocalDate.day, DateCase.getDay() ); + new TestCase( SECTION, DateString+".getHours()", LocalDate.hours, DateCase.getHours() ); + new TestCase( SECTION, DateString+".getMinutes()", LocalDate.minutes, DateCase.getMinutes() ); + new TestCase( SECTION, DateString+".getSeconds()", LocalDate.seconds, DateCase.getSeconds() ); + new TestCase( SECTION, DateString+".getMilliseconds()", LocalDate.ms, DateCase.getMilliseconds() ); - DateCase.toString = Object.prototype.toString; + DateCase.toString = Object.prototype.toString; - testcases[item++] = new TestCase( SECTION, - DateString+".toString=Object.prototype.toString;"+DateString+".toString()", - "[object Date]", - DateCase.toString() ); + new TestCase( SECTION, + DateString+".toString=Object.prototype.toString;"+DateString+".toString()", + "[object Date]", + DateCase.toString() ); } function MyDate() { - this.year = 0; - this.month = 0; - this.date = 0; - this.hours = 0; - this.minutes = 0; - this.seconds = 0; - this.ms = 0; + this.year = 0; + this.month = 0; + this.date = 0; + this.hours = 0; + this.minutes = 0; + this.seconds = 0; + this.ms = 0; } function LocalDateFromTime(t) { - t = LocalTime(t); - return ( MyDateFromTime(t) ); + t = LocalTime(t); + return ( MyDateFromTime(t) ); } function UTCDateFromTime(t) { - return ( MyDateFromTime(t) ); + return ( MyDateFromTime(t) ); } function MyDateFromTime( t ) { - var d = new MyDate(); - d.year = YearFromTime(t); - d.month = MonthFromTime(t); - d.date = DateFromTime(t); - d.hours = HourFromTime(t); - d.minutes = MinFromTime(t); - d.seconds = SecFromTime(t); - d.ms = msFromTime(t); + var d = new MyDate(); + d.year = YearFromTime(t); + d.month = MonthFromTime(t); + d.date = DateFromTime(t); + d.hours = HourFromTime(t); + d.minutes = MinFromTime(t); + d.seconds = SecFromTime(t); + d.ms = msFromTime(t); - d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); - d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); - d.day = WeekDay( d.value ); + d.time = MakeTime( d.hours, d.minutes, d.seconds, d.ms ); + d.value = TimeClip( MakeDate( MakeDay( d.year, d.month, d.date ), d.time ) ); + d.day = WeekDay( d.value ); - return (d); + return (d); } function SetUTCFullYear( t, year, mon, date ) { - var T = ( t != t ) ? 0 : t; - var YEAR = Number(year); - var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); - var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); - var DAY = MakeDay( YEAR, MONTH, DATE ); + var T = ( t != t ) ? 0 : t; + var YEAR = Number(year); + var MONTH = ( mon == void 0 ) ? MonthFromTime(T) : Number( mon ); + var DATE = ( date == void 0 ) ? DateFromTime(T) : Number( date ); + var DAY = MakeDay( YEAR, MONTH, DATE ); - return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); + return ( TimeClip(MakeDate(DAY, TimeWithinDay(T))) ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.4-1.js b/mozilla/js/tests/ecma/Date/15.9.5.4-1.js index 4d7ce5019ab..c313caf66fd 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.4-1.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,63 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.4-1.js - ECMA Section: 15.9.5.4-1 Date.prototype.getTime - Description: + File Name: 15.9.5.4-1.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: - 1. If the this value is not an object whose [[Class]] property is "Date", - generate a runtime error. - 2. Return this time value. - Author: christine@netscape.com - Date: 12 november 1997 + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTime"; +var SECTION = "15.9.5.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTime"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; +var now = (new Date()).valueOf(); +var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; +var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var TZ_ADJUST = TZ_DIFF * msPerHour; - var now = (new Date()).valueOf(); - var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; - var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_29_FEB_2000 ); +addTestCase( UTC_1_JAN_2005 ); - addTestCase( now ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_29_FEB_2000 ); - addTestCase( UTC_1_JAN_2005 ); - - test(); +test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+").getTime()", - t, - (new Date(t)).getTime() ); + new TestCase( SECTION, + "(new Date("+t+").getTime()", + t, + (new Date(t)).getTime() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+").getTime()", - t+1, - (new Date(t+1)).getTime() ); + new TestCase( SECTION, + "(new Date("+(t+1)+").getTime()", + t+1, + (new Date(t+1)).getTime() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+").getTime()", - t-1, - (new Date(t-1)).getTime() ); + new TestCase( SECTION, + "(new Date("+(t-1)+").getTime()", + t-1, + (new Date(t-1)).getTime() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+").getTime()", - t-TZ_ADJUST, - (new Date(t-TZ_ADJUST)).getTime() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+").getTime()", + t-TZ_ADJUST, + (new Date(t-TZ_ADJUST)).getTime() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+").getTime()", - t+TZ_ADJUST, - (new Date(t+TZ_ADJUST)).getTime() ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+").getTime()", + t+TZ_ADJUST, + (new Date(t+TZ_ADJUST)).getTime() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.4-2-n.js b/mozilla/js/tests/ecma/Date/15.9.5.4-2-n.js index 8d823434001..386a6d8ad8f 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.4-2-n.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.4-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,40 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.4-2-n.js - ECMA Section: 15.9.5.4-1 Date.prototype.getTime - Description: - 1. If the this value is not an object whose [[Class]] property is "Date", - generate a runtime error. - 2. Return this time value. - Author: christine@netscape.com - Date: 12 november 1997 +/** + File Name: 15.9.5.4-2-n.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.4-2-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getTime"; +var SECTION = "15.9.5.4-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getTime"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var MYDATE = new MyDate( TIME_2000 ); - var MYDATE = new MyDate( TIME_2000 ); +DESCRIPTION = "MYDATE.getTime()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, - "MYDATE.getTime()", - "error", - MYDATE.getTime() ); +new TestCase( SECTION, + "MYDATE.getTime()", + "error", + eval("MYDATE.getTime()") ); + +test(); function MyDate( value ) { - this.value = value; - this.getTime = Date.prototype.getTime; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + this.value = value; + this.getTime = Date.prototype.getTime; } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.5.js b/mozilla/js/tests/ecma/Date/15.9.5.5.js index 54263979bc2..8f2493b3978 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,109 +35,96 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.5.js - ECMA Section: 15.9.5.5 - Description: Date.prototype.getYear + File Name: 15.9.5.5.js + ECMA Section: 15.9.5.5 + Description: Date.prototype.getYear - This function is specified here for backwards compatibility only. The - function getFullYear is much to be preferred for nearly all purposes, - because it avoids the "year 2000 problem." + This function is specified here for backwards compatibility only. The + function getFullYear is much to be preferred for nearly all purposes, + because it avoids the "year 2000 problem." - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return YearFromTime(LocalTime(t)) 1900. + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return YearFromTime(LocalTime(t)) 1900. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getYear()"; +var SECTION = "15.9.5.5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getYear()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); +new TestCase( SECTION, + "(new Date(NaN)).getYear()", + NaN, + (new Date(NaN)).getYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getYear()", - NaN, - (new Date(NaN)).getYear() ); +new TestCase( SECTION, + "Date.prototype.getYear.length", + 0, + Date.prototype.getYear.length ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getYear.length", - 0, - Date.prototype.getYear.length ); +test(); - test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getYear()", - GetYear(YearFromTime(LocalTime(t))), - (new Date(t)).getYear() ); + new TestCase( SECTION, + "(new Date("+t+")).getYear()", + GetYear(YearFromTime(LocalTime(t))), + (new Date(t)).getYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getYear()", - GetYear(YearFromTime(LocalTime(t+1))), - (new Date(t+1)).getYear() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getYear()", + GetYear(YearFromTime(LocalTime(t+1))), + (new Date(t+1)).getYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getYear()", - GetYear(YearFromTime(LocalTime(t-1))), - (new Date(t-1)).getYear() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getYear()", + GetYear(YearFromTime(LocalTime(t-1))), + (new Date(t-1)).getYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getYear()", - GetYear(YearFromTime(LocalTime(t-TZ_ADJUST))), - (new Date(t-TZ_ADJUST)).getYear() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getYear()", + GetYear(YearFromTime(LocalTime(t-TZ_ADJUST))), + (new Date(t-TZ_ADJUST)).getYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getYear()", - GetYear(YearFromTime(LocalTime(t+TZ_ADJUST))), - (new Date(t+TZ_ADJUST)).getYear() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getYear()", + GetYear(YearFromTime(LocalTime(t+TZ_ADJUST))), + (new Date(t+TZ_ADJUST)).getYear() ); } function GetYear( year ) { /* - if ( year >= 1900 && year < 2000 ) { - return year - 1900; - } else { - return year; - } + if ( year >= 1900 && year < 2000 ) { + return year - 1900; + } else { + return year; + } */ - return year - 1900; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return year - 1900; } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.6.js b/mozilla/js/tests/ecma/Date/15.9.5.6.js index e0c70d11618..5fd2e378ee1 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.6.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,100 +35,86 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.6.js - ECMA Section: 15.9.5.6 - Description: Date.prototype.getFullYear + File Name: 15.9.5.6.js + ECMA Section: 15.9.5.6 + Description: Date.prototype.getFullYear 1. Let t be this time value. 2. If t is NaN, return NaN. 3. Return YearFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getFullYear()"; +var SECTION = "15.9.5.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getFullYear()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getFullYear()", + NaN, + (new Date(NaN)).getFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getFullYear()", - NaN, - (new Date(NaN)).getFullYear() ); +new TestCase( SECTION, + "Date.prototype.getFullYear.length", + 0, + Date.prototype.getFullYear.length ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getFullYear.length", - 0, - Date.prototype.getFullYear.length ); - - test(); +test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getFullYear()", - YearFromTime(LocalTime(t)), - (new Date(t)).getFullYear() ); + new TestCase( SECTION, + "(new Date("+t+")).getFullYear()", + YearFromTime(LocalTime(t)), + (new Date(t)).getFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getFullYear()", - YearFromTime(LocalTime(t+1)), - (new Date(t+1)).getFullYear() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getFullYear()", + YearFromTime(LocalTime(t+1)), + (new Date(t+1)).getFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getFullYear()", - YearFromTime(LocalTime(t-1)), - (new Date(t-1)).getFullYear() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getFullYear()", + YearFromTime(LocalTime(t-1)), + (new Date(t-1)).getFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getFullYear()", - YearFromTime(LocalTime(t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getFullYear() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getFullYear()", + YearFromTime(LocalTime(t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getFullYear()", - YearFromTime(LocalTime(t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getFullYear() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getFullYear()", + YearFromTime(LocalTime(t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getFullYear() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.7.js b/mozilla/js/tests/ecma/Date/15.9.5.7.js index b8bf722a4e9..5419b5171f1 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.7.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,100 +35,87 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.9.5.7.js - ECMA Section: 15.9.5.7 - Description: Date.prototype.getUTCFullYear - 1.Let t be this time value. - 2.If t is NaN, return NaN. - 3.Return YearFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 +/** + File Name: 15.9.5.7.js + ECMA Section: 15.9.5.7 + Description: Date.prototype.getUTCFullYear + + 1.Let t be this time value. + 2.If t is NaN, return NaN. + 3.Return YearFromTime(t). + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.7"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCFullYear()"; +var SECTION = "15.9.5.7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCFullYear()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getUTCFullYear()", + NaN, + (new Date(NaN)).getUTCFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCFullYear()", - NaN, - (new Date(NaN)).getUTCFullYear() ); +new TestCase( SECTION, + "Date.prototype.getUTCFullYear.length", + 0, + Date.prototype.getUTCFullYear.length ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCFullYear.length", - 0, - Date.prototype.getUTCFullYear.length ); +test(); - test(); function addTestCase( t ) { - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCFullYear()", - YearFromTime(t), - (new Date(t)).getUTCFullYear() ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCFullYear()", + YearFromTime(t), + (new Date(t)).getUTCFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCFullYear()", - YearFromTime(t+1), - (new Date(t+1)).getUTCFullYear() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCFullYear()", + YearFromTime(t+1), + (new Date(t+1)).getUTCFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCFullYear()", - YearFromTime(t-1), - (new Date(t-1)).getUTCFullYear() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCFullYear()", + YearFromTime(t-1), + (new Date(t-1)).getUTCFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCFullYear()", - YearFromTime(t-TZ_ADJUST), - (new Date(t-TZ_ADJUST)).getUTCFullYear() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCFullYear()", + YearFromTime(t-TZ_ADJUST), + (new Date(t-TZ_ADJUST)).getUTCFullYear() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCFullYear()", - YearFromTime(t+TZ_ADJUST), - (new Date(t+TZ_ADJUST)).getUTCFullYear() ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCFullYear()", + YearFromTime(t+TZ_ADJUST), + (new Date(t+TZ_ADJUST)).getUTCFullYear() ); } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.8.js b/mozilla/js/tests/ecma/Date/15.9.5.8.js index 80d5487e7a8..78a21799715 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.8.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,106 +35,93 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.8.js - ECMA Section: 15.9.5.8 - Description: Date.prototype.getMonth + File Name: 15.9.5.8.js + ECMA Section: 15.9.5.8 + Description: Date.prototype.getMonth - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return MonthFromTime(LocalTime(t)). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(LocalTime(t)). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.8"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getMonth()"; +var SECTION = "15.9.5.8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getMonth()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getMonth()", + NaN, + (new Date(NaN)).getMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getMonth()", - NaN, - (new Date(NaN)).getMonth() ); +new TestCase( SECTION, + "Date.prototype.getMonth.length", + 0, + Date.prototype.getMonth.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getMonth.length", - 0, - Date.prototype.getMonth.length ); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { + for ( var m = 0; m < 12; m++ ) { t += TimeInMonth(m); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getMonth()", - MonthFromTime(LocalTime(t)), - (new Date(t)).getMonth() ); + new TestCase( SECTION, + "(new Date("+t+")).getMonth()", + MonthFromTime(LocalTime(t)), + (new Date(t)).getMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getMonth()", - MonthFromTime(LocalTime(t+1)), - (new Date(t+1)).getMonth() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getMonth()", + MonthFromTime(LocalTime(t+1)), + (new Date(t+1)).getMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getMonth()", - MonthFromTime(LocalTime(t-1)), - (new Date(t-1)).getMonth() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getMonth()", + MonthFromTime(LocalTime(t-1)), + (new Date(t-1)).getMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getMonth()", - MonthFromTime(LocalTime(t-TZ_ADJUST)), - (new Date(t-TZ_ADJUST)).getMonth() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getMonth()", + MonthFromTime(LocalTime(t-TZ_ADJUST)), + (new Date(t-TZ_ADJUST)).getMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getMonth()", - MonthFromTime(LocalTime(t+TZ_ADJUST)), - (new Date(t+TZ_ADJUST)).getMonth() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getMonth()", + MonthFromTime(LocalTime(t+TZ_ADJUST)), + (new Date(t+TZ_ADJUST)).getMonth() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.9.js b/mozilla/js/tests/ecma/Date/15.9.5.9.js index 76f60799a9c..aea37d4e1dc 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.9.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.9.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,106 +35,93 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.9.js - ECMA Section: 15.9.5.9 - Description: Date.prototype.getUTCMonth + File Name: 15.9.5.9.js + ECMA Section: 15.9.5.9 + Description: Date.prototype.getUTCMonth - 1. Let t be this time value. - 2. If t is NaN, return NaN. - 3. Return MonthFromTime(t). + 1. Let t be this time value. + 2. If t is NaN, return NaN. + 3. Return MonthFromTime(t). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5.8"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Date.prototype.getUTCMonth()"; +var SECTION = "15.9.5.8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Date.prototype.getUTCMonth()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var TZ_ADJUST = TZ_DIFF * msPerHour; - var TZ_ADJUST = TZ_DIFF * msPerHour; +// get the current time +var now = (new Date()).valueOf(); - // get the current time - var now = (new Date()).valueOf(); +// calculate time for year 0 +for ( var time = 0, year = 1969; year >= 0; year-- ) { + time -= TimeInYear(year); +} +// get time for 29 feb 2000 - // calculate time for year 0 - for ( var time = 0, year = 1969; year >= 0; year-- ) { - time -= TimeInYear(year); - } - // get time for 29 feb 2000 +var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; - var UTC_FEB_29_2000 = TIME_2000 + 31*msPerDay + 28*msPerHour; +// get time for 1 jan 2005 - // get time for 1 jan 2005 +var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ +TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); - var UTC_JAN_1_2005 = TIME_2000 + TimeInYear(2000)+TimeInYear(2001)+ - TimeInYear(2002)+TimeInYear(2003)+TimeInYear(2004); +addTestCase( now ); +addTestCase( time ); +addTestCase( TIME_1970 ); +addTestCase( TIME_1900 ); +addTestCase( TIME_2000 ); +addTestCase( UTC_FEB_29_2000 ); +addTestCase( UTC_JAN_1_2005 ); - addTestCase( now ); - addTestCase( time ); - addTestCase( TIME_1970 ); - addTestCase( TIME_1900 ); - addTestCase( TIME_2000 ); - addTestCase( UTC_FEB_29_2000 ); - addTestCase( UTC_JAN_1_2005 ); +new TestCase( SECTION, + "(new Date(NaN)).getUTCMonth()", + NaN, + (new Date(NaN)).getUTCMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date(NaN)).getUTCMonth()", - NaN, - (new Date(NaN)).getUTCMonth() ); +new TestCase( SECTION, + "Date.prototype.getUTCMonth.length", + 0, + Date.prototype.getUTCMonth.length ); +test(); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getUTCMonth.length", - 0, - Date.prototype.getUTCMonth.length ); - test(); function addTestCase( t ) { - for ( var m = 0; m < 12; m++ ) { + for ( var m = 0; m < 12; m++ ) { t += TimeInMonth(m); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+t+")).getUTCMonth()", - MonthFromTime(t), - (new Date(t)).getUTCMonth() ); + new TestCase( SECTION, + "(new Date("+t+")).getUTCMonth()", + MonthFromTime(t), + (new Date(t)).getUTCMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+1)+")).getUTCMonth()", - MonthFromTime(t+1), - (new Date(t+1)).getUTCMonth() ); + new TestCase( SECTION, + "(new Date("+(t+1)+")).getUTCMonth()", + MonthFromTime(t+1), + (new Date(t+1)).getUTCMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-1)+")).getUTCMonth()", - MonthFromTime(t-1), - (new Date(t-1)).getUTCMonth() ); + new TestCase( SECTION, + "(new Date("+(t-1)+")).getUTCMonth()", + MonthFromTime(t-1), + (new Date(t-1)).getUTCMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t-TZ_ADJUST)+")).getUTCMonth()", - MonthFromTime(t-TZ_ADJUST), - (new Date(t-TZ_ADJUST)).getUTCMonth() ); + new TestCase( SECTION, + "(new Date("+(t-TZ_ADJUST)+")).getUTCMonth()", + MonthFromTime(t-TZ_ADJUST), + (new Date(t-TZ_ADJUST)).getUTCMonth() ); - testcases[tc++] = new TestCase( SECTION, - "(new Date("+(t+TZ_ADJUST)+")).getUTCMonth()", - MonthFromTime(t+TZ_ADJUST), - (new Date(t+TZ_ADJUST)).getUTCMonth() ); + new TestCase( SECTION, + "(new Date("+(t+TZ_ADJUST)+")).getUTCMonth()", + MonthFromTime(t+TZ_ADJUST), + (new Date(t+TZ_ADJUST)).getUTCMonth() ); - } -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + } } diff --git a/mozilla/js/tests/ecma/Date/15.9.5.js b/mozilla/js/tests/ecma/Date/15.9.5.js index e40717b484f..60a02a3f6e3 100644 --- a/mozilla/js/tests/ecma/Date/15.9.5.js +++ b/mozilla/js/tests/ecma/Date/15.9.5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,63 +35,51 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.9.5.js - ECMA Section: 15.9.5 Properties of the Date prototype object - Description: + File Name: 15.9.5.js + ECMA Section: 15.9.5 Properties of the Date prototype object + Description: - The Date prototype object is itself a Date object (its [[Class]] is - "Date") whose value is NaN. + The Date prototype object is itself a Date object (its [[Class]] is + "Date") whose value is NaN. - The value of the internal [[Prototype]] property of the Date prototype - object is the Object prototype object (15.2.3.1). + The value of the internal [[Prototype]] property of the Date prototype + object is the Object prototype object (15.2.3.1). - In following descriptions of functions that are properties of the Date - prototype object, the phrase "this Date object" refers to the object that - is the this value for the invocation of the function; it is an error if - this does not refer to an object for which the value of the internal - [[Class]] property is "Date". Also, the phrase "this time value" refers - to the number value for the time represented by this Date object, that is, - the value of the internal [[Value]] property of this Date object. + In following descriptions of functions that are properties of the Date + prototype object, the phrase "this Date object" refers to the object that + is the this value for the invocation of the function; it is an error if + this does not refer to an object for which the value of the internal + [[Class]] property is "Date". Also, the phrase "this time value" refers + to the number value for the time represented by this Date object, that is, + the value of the internal [[Value]] property of this Date object. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.9.5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the Date Prototype Object"; +var SECTION = "15.9.5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Date Prototype Object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - Date.prototype.getClass = Object.prototype.toString; +Date.prototype.getClass = Object.prototype.toString; - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.getClass", - "[object Date]", - Date.prototype.getClass() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.valueOf()", - NaN, - Date.prototype.valueOf() ); - testcases[tc++] = new TestCase( SECTION, - "Date.prototype.__proto__ == Object.prototype", - true, - Date.prototype.__proto__ == Object.prototype ); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Date.prototype.getClass", + "[object Date]", + Date.prototype.getClass() ); +new TestCase( SECTION, + "Date.prototype.valueOf()", + NaN, + Date.prototype.valueOf() ); +new TestCase( SECTION, + "Date.prototype.__proto__ == Object.prototype", + true, + Date.prototype.__proto__ == Object.prototype ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Date/browser.js b/mozilla/js/tests/ecma/Date/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Date/shell.js b/mozilla/js/tests/ecma/Date/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.3-1.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.3-1.js index 5dee331a6e7..fa730309d3f 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.3-1.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,89 +35,71 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.3-1.js - ECMA Section: 10.1.3 - Description: + File Name: 10.1.3-1.js + ECMA Section: 10.1.3 + Description: - For each formal parameter, as defined in the FormalParameterList, create - a property of the variable object whose name is the Identifier and whose - attributes are determined by the type of code. The values of the - parameters are supplied by the caller. If the caller supplies fewer - parameter values than there are formal parameters, the extra formal - parameters have value undefined. If two or more formal parameters share - the same name, hence the same property, the corresponding property is - given the value that was supplied for the last parameter with this name. - If the value of this last parameter was not supplied by the caller, - the value of the corresponding property is undefined. + For each formal parameter, as defined in the FormalParameterList, create + a property of the variable object whose name is the Identifier and whose + attributes are determined by the type of code. The values of the + parameters are supplied by the caller. If the caller supplies fewer + parameter values than there are formal parameters, the extra formal + parameters have value undefined. If two or more formal parameters share + the same name, hence the same property, the corresponding property is + given the value that was supplied for the last parameter with this name. + If the value of this last parameter was not supplied by the caller, + the value of the corresponding property is undefined. - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104191 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104191 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Variable Instantiation: Formal Parameters"; - var BUGNUMBER="104191"; +var SECTION = "10.1.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Variable Instantiation: Formal Parameters"; +var BUGNUMBER="104191"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var myfun1 = new Function( "a", "a", "return a" ); +var myfun2 = new Function( "a", "b", "a", "return a" ); - var myfun1 = new Function( "a", "a", "return a" ); - var myfun2 = new Function( "a", "b", "a", "return a" ); - - function myfun3(a, b, a) { - return a; - } - - // myfun1, myfun2, myfun3 tostring - - - testcases[tc++] = new TestCase( - SECTION, - String(myfun2) +"; myfun2(2,4,8)", - 8, - myfun2(2,4,8) ); - - testcases[tc++] = new TestCase( - SECTION, - "myfun2(2,4)", - void 0, - myfun2(2,4)); - - testcases[tc++] = new TestCase( - SECTION, - String(myfun3) +"; myfun3(2,4,8)", - 8, - myfun3(2,4,8) ); - - testcases[tc++] = new TestCase( - SECTION, - "myfun3(2,4)", - void 0, - myfun3(2,4) ); - - - - - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function myfun3(a, b, a) { + return a; } + +// myfun1, myfun2, myfun3 tostring + + +new TestCase( + SECTION, + String(myfun2) +"; myfun2(2,4,8)", + 8, + myfun2(2,4,8) ); + +new TestCase( + SECTION, + "myfun2(2,4)", + void 0, + myfun2(2,4)); + +new TestCase( + SECTION, + String(myfun3) +"; myfun3(2,4,8)", + 8, + myfun3(2,4,8) ); + +new TestCase( + SECTION, + "myfun3(2,4)", + void 0, + myfun3(2,4) ); + +test(); + diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.3.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.3.js index b87ef279da1..65ae364f3f8 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.3.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,12 +35,13 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.3.js - ECMA Section: 10.1.3.js Variable Instantiation - Description: - Author: christine@netscape.com - Date: 11 september 1997 + File Name: 10.1.3.js + ECMA Section: 10.1.3.js Variable Instantiation + Description: + Author: christine@netscape.com + Date: 11 september 1997 */ var SECTION = "10.1.3"; @@ -50,126 +52,117 @@ var BUGNUMBER = "20256"; writeHeaderToLog( SECTION + " "+ TITLE); -var testcases = getTestCases(); + +// overriding a variable or function name with a function should succeed + +new TestCase(SECTION, + "function t() { return \"first\" };" + + "function t() { return \"second\" };t() ", + "second", + eval("function t() { return \"first\" };" + + "function t() { return \"second\" };t()")); + + +new TestCase(SECTION, + "var t; function t(){}; typeof(t)", + "function", + eval("var t; function t(){}; typeof(t)")); + + +// formal parameter tests + +new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( 4 );", + void 0, + eval("function t1(a,b) { return b; }; t1( 4 );") ); + +new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(4);", + 4, + eval("function t1(a,b) { return a; }; t1(4)")); + +new TestCase(SECTION, + "function t1(a,b) { return a; }; t1();", + void 0, + eval("function t1(a,b) { return a; }; t1()")); + +new TestCase(SECTION, + "function t1(a,b) { return a; }; t1(1,2,4);", + 1, + eval("function t1(a,b) { return a; }; t1(1,2,4)")); +/* + +new TestCase(SECTION, "function t1(a,a) { return a; }; t1( 4 );", +void 0, +eval("function t1(a,a) { return a; }; t1( 4 )")); + +new TestCase(SECTION, +"function t1(a,a) { return a; }; t1( 1,2 );", +2, +eval("function t1(a,a) { return a; }; t1( 1,2 )")); +*/ +// variable declarations + +new TestCase(SECTION, + "function t1(a,b) { return a; }; t1( false, true );", + false, + eval("function t1(a,b) { return a; }; t1( false, true );")); + +new TestCase(SECTION, + "function t1(a,b) { return b; }; t1( false, true );", + true, + eval("function t1(a,b) { return b; }; t1( false, true );")); + +new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4, 2 );", + 6, + eval("function t1(a,b) { return a+b; }; t1( 4, 2 );")); + +new TestCase(SECTION, + "function t1(a,b) { return a+b; }; t1( 4 );", + Number.NaN, + eval("function t1(a,b) { return a+b; }; t1( 4 );")); + +// overriding a function name with a variable should fail + +new TestCase(SECTION, + "function t() { return 'function' };" + + "var t = 'variable'; typeof(t)", + "string", + eval("function t() { return 'function' };" + + "var t = 'variable'; typeof(t)")); + +// function as a constructor + +new TestCase(SECTION, + "function t1(a,b) { var a = b; return a; } t1(1,3);", + 3, + eval("function t1(a, b){ var a = b; return a;}; t1(1,3)")); + +new TestCase(SECTION, + "function t2(a,b) { this.a = b; } x = new t2(1,3); x.a", + 3, + eval("function t2(a,b) { this.a = b; };" + + "x = new t2(1,3); x.a")); + +new TestCase(SECTION, + "function t2(a,b) { this.a = a; } x = new t2(1,3); x.a", + 1, + eval("function t2(a,b) { this.a = a; };" + + "x = new t2(1,3); x.a")); + +new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; } " + + "x = new t2(1,3);x.a;", + 3, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.a;")); + +new TestCase(SECTION, + "function t2(a,b) { this.a = b; this.b = a; }" + + "x = new t2(1,3);x.b;", + 1, + eval("function t2(a,b) { this.a = b; this.b = a; };" + + "x = new t2(1,3);x.b;") ); test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - - // overriding a variable or function name with a function should succeed - array[item++] = - new TestCase(SECTION, - "function t() { return \"first\" };" + - "function t() { return \"second\" };t() ", - "second", - eval("function t() { return \"first\" };" + - "function t() { return \"second\" };t()")); - - array[item++] = - new TestCase(SECTION, - "var t; function t(){}; typeof(t)", - "function", - eval("var t; function t(){}; typeof(t)")); - - - // formal parameter tests - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { return b; }; t1( 4 );", - void 0, - eval("function t1(a,b) { return b; }; t1( 4 );") ); - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { return a; }; t1(4);", - 4, - eval("function t1(a,b) { return a; }; t1(4)")); - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { return a; }; t1();", - void 0, - eval("function t1(a,b) { return a; }; t1()")); - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { return a; }; t1(1,2,4);", - 1, - eval("function t1(a,b) { return a; }; t1(1,2,4)")); -/* - array[item++] = - new TestCase(SECTION, "function t1(a,a) { return a; }; t1( 4 );", - void 0, - eval("function t1(a,a) { return a; }; t1( 4 )")); - array[item++] = - new TestCase(SECTION, - "function t1(a,a) { return a; }; t1( 1,2 );", - 2, - eval("function t1(a,a) { return a; }; t1( 1,2 )")); -*/ - // variable declarations - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { return a; }; t1( false, true );", - false, - eval("function t1(a,b) { return a; }; t1( false, true );")); - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { return b; }; t1( false, true );", - true, - eval("function t1(a,b) { return b; }; t1( false, true );")); - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { return a+b; }; t1( 4, 2 );", - 6, - eval("function t1(a,b) { return a+b; }; t1( 4, 2 );")); - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { return a+b; }; t1( 4 );", - Number.NaN, - eval("function t1(a,b) { return a+b; }; t1( 4 );")); - - // overriding a function name with a variable should fail - array[item++] = - new TestCase(SECTION, - "function t() { return 'function' };" + - "var t = 'variable'; typeof(t)", - "string", - eval("function t() { return 'function' };" + - "var t = 'variable'; typeof(t)")); - - // function as a constructor - array[item++] = - new TestCase(SECTION, - "function t1(a,b) { var a = b; return a; } t1(1,3);", - 3, - eval("function t1(a, b){ var a = b; return a;}; t1(1,3)")); - array[item++] = - new TestCase(SECTION, - "function t2(a,b) { this.a = b; } x = new t2(1,3); x.a", - 3, - eval("function t2(a,b) { this.a = b; };" + - "x = new t2(1,3); x.a")); - array[item++] = - new TestCase(SECTION, - "function t2(a,b) { this.a = a; } x = new t2(1,3); x.a", - 1, - eval("function t2(a,b) { this.a = a; };" + - "x = new t2(1,3); x.a")); - array[item++] = - new TestCase(SECTION, - "function t2(a,b) { this.a = b; this.b = a; } " + - "x = new t2(1,3);x.a;", - 3, - eval("function t2(a,b) { this.a = b; this.b = a; };" + - "x = new t2(1,3);x.a;")); - array[item++] = - new TestCase(SECTION, - "function t2(a,b) { this.a = b; this.b = a; }" + - "x = new t2(1,3);x.b;", - 1, - eval("function t2(a,b) { this.a = b; this.b = a; };" + - "x = new t2(1,3);x.b;") ); - - return (array); -} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-1.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-1.js index 115af7b0491..1bed18b1044 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-1.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,82 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-1.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - var testcases = getTestCases(); +new TestCase( "SECTION", "with MyObject, eval should return square of " ); - test(); +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { + for ( tc=0; tc < testcases.length; tc++ ) { - var MYOBJECT = new MyObject(); - var INPUT = 2; - testcases[tc].description += "( " + INPUT +" )" ; + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += "( " + INPUT +" )" ; - with ( MYOBJECT ) { - testcases[tc].actual = eval( INPUT ); - testcases[tc].expect = Math.pow(INPUT,2); - } - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + with ( MYOBJECT ) { + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,2); } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( "SECTION", "with MyObject, eval should return square of " ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); - return ( array ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } function MyObject() { - this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); -} \ No newline at end of file + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-10.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-10.js index 7ea81ad7802..077c913ea59 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-10.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-10.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,76 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-10.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-10.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-10"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-10"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - var testcases = getTestCases(); +new TestCase( "SECTION", "MYOBJECT.toString()" ); - test(); +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - var VALUE = 12345; - var MYOBJECT = new Number( VALUE ); + for ( tc=0; tc < testcases.length; tc++ ) { + var VALUE = 12345; + var MYOBJECT = new Number( VALUE ); - with ( MYOBJECT ) { - testcases[tc].actual = toString(); - testcases[tc].expect = String(VALUE); - } - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + with ( MYOBJECT ) { + testcases[tc].actual = toString(); + testcases[tc].expect = String(VALUE); } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( "SECTION", "MYOBJECT.toString()" ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); - return ( array ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-2.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-2.js index ec88085f627..4d498ee4574 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-2.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,77 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-1.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-2"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-2"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - var testcases = getTestCases(); +new TestCase( "SECTION", "with MyObject, eval should return square of " ); - test(); +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { + for ( tc=0; tc < testcases.length; tc++ ) { - var MYOBJECT = new MyObject(); - var INPUT = 2; - testcases[tc].description += "( "+INPUT +" )" ; + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += "( "+INPUT +" )" ; - with ( this ) { - with ( MYOBJECT ) { - testcases[tc].actual = eval( INPUT ); - testcases[tc].expect = Math.pow(INPUT,2); - } - } - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + with ( this ) { + with ( MYOBJECT ) { + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,2); + } } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( "SECTION", "with MyObject, eval should return square of " ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); - return ( array ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } function MyObject() { - this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); -} \ No newline at end of file + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-3.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-3.js index 12a55da51fb..53dce846397 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-3.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-1.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-3"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-3"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - var testcases = getTestCases(); - test(); +new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); + +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { + for ( tc=0; tc < testcases.length; tc++ ) { - var MYOBJECT = new MyObject(); - var INPUT = 2; - testcases[tc].description += ( INPUT +"" ); + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); - with ( MYOBJECT ) { - eval( INPUT ); - } - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + with ( MYOBJECT ) { + eval( INPUT ); } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); - return ( array ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } function MyObject() { - this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); -} \ No newline at end of file + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-4.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-4.js index 81482b73492..477e4b581c0 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-4.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,77 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-1.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - var testcases = getTestCases(); - test(); +new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { + for ( tc=0; tc < testcases.length; tc++ ) { - var MYOBJECT = new MyObject(); - var INPUT = 2; - testcases[tc].description += ( INPUT +"" ); + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); - with ( MYOBJECT ) { - eval( INPUT ); - } - - testcases[tc].actual = eval( INPUT ); - testcases[tc].expect = INPUT; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + with ( MYOBJECT ) { + eval( INPUT ); } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; - return ( array ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } function MyObject() { - this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); -} \ No newline at end of file + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-5.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-5.js index a8b76ecd058..6992e4695f1 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-5.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,76 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-1.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - var testcases = getTestCases(); - test(); +new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { + for ( tc=0; tc < testcases.length; tc++ ) { - var MYOBJECT = new MyObject(); - var INPUT = 2; - testcases[tc].description += ( INPUT +"" ); + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); - with ( MYOBJECT ) { - eval = null; - } - - testcases[tc].actual = eval( INPUT ); - testcases[tc].expect = INPUT; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + with ( MYOBJECT ) { + eval = null; } - stopTest(); - return ( testcases ); + + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; + + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); - - return ( array ); -} - function MyObject() { - this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); -} \ No newline at end of file + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-6.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-6.js index 39307efe06a..3d0eaec7760 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-6.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,64 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-1.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-6"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - getTestCases(); - test(); -function getTestCases() { - testcases[0] = new TestCase( "SECTION", - "with MyObject, eval should be [object Global].eval " ); +var testcase = new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); - var MYOBJECT = new MyObject(); - var INPUT = 2; - testcases[0].description += ( INPUT +"" ); - - with ( MYOBJECT ) { - ; - } - testcases[0].actual = eval( INPUT ); - testcases[0].expect = INPUT; +var MYOBJECT = new MyObject(); +var INPUT = 2; +testcase.description += ( INPUT +"" ); +with ( MYOBJECT ) { + ; } +testcase.actual = eval( INPUT ); +testcase.expect = INPUT; + +test(); + function MyObject() { - this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); -} \ No newline at end of file + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-7.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-7.js index 66731d2d7a6..db8bb307375 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-7.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,82 +35,76 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-1.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-7.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-7"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-7"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - var testcases = getTestCases(); - test(); +new TestCase( "SECTION", + "with MyObject, eval should be [object Global].eval " ); +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { + for ( tc=0; tc < testcases.length; tc++ ) { - var MYOBJECT = new MyObject(); - var INPUT = 2; - testcases[tc].description += ( INPUT +"" ); + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); - with ( MYOBJECT ) { - delete( eval ); - testcases[tc].actual = eval( INPUT ); - testcases[tc].expect = INPUT; - } - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + with ( MYOBJECT ) { + delete( eval ); + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = INPUT; } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( "SECTION", "with MyObject, eval should be [object Global].eval " ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); - return ( array ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } function MyObject() { - this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); -} \ No newline at end of file + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-8.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-8.js index e094a83106c..58d633b5685 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-8.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,77 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-1.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-1.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "10.1.4-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - var testcases = getTestCases(); - test(); +new TestCase( "SECTION", + "with MyObject, eval should cube INPUT: " ); +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { + for ( tc=0; tc < testcases.length; tc++ ) { - var MYOBJECT = new MyObject(); - var INPUT = 2; - testcases[tc].description += ( INPUT +"" ); + var MYOBJECT = new MyObject(); + var INPUT = 2; + testcases[tc].description += ( INPUT +"" ); - with ( MYOBJECT ) { - eval = new Function ( "x", "return(Math.pow(Number(x),3))" ); + with ( MYOBJECT ) { + eval = new Function ( "x", "return(Math.pow(Number(x),3))" ); - testcases[tc].actual = eval( INPUT ); - testcases[tc].expect = Math.pow(INPUT,3); - } - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + testcases[tc].actual = eval( INPUT ); + testcases[tc].expect = Math.pow(INPUT,3); } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( "SECTION", "with MyObject, eval should cube INPUT: " ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); - return ( array ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } function MyObject() { - this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); -} \ No newline at end of file + this.eval = new Function( "x", "return(Math.pow(Number(x),2))" ); +} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-9.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-9.js index 7e778ffd1fd..c162fb8c4b0 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-9.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.4-9.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.4-9.js - ECMA Section: 10.1.4 Scope Chain and Identifier Resolution - Description: - Every execution context has associated with it a scope chain. This is - logically a list of objects that are searched when binding an Identifier. - When control enters an execution context, the scope chain is created and - is populated with an initial set of objects, depending on the type of - code. When control leaves the execution context, the scope chain is - destroyed. + File Name: 10.1.4-9.js + ECMA Section: 10.1.4 Scope Chain and Identifier Resolution + Description: + Every execution context has associated with it a scope chain. This is + logically a list of objects that are searched when binding an Identifier. + When control enters an execution context, the scope chain is created and + is populated with an initial set of objects, depending on the type of + code. When control leaves the execution context, the scope chain is + destroyed. - During execution, the scope chain of the execution context is affected - only by WithStatement. When execution enters a with block, the object - specified in the with statement is added to the front of the scope chain. - When execution leaves a with block, whether normally or via a break or - continue statement, the object is removed from the scope chain. The object - being removed will always be the first object in the scope chain. + During execution, the scope chain of the execution context is affected + only by WithStatement. When execution enters a with block, the object + specified in the with statement is added to the front of the scope chain. + When execution leaves a with block, whether normally or via a break or + continue statement, the object is removed from the scope chain. The object + being removed will always be the first object in the scope chain. - During execution, the syntactic production PrimaryExpression : Identifier - is evaluated using the following algorithm: + During execution, the syntactic production PrimaryExpression : Identifier + is evaluated using the following algorithm: - 1. Get the next object in the scope chain. If there isn't one, go to step 5. - 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as - the property. - 3. If Result(2) is true, return a value of type Reference whose base object - is Result(l) and whose property name is the Identifier. - 4. Go to step 1. - 5. Return a value of type Reference whose base object is null and whose - property name is the Identifier. - The result of binding an identifier is always a value of type Reference with - its member name component equal to the identifier string. - Author: christine@netscape.com - Date: 12 november 1997 + 1. Get the next object in the scope chain. If there isn't one, go to step 5. + 2. Call the [[HasProperty]] method of Result(l), passing the Identifier as + the property. + 3. If Result(2) is true, return a value of type Reference whose base object + is Result(l) and whose property name is the Identifier. + 4. Go to step 1. + 5. Return a value of type Reference whose base object is null and whose + property name is the Identifier. + The result of binding an identifier is always a value of type Reference with + its member name component equal to the identifier string. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.4-9"; - var VERSION = "ECMA_2"; - startTest(); +var SECTION = "10.1.4-9"; +var VERSION = "ECMA_2"; +startTest(); - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution"); - test(); +new TestCase( SECTION, "NEW_PROPERTY = " ); + +test(); function test() { - for ( tc=0; tc < testcases.length; tc++ ) { + for ( tc=0; tc < testcases.length; tc++ ) { - var MYOBJECT = new MyObject(); - var RESULT = "hello"; + var MYOBJECT = new MyObject(); + var RESULT = "hello"; - with ( MYOBJECT ) { - NEW_PROPERTY = RESULT; - } - testcases[tc].actual = NEW_PROPERTY; - testcases[tc].expect = RESULT; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + with ( MYOBJECT ) { + NEW_PROPERTY = RESULT; } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; + testcases[tc].actual = NEW_PROPERTY; + testcases[tc].expect = RESULT; - array[item++] = new TestCase( SECTION, "NEW_PROPERTY = " ); + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); - return ( array ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } function MyObject( n ) { - this.__proto__ = Number.prototype; + this.__proto__ = Number.prototype; } diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-1.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-1.js index ebe490eab04..b1f602d16a6 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-1.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 10.1.5-1.js ECMA Section: 10.1.5 Global Object @@ -61,7 +63,8 @@ writeHeaderToLog( SECTION + " Global Ojbect"); - var testcases = getTestCases(); + + new TestCase( "SECTION", "Global Code check" ); if ( Object == null ) { testcases[0].reason += " Object == null" ; @@ -111,23 +114,3 @@ test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( "SECTION", "Global Code check" ); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-2.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-2.js index ea2374475d8..63c21d5abcd 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-2.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 10.1.5-2.js ECMA Section: 10.1.5 Global Object @@ -61,7 +63,7 @@ writeHeaderToLog( SECTION + " Global Ojbect"); - var testcases = getTestCases(); + new TestCase( "SECTION", "Eval Code check" ); var EVAL_STRING = 'if ( Object == null ) { testcases[0].reason += " Object == null" ; }' + 'if ( Function == null ) { testcases[0].reason += " Function == null"; }' + @@ -94,23 +96,3 @@ test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual + " "+ - testcases[tc].reason ); - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( "SECTION", "Eval Code check" ); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-3.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-3.js index 211dd7372a8..6ff1f76b96e 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-3.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 10.1.5-3.js ECMA Section: 10.1.5 Global Object @@ -60,7 +62,7 @@ startTest(); writeHeaderToLog( SECTION + " Global Ojbect"); - var testcases = getTestCases(); + new TestCase( "SECTION", "Function Code check" ); test(); @@ -124,11 +126,3 @@ function test() { stopTest(); return ( testcases ); } -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( "SECTION", "Function Code check" ); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-4.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-4.js index d97d14dcee8..a655da88983 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-4.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.5-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 10.1.5-4.js ECMA Section: 10.1.5 Global Object @@ -61,7 +63,8 @@ writeHeaderToLog( SECTION + " Global Ojbect"); - var testcases = getTestCases(); + new TestCase( "SECTION", "Anonymous Code check" ); + var EVAL_STRING = 'if ( Object == null ) { testcases[0].reason += " Object == null" ; }' + 'if ( Function == null ) { testcases[0].reason += " Function == null"; }' + @@ -84,26 +87,3 @@ testcases[0].expect = "pass"; test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual + " "+ - testcases[tc].reason ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( "SECTION", "Anonymous Code check" ); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.6.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.6.js index f6d102bbd9b..a15155b3691 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.6.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,106 +35,91 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.6 - ECMA Section: Activation Object - Description: + File Name: 10.1.6 + ECMA Section: Activation Object + Description: - If the function object being invoked has an arguments property, let x be - the value of that property; the activation object is also given an internal - property [[OldArguments]] whose initial value is x; otherwise, an arguments - property is created for the function object but the activation object is - not given an [[OldArguments]] property. Next, arguments object described - below (the same one stored in the arguments property of the activation - object) is used as the new value of the arguments property of the function - object. This new value is installed even if the arguments property already - exists and has the ReadOnly attribute (as it will for native Function - objects). (These actions are taken to provide compatibility with a form of - program syntax that is now discouraged: to access the arguments object for - function f within the body of f by using the expression f.arguments. - The recommended way to access the arguments object for function f within - the body of f is simply to refer to the variable arguments.) + If the function object being invoked has an arguments property, let x be + the value of that property; the activation object is also given an internal + property [[OldArguments]] whose initial value is x; otherwise, an arguments + property is created for the function object but the activation object is + not given an [[OldArguments]] property. Next, arguments object described + below (the same one stored in the arguments property of the activation + object) is used as the new value of the arguments property of the function + object. This new value is installed even if the arguments property already + exists and has the ReadOnly attribute (as it will for native Function + objects). (These actions are taken to provide compatibility with a form of + program syntax that is now discouraged: to access the arguments object for + function f within the body of f by using the expression f.arguments. + The recommended way to access the arguments object for function f within + the body of f is simply to refer to the variable arguments.) - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Activation Object"; +var SECTION = "10.1.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Activation Object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var arguments = "FAILED!"; - var arguments = "FAILED!"; +var ARG_STRING = "value of the argument property"; - var ARG_STRING = "value of the argument property"; +new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5)).length", + 6, + (new TestObject(0,1,2,3,4,5)).length ); - testcases[tc++] = new TestCase( SECTION, - "(new TestObject(0,1,2,3,4,5)).length", - 6, - (new TestObject(0,1,2,3,4,5)).length ); +for ( i = 0; i < 6; i++ ) { - for ( i = 0; i < 6; i++ ) { - - testcases[tc++] = new TestCase( SECTION, - "(new TestObject(0,1,2,3,4,5))["+i+"]", - i, - (new TestObject(0,1,2,3,4,5))[i]); - } + new TestCase( SECTION, + "(new TestObject(0,1,2,3,4,5))["+i+"]", + i, + (new TestObject(0,1,2,3,4,5))[i]); +} - // The current object already has an arguments property. +// The current object already has an arguments property. - testcases[tc++] = new TestCase( SECTION, - "(new AnotherTestObject(1,2,3)).arguments", - ARG_STRING, - (new AnotherTestObject(1,2,3)).arguments ); +new TestCase( SECTION, + "(new AnotherTestObject(1,2,3)).arguments", + ARG_STRING, + (new AnotherTestObject(1,2,3)).arguments ); - // The function invoked with [[Call]] +// The function invoked with [[Call]] - testcases[tc++] = new TestCase( SECTION, - "TestFunction(1,2,3)", - ARG_STRING, - TestFunction() + '' ); +new TestCase( SECTION, + "TestFunction(1,2,3)", + ARG_STRING, + TestFunction() + '' ); - test(); +test(); function Prototype() { - this.arguments = ARG_STRING; + this.arguments = ARG_STRING; } function TestObject() { - this.__proto__ = new Prototype(); - return arguments; + this.__proto__ = new Prototype(); + return arguments; } function AnotherTestObject() { - this.__proto__ = new Prototype(); - return this; + this.__proto__ = new Prototype(); + return this; } function TestFunction() { - arguments = ARG_STRING; - return arguments; + arguments = ARG_STRING; + return arguments; } function AnotherTestFunction() { - this.__proto__ = new Prototype(); - return this; -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + this.__proto__ = new Prototype(); + return this; } diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.8-1.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.8-1.js index 4521f98a86c..5403594057b 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.8-1.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.8-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,114 +35,99 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.8 - ECMA Section: Arguments Object - Description: + File Name: 10.1.8 + ECMA Section: Arguments Object + Description: - When control enters an execution context for declared function code, - anonymous code, or implementation-supplied code, an arguments object is - created and initialized as follows: + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: - The [[Prototype]] of the arguments object is to the original Object - prototype object, the one that is the initial value of Object.prototype - (section 15.2.3.1). + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). - A property is created with name callee and property attributes {DontEnum}. - The initial value of this property is the function object being executed. - This allows anonymous functions to be recursive. + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. - A property is created with name length and property attributes {DontEnum}. - The initial value of this property is the number of actual parameter values - supplied by the caller. + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. - For each non-negative integer, iarg, less than the value of the length - property, a property is created with name ToString(iarg) and property - attributes { DontEnum }. The initial value of this property is the value - of the corresponding actual parameter supplied by the caller. The first - actual parameter value corresponds to iarg = 0, the second to iarg = 1 and - so on. In the case when iarg is less than the number of formal parameters - for the function object, this property shares its value with the - corresponding property of the activation object. This means that changing - this property changes the corresponding property of the activation object - and vice versa. The value sharing mechanism depends on the implementation. + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.8"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Arguments Object"; +var SECTION = "10.1.8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Arguments Object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var ARG_STRING = "value of the argument property"; - var ARG_STRING = "value of the argument property"; +new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); - testcases[tc++] = new TestCase( SECTION, - "GetCallee()", - GetCallee, - GetCallee() ); +var LIMIT = 100; - var LIMIT = 100; +for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); - for ( var i = 0, args = "" ; i < LIMIT; i++ ) { - args += String(i) + ( i+1 < LIMIT ? "," : "" ); +} - } +var LENGTH = eval( "GetLength("+ args +")" ); - var LENGTH = eval( "GetLength("+ args +")" ); +new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); - testcases[tc++] = new TestCase( SECTION, - "GetLength("+args+")", - 100, - LENGTH ); +var ARGUMENTS = eval( "GetArguments( " +args+")" ); - var ARGUMENTS = eval( "GetArguments( " +args+")" ); +for ( var i = 0; i < 100; i++ ) { + new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); +} - for ( var i = 0; i < 100; i++ ) { - testcases[tc++] = new TestCase( SECTION, - "GetArguments("+args+")["+i+"]", - i, - ARGUMENTS[i] ); - } - - test(); +test(); function TestFunction() { - var arg_proto = arguments.__proto__; + var arg_proto = arguments.__proto__; } function GetCallee() { - var c = arguments.callee; - return c; + var c = arguments.callee; + return c; } function GetArguments() { - var a = arguments; - return a; + var a = arguments; + return a; } function GetLength() { - var l = arguments.length; - return l; + var l = arguments.length; + return l; } function AnotherTestFunction() { - this.__proto__ = new Prototype(); - return this; -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + this.__proto__ = new Prototype(); + return this; } diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.1.8-2.js b/mozilla/js/tests/ecma/ExecutionContexts/10.1.8-2.js index 0edba7327dd..db3f8978567 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.1.8-2.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.1.8-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,99 +35,84 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.1.8-2 - ECMA Section: Arguments Object - Description: + File Name: 10.1.8-2 + ECMA Section: Arguments Object + Description: - When control enters an execution context for declared function code, - anonymous code, or implementation-supplied code, an arguments object is - created and initialized as follows: + When control enters an execution context for declared function code, + anonymous code, or implementation-supplied code, an arguments object is + created and initialized as follows: - The [[Prototype]] of the arguments object is to the original Object - prototype object, the one that is the initial value of Object.prototype - (section 15.2.3.1). + The [[Prototype]] of the arguments object is to the original Object + prototype object, the one that is the initial value of Object.prototype + (section 15.2.3.1). - A property is created with name callee and property attributes {DontEnum}. - The initial value of this property is the function object being executed. - This allows anonymous functions to be recursive. + A property is created with name callee and property attributes {DontEnum}. + The initial value of this property is the function object being executed. + This allows anonymous functions to be recursive. - A property is created with name length and property attributes {DontEnum}. - The initial value of this property is the number of actual parameter values - supplied by the caller. + A property is created with name length and property attributes {DontEnum}. + The initial value of this property is the number of actual parameter values + supplied by the caller. - For each non-negative integer, iarg, less than the value of the length - property, a property is created with name ToString(iarg) and property - attributes { DontEnum }. The initial value of this property is the value - of the corresponding actual parameter supplied by the caller. The first - actual parameter value corresponds to iarg = 0, the second to iarg = 1 and - so on. In the case when iarg is less than the number of formal parameters - for the function object, this property shares its value with the - corresponding property of the activation object. This means that changing - this property changes the corresponding property of the activation object - and vice versa. The value sharing mechanism depends on the implementation. + For each non-negative integer, iarg, less than the value of the length + property, a property is created with name ToString(iarg) and property + attributes { DontEnum }. The initial value of this property is the value + of the corresponding actual parameter supplied by the caller. The first + actual parameter value corresponds to iarg = 0, the second to iarg = 1 and + so on. In the case when iarg is less than the number of formal parameters + for the function object, this property shares its value with the + corresponding property of the activation object. This means that changing + this property changes the corresponding property of the activation object + and vice versa. The value sharing mechanism depends on the implementation. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.1.8-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Arguments Object"; +var SECTION = "10.1.8-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Arguments Object"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +writeHeaderToLog( SECTION + " "+ TITLE); // Tests for anonymous functions - var GetCallee = new Function( "var c = arguments.callee; return c" ); - var GetArguments = new Function( "var a = arguments; return a" ); - var GetLength = new Function( "var l = arguments.length; return l" ); +var GetCallee = new Function( "var c = arguments.callee; return c" ); +var GetArguments = new Function( "var a = arguments; return a" ); +var GetLength = new Function( "var l = arguments.length; return l" ); - var ARG_STRING = "value of the argument property"; +var ARG_STRING = "value of the argument property"; - testcases[tc++] = new TestCase( SECTION, - "GetCallee()", - GetCallee, - GetCallee() ); +new TestCase( SECTION, + "GetCallee()", + GetCallee, + GetCallee() ); - var LIMIT = 100; +var LIMIT = 100; - for ( var i = 0, args = "" ; i < LIMIT; i++ ) { - args += String(i) + ( i+1 < LIMIT ? "," : "" ); +for ( var i = 0, args = "" ; i < LIMIT; i++ ) { + args += String(i) + ( i+1 < LIMIT ? "," : "" ); - } - - var LENGTH = eval( "GetLength("+ args +")" ); - - testcases[tc++] = new TestCase( SECTION, - "GetLength("+args+")", - 100, - LENGTH ); - - var ARGUMENTS = eval( "GetArguments( " +args+")" ); - - for ( var i = 0; i < 100; i++ ) { - testcases[tc++] = new TestCase( SECTION, - "GetArguments("+args+")["+i+"]", - i, - ARGUMENTS[i] ); - } - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); } + +var LENGTH = eval( "GetLength("+ args +")" ); + +new TestCase( SECTION, + "GetLength("+args+")", + 100, + LENGTH ); + +var ARGUMENTS = eval( "GetArguments( " +args+")" ); + +for ( var i = 0; i < 100; i++ ) { + new TestCase( SECTION, + "GetArguments("+args+")["+i+"]", + i, + ARGUMENTS[i] ); +} + +test(); diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.2.1.js b/mozilla/js/tests/ecma/ExecutionContexts/10.2.1.js index 1bb4b97d503..009509d5c5a 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.2.1.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.2.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,64 +35,49 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.2.1.js - ECMA Section: 10.2.1 Global Code - Description: + File Name: 10.2.1.js + ECMA Section: 10.2.1 Global Code + Description: - The scope chain is created and initialized to contain the global object and - no others. + The scope chain is created and initialized to contain the global object and + no others. - Variable instantiation is performed using the global object as the variable - object and using empty property attributes. + Variable instantiation is performed using the global object as the variable + object and using empty property attributes. - The this value is the global object. - Author: christine@netscape.com - Date: 12 november 1997 + The this value is the global object. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.2.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Global Code"; +var SECTION = "10.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Global Code"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var THIS = this; - var THIS = this; +new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); - testcases[tc++] = new TestCase( SECTION, - "this +''", - GLOBAL, - THIS + "" ); +var GLOBAL_PROPERTIES = new Array(); +var i = 0; - var GLOBAL_PROPERTIES = new Array(); - var i = 0; - - for ( p in this ) { - GLOBAL_PROPERTIES[i++] = p; - } - - for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { - testcases[tc++] = new TestCase( SECTION, - GLOBAL_PROPERTIES[i] +" == void 0", - false, - eval("GLOBAL_PROPERTIES["+i+"] == void 0")); - } - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; } + +for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == void 0", + false, + eval("GLOBAL_PROPERTIES["+i+"] == void 0")); +} + +test(); diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.2.2-1.js b/mozilla/js/tests/ecma/ExecutionContexts/10.2.2-1.js index aa0a93fdf6a..29ec4a87a96 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.2.2-1.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.2.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,101 +35,86 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.2.2-1.js - ECMA Section: 10.2.2 Eval Code - Description: + File Name: 10.2.2-1.js + ECMA Section: 10.2.2 Eval Code + Description: - When control enters an execution context for eval code, the previous - active execution context, referred to as the calling context, is used to - determine the scope chain, the variable object, and the this value. If - there is no calling context, then initializing the scope chain, variable - instantiation, and determination of the this value are performed just as - for global code. + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. - The scope chain is initialized to contain the same objects, in the same - order, as the calling context's scope chain. This includes objects added - to the calling context's scope chain by WithStatement. + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. - Variable instantiation is performed using the calling context's variable - object and using empty property attributes. + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. - The this value is the same as the this value of the calling context. + The this value is the same as the this value of the calling context. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.2.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Eval Code"; +var SECTION = "10.2.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Eval Code"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var THIS = eval("this"); - var THIS = eval("this"); +new TestCase( SECTION, + "this +''", + GLOBAL, + THIS + "" ); - testcases[tc++] = new TestCase( SECTION, - "this +''", - GLOBAL, - THIS + "" ); +var GLOBAL_PROPERTIES = new Array(); +var i = 0; - var GLOBAL_PROPERTIES = new Array(); - var i = 0; - - for ( p in THIS ) { - GLOBAL_PROPERTIES[i++] = p; - } - - for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { - testcases[tc++] = new TestCase( SECTION, - GLOBAL_PROPERTIES[i] +" == THIS["+GLOBAL_PROPERTIES[i]+"]", - true, - eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); - } - - // this in eval statements is the same as this value of the calling context - - var RESULT = THIS == this; - - testcases[tc++] = new TestCase( SECTION, - "eval( 'this == THIS' )", - true, - RESULT ); - - var RESULT = THIS +''; - - testcases[tc++] = new TestCase( SECTION, - "eval( 'this + \"\"' )", - GLOBAL, - RESULT ); - - - testcases[tc++] = new TestCase( SECTION, - "eval( 'this == THIS' )", - true, - eval( "this == THIS" ) ); - - testcases[tc++] = new TestCase( SECTION, - "eval( 'this + \"\"' )", - GLOBAL, - eval( "this +''") ); - - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( p in THIS ) { + GLOBAL_PROPERTIES[i++] = p; } + +for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + new TestCase( SECTION, + GLOBAL_PROPERTIES[i] +" == THIS["+GLOBAL_PROPERTIES[i]+"]", + true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); +} + +// this in eval statements is the same as this value of the calling context + +var RESULT = THIS == this; + +new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + RESULT ); + +var RESULT = THIS +''; + +new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + RESULT ); + + +new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + eval( "this == THIS" ) ); + +new TestCase( SECTION, + "eval( 'this + \"\"' )", + GLOBAL, + eval( "this +''") ); + + +test(); diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.2.2-2.js b/mozilla/js/tests/ecma/ExecutionContexts/10.2.2-2.js index df6012a1dd7..beb6859b51a 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.2.2-2.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.2.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,87 +35,97 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.2.2-2.js - ECMA Section: 10.2.2 Eval Code - Description: + File Name: 10.2.2-2.js + ECMA Section: 10.2.2 Eval Code + Description: - When control enters an execution context for eval code, the previous - active execution context, referred to as the calling context, is used to - determine the scope chain, the variable object, and the this value. If - there is no calling context, then initializing the scope chain, variable - instantiation, and determination of the this value are performed just as - for global code. + When control enters an execution context for eval code, the previous + active execution context, referred to as the calling context, is used to + determine the scope chain, the variable object, and the this value. If + there is no calling context, then initializing the scope chain, variable + instantiation, and determination of the this value are performed just as + for global code. - The scope chain is initialized to contain the same objects, in the same - order, as the calling context's scope chain. This includes objects added - to the calling context's scope chain by WithStatement. + The scope chain is initialized to contain the same objects, in the same + order, as the calling context's scope chain. This includes objects added + to the calling context's scope chain by WithStatement. - Variable instantiation is performed using the calling context's variable - object and using empty property attributes. + Variable instantiation is performed using the calling context's variable + object and using empty property attributes. - The this value is the same as the this value of the calling context. + The this value is the same as the this value of the calling context. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.2.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Eval Code"; +var SECTION = "10.2.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Eval Code"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// Test Objects - // Test Objects +var OBJECT = new MyObject( "hello" ); +var GLOBAL_PROPERTIES = new Array(); +var i = 0; - var OBJECT = new MyObject( "hello" ); - var GLOBAL_PROPERTIES = new Array(); - var i = 0; - - for ( p in this ) { - GLOBAL_PROPERTIES[i++] = p; - } - - with ( OBJECT ) { - var THIS = this; - testcases[tc++] = new TestCase( SECTION, "eval( 'this == THIS' )", true, eval("this == THIS") ); - testcases[tc++] = new TestCase( SECTION, "this in a with() block", GLOBAL, this+"" ); - testcases[tc++] = new TestCase( SECTION, "new MyObject('hello').value", "hello", value ); - testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').value)", "hello", eval("value") ); - testcases[tc++] = new TestCase( SECTION, "new MyObject('hello').getClass()", "[object Object]", getClass() ); - testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').getClass())", "[object Object]", eval("getClass()") ); - testcases[tc++] = new TestCase( SECTION, "eval(new MyObject('hello').toString())", "hello", eval("toString()") ); - testcases[tc++] = new TestCase( SECTION, "eval('getClass') == Object.prototype.toString", true, eval("getClass") == Object.prototype.toString ); - - for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { - testcases[tc++] = new TestCase( SECTION, GLOBAL_PROPERTIES[i] + - " == THIS["+GLOBAL_PROPERTIES[i]+"]", true, - eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); - } - - } - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( p in this ) { + GLOBAL_PROPERTIES[i++] = p; } + +with ( OBJECT ) { + var THIS = this; + new TestCase( SECTION, + "eval( 'this == THIS' )", + true, + eval("this == THIS") ); + new TestCase( SECTION, + "this in a with() block", + GLOBAL, + this+"" ); + new TestCase( SECTION, + "new MyObject('hello').value", + "hello", + value ); + new TestCase( SECTION, + "eval(new MyObject('hello').value)", + "hello", + eval("value") ); + new TestCase( SECTION, + "new MyObject('hello').getClass()", + "[object Object]", + getClass() ); + new TestCase( SECTION, + "eval(new MyObject('hello').getClass())", + "[object Object]", + eval("getClass()") ); + new TestCase( SECTION, + "eval(new MyObject('hello').toString())", + "hello", + eval("toString()") ); + new TestCase( SECTION, + "eval('getClass') == Object.prototype.toString", + true, + eval("getClass") == Object.prototype.toString ); + + for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { + new TestCase( SECTION, GLOBAL_PROPERTIES[i] + + " == THIS["+GLOBAL_PROPERTIES[i]+"]", true, + eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); + } + +} + +test(); + function MyObject( value ) { - this.value = value; - this.getClass = Object.prototype.toString; - this.toString = new Function( "return this.value+''" ); - return this; + this.value = value; + this.getClass = Object.prototype.toString; + this.toString = new Function( "return this.value+''" ); + return this; } diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.2.3-1.js b/mozilla/js/tests/ecma/ExecutionContexts/10.2.3-1.js index e7bed3014bc..c20c1c62428 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.2.3-1.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.2.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,50 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.2.3-1.js - ECMA Section: 10.2.3 Function and Anonymous Code - Description: + File Name: 10.2.3-1.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: - The scope chain is initialized to contain the activation object followed - by the global object. Variable instantiation is performed using the - activation by the global object. Variable instantiation is performed using - the activation object as the variable object and using property attributes - { DontDelete }. The caller provides the this value. If the this value - provided by the caller is not an object (including the case where it is - null), then the this value is the global object. + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.2.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Eval Code"; +var SECTION = "10.2.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Eval Code"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var o = new MyObject("hello") - var o = new MyObject("hello") + new TestCase( SECTION, + "var o = new MyObject('hello'); o.THIS == x", + true, + o.THIS == o ); - testcases[tc++] = new TestCase( SECTION, - "var o = new MyObject('hello'); o.THIS == x", - true, - o.THIS == o ); +var o = MyFunction(); - var o = MyFunction(); +new TestCase( SECTION, + "var o = MyFunction(); o == this", + true, + o == this ); - testcases[tc++] = new TestCase( SECTION, - "var o = MyFunction(); o == this", - true, - o == this ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); function MyFunction( value ) { - return this; + return this; } function MyObject( value ) { - this.THIS = this; + this.THIS = this; } diff --git a/mozilla/js/tests/ecma/ExecutionContexts/10.2.3-2.js b/mozilla/js/tests/ecma/ExecutionContexts/10.2.3-2.js index 3a5c350d5d6..6b0649284fe 100644 --- a/mozilla/js/tests/ecma/ExecutionContexts/10.2.3-2.js +++ b/mozilla/js/tests/ecma/ExecutionContexts/10.2.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,71 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 10.2.3-2.js - ECMA Section: 10.2.3 Function and Anonymous Code - Description: + File Name: 10.2.3-2.js + ECMA Section: 10.2.3 Function and Anonymous Code + Description: - The scope chain is initialized to contain the activation object followed - by the global object. Variable instantiation is performed using the - activation by the global object. Variable instantiation is performed using - the activation object as the variable object and using property attributes - { DontDelete }. The caller provides the this value. If the this value - provided by the caller is not an object (including the case where it is - null), then the this value is the global object. + The scope chain is initialized to contain the activation object followed + by the global object. Variable instantiation is performed using the + activation by the global object. Variable instantiation is performed using + the activation object as the variable object and using property attributes + { DontDelete }. The caller provides the this value. If the this value + provided by the caller is not an object (including the case where it is + null), then the this value is the global object. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "10.2.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function and Anonymous Code"; +var SECTION = "10.2.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function and Anonymous Code"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var o = new MyObject("hello"); - var o = new MyObject("hello") +new TestCase( SECTION, + "MyFunction(\"PASSED!\")", + "PASSED!", + MyFunction("PASSED!") ); - testcases[tc++] = new TestCase( SECTION, - "MyFunction(\"PASSED!\")", - "PASSED!", - MyFunction("PASSED!") ); +var o = MyFunction(); - var o = MyFunction(); +new TestCase( SECTION, + "MyOtherFunction(true);", + false, + MyOtherFunction(true) ); - testcases[tc++] = new TestCase( SECTION, - "MyOtherFunction(true);", - false, - MyOtherFunction(true) ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); function MyFunction( value ) { - var x = value; - delete x; - return x; + var x = value; + delete x; + return x; } function MyOtherFunction(value) { - var x = value; - return delete x; + var x = value; + return delete x; } function MyObject( value ) { - this.THIS = this; + this.THIS = this; } diff --git a/mozilla/js/tests/ecma/ExecutionContexts/browser.js b/mozilla/js/tests/ecma/ExecutionContexts/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/ExecutionContexts/shell.js b/mozilla/js/tests/ecma/ExecutionContexts/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Expressions/11.1.1.js b/mozilla/js/tests/ecma/Expressions/11.1.1.js index b5410ad6dbe..4d2584e1311 100644 --- a/mozilla/js/tests/ecma/Expressions/11.1.1.js +++ b/mozilla/js/tests/ecma/Expressions/11.1.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,117 +35,101 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.1.1.js - ECMA Section: 11.1.1 The this keyword - Description: + File Name: 11.1.1.js + ECMA Section: 11.1.1 The this keyword + Description: - The this keyword evaluates to the this value of the execution context. + The this keyword evaluates to the this value of the execution context. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.1.1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "11.1.1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The this keyword"); +writeHeaderToLog( SECTION + " The this keyword"); - var testcases = new Array(); - var item = 0; +var GLOBAL_OBJECT = this.toString(); - var GLOBAL_OBJECT = this.toString(); +// this in global code and eval(this) in global code should return the global object. - // this in global code and eval(this) in global code should return the global object. +new TestCase( SECTION, + "Global Code: this.toString()", + GLOBAL_OBJECT, + this.toString() ); - testcases[item++] = new TestCase( SECTION, - "Global Code: this.toString()", - GLOBAL_OBJECT, - this.toString() ); +new TestCase( SECTION, + "Global Code: eval('this.toString()')", + GLOBAL_OBJECT, + eval('this.toString()') ); - testcases[item++] = new TestCase( SECTION, - "Global Code: eval('this.toString()')", - GLOBAL_OBJECT, - eval('this.toString()') ); +// this in anonymous code called as a function should return the global object. - // this in anonymous code called as a function should return the global object. +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('return this.toString()'); MYFUNC()", + GLOBAL_OBJECT, + eval("var MYFUNC = new Function('return this.toString()'); MYFUNC()") ); - testcases[item++] = new TestCase( SECTION, - "Anonymous Code: var MYFUNC = new Function('return this.toString()'); MYFUNC()", - GLOBAL_OBJECT, - eval("var MYFUNC = new Function('return this.toString()'); MYFUNC()") ); +// eval( this ) in anonymous code called as a function should return that function's activation object - // eval( this ) in anonymous code called as a function should return that function's activation object +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('return (eval(\"this.toString()\")'); (MYFUNC()).toString()", + GLOBAL_OBJECT, + eval("var MYFUNC = new Function('return eval(\"this.toString()\")'); (MYFUNC()).toString()") ); - testcases[item++] = new TestCase( SECTION, - "Anonymous Code: var MYFUNC = new Function('return (eval(\"this.toString()\")'); (MYFUNC()).toString()", - GLOBAL_OBJECT, - eval("var MYFUNC = new Function('return eval(\"this.toString()\")'); (MYFUNC()).toString()") ); +// this and eval( this ) in anonymous code called as a constructor should return the object - // this and eval( this ) in anonymous code called as a constructor should return the object +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()", + "[object Object]", + eval("var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()") ); - testcases[item++] = new TestCase( SECTION, - "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()", - "[object Object]", - eval("var MYFUNC = new Function('this.THIS = this'); ((new MYFUNC()).THIS).toString()") ); +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", + true, + eval("var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); - testcases[item++] = new TestCase( SECTION, - "Anonymous Code: var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", - true, - eval("var MYFUNC = new Function('this.THIS = this'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC().THIS).toString()", + "[object Object]", + eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC()).THIS).toString()") ); - testcases[item++] = new TestCase( SECTION, - "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC().THIS).toString()", - "[object Object]", - eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); ((new MYFUNC()).THIS).toString()") ); +new TestCase( SECTION, + "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", + true, + eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); - testcases[item++] = new TestCase( SECTION, - "Anonymous Code: var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1", - true, - eval("var MYFUNC = new Function('this.THIS = eval(\"this\")'); var FUN1 = new MYFUNC(); FUN1.THIS == FUN1") ); +// this and eval(this) in function code called as a function should return the global object. +new TestCase( SECTION, + "Function Code: ReturnThis()", + GLOBAL_OBJECT, + ReturnThis() ); - // this and eval(this) in function code called as a function should return the global object. - testcases[item++] = new TestCase( SECTION, - "Function Code: ReturnThis()", - GLOBAL_OBJECT, - ReturnThis() ); +new TestCase( SECTION, + "Function Code: ReturnEvalThis()", + GLOBAL_OBJECT, + ReturnEvalThis() ); - testcases[item++] = new TestCase( SECTION, - "Function Code: ReturnEvalThis()", - GLOBAL_OBJECT, - ReturnEvalThis() ); +// this and eval(this) in function code called as a contructor should return the object. +new TestCase( SECTION, + "var MYOBJECT = new ReturnThis(); MYOBJECT.toString()", + "[object Object]", + eval("var MYOBJECT = new ReturnThis(); MYOBJECT.toString()") ); - // this and eval(this) in function code called as a contructor should return the object. - testcases[item++] = new TestCase( SECTION, - "var MYOBJECT = new ReturnThis(); MYOBJECT.toString()", - "[object Object]", - eval("var MYOBJECT = new ReturnThis(); MYOBJECT.toString()") ); +new TestCase( SECTION, + "var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()", + "[object Object]", + eval("var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()") ); - testcases[item++] = new TestCase( SECTION, - "var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()", - "[object Object]", - eval("var MYOBJECT = new ReturnEvalThis(); MYOBJECT.toString()") ); +test(); - - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function ReturnThis() { - return this.toString(); + return this.toString(); } + function ReturnEvalThis() { - return( eval("this.toString()") ); -} \ No newline at end of file + return( eval("this.toString()") ); +} diff --git a/mozilla/js/tests/ecma/Expressions/11.10-1.js b/mozilla/js/tests/ecma/Expressions/11.10-1.js index 1d43b678dc0..cba5fefb90c 100644 --- a/mozilla/js/tests/ecma/Expressions/11.10-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.10-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,251 +36,232 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 11.10-1.js - ECMA Section: 11.10-1 Binary Bitwise Operators: & - Description: - Semantics + File Name: 11.10-1.js + ECMA Section: 11.10-1 Binary Bitwise Operators: & + Description: + Semantics - The production A : A @ B, where @ is one of the bitwise operators in the - productions &, ^, | , is evaluated as follows: + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: - 1. Evaluate A. - 2. Call GetValue(Result(1)). - 3. Evaluate B. - 4. Call GetValue(Result(3)). - 5. Call ToInt32(Result(2)). - 6. Call ToInt32(Result(4)). - 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is - a signed 32 bit integer. - 8. Return Result(7). + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.10-1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "11.10-1"; +var VERSION = "ECMA_1"; +startTest(); - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " Binary Bitwise Operators: &"); - writeHeaderToLog( SECTION + " Binary Bitwise Operators: &"); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - var shiftexp = 0; - var addexp = 0; +var shiftexp = 0; +var addexp = 0; // for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { - for ( shiftpow = 0; shiftpow < 1; shiftpow++ ) { - shiftexp += Math.pow( 2, shiftpow ); +for ( shiftpow = 0; shiftpow < 1; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); - for ( addpow = 0; addpow < 33; addpow++ ) { - addexp += Math.pow(2, addpow); + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); - array[item++] = new TestCase( SECTION, - shiftexp + " & " + addexp, - And( shiftexp, addexp ), - shiftexp & addexp ); - } - } - - return ( array ); + new TestCase( SECTION, + shiftexp + " & " + addexp, + And( shiftexp, addexp ), + shiftexp & addexp ); + } } -function ToInteger( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; - if ( n != n ) { - return 0; - } - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { - return n; - } - return ( sign * Math.floor(Math.abs(n)) ); +test(); + +function ToInteger( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); } function ToInt32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); - n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; - return ( n ); + return ( n ); } function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); + return ( n ); } function ToUint16( n ) { - var sign = ( n < 0 ) ? -1 : 1; + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); - if (n <0) { - n += Math.pow(2,16); - } + if (n <0) { + n += Math.pow(2,16); + } - return ( n ); + return ( n ); } function Mask( b, n ) { - b = ToUint32BitString( b ); - b = b.substring( b.length - n ); - b = ToUint32Decimal( b ); - return ( b ); + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); } function ToUint32BitString( n ) { - var b = ""; - for ( p = 31; p >=0; p-- ) { - if ( n >= Math.pow(2,p) ) { - b += "1"; - n -= Math.pow(2,p); - } else { - b += "0"; - } + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; } - return b; + } + return b; } function ToInt32BitString( n ) { - var b = ""; - var sign = ( n < 0 ) ? -1 : 1; + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; - b += ( sign == 1 ) ? "0" : "1"; + b += ( sign == 1 ) ? "0" : "1"; - for ( p = 30; p >=0; p-- ) { - if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { - b += ( sign == 1 ) ? "1" : "0"; - n -= sign * Math.pow( 2, p ); - } else { - b += ( sign == 1 ) ? "0" : "1"; - } + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; } + } - return b; + return b; } function ToInt32Decimal( bin ) { - var r = 0; - var sign; + var r = 0; + var sign; - if ( Number(bin.charAt(0)) == 0 ) { - sign = 1; - r = 0; - } else { - sign = -1; - r = -(Math.pow(2,31)); - } + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } - for ( var j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } - return r; + return r; } function ToUint32Decimal( bin ) { - var r = 0; + var r = 0; - for ( l = bin.length; l < 32; l++ ) { - bin = "0" + bin; - } + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } - for ( j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + } - return r; + return r; } function And( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; } - return ToInt32Decimal(result); + } + return ToInt32Decimal(result); } function Xor( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || - (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") - ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; } + } - return ToInt32Decimal(result); + return ToInt32Decimal(result); } function Or( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; } + } - return ToInt32Decimal(result); + return ToInt32Decimal(result); } diff --git a/mozilla/js/tests/ecma/Expressions/11.10-2.js b/mozilla/js/tests/ecma/Expressions/11.10-2.js index 4637ca1a99d..557fcfed54f 100644 --- a/mozilla/js/tests/ecma/Expressions/11.10-2.js +++ b/mozilla/js/tests/ecma/Expressions/11.10-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,250 +36,231 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 11.10-2.js - ECMA Section: 11.10-2 Binary Bitwise Operators: | - Description: - Semantics + File Name: 11.10-2.js + ECMA Section: 11.10-2 Binary Bitwise Operators: | + Description: + Semantics - The production A : A @ B, where @ is one of the bitwise operators in the - productions &, ^, | , is evaluated as follows: + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: - 1. Evaluate A. - 2. Call GetValue(Result(1)). - 3. Evaluate B. - 4. Call GetValue(Result(3)). - 5. Call ToInt32(Result(2)). - 6. Call ToInt32(Result(4)). - 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is - a signed 32 bit integer. - 8. Return Result(7). + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.10-2"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "11.10-2"; +var VERSION = "ECMA_1"; +startTest(); - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " Binary Bitwise Operators: |"); - writeHeaderToLog( SECTION + " Binary Bitwise Operators: |"); - test(); +var shiftexp = 0; +var addexp = 0; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + new TestCase( SECTION, + shiftexp + " | " + addexp, + Or( shiftexp, addexp ), + shiftexp | addexp ); + } } -function getTestCases() { - var array = new Array(); - var item = 0; - var shiftexp = 0; - var addexp = 0; - for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { - shiftexp += Math.pow( 2, shiftpow ); +test(); - for ( addpow = 0; addpow < 33; addpow++ ) { - addexp += Math.pow(2, addpow); - - array[item++] = new TestCase( SECTION, - shiftexp + " | " + addexp, - Or( shiftexp, addexp ), - shiftexp | addexp ); - } - } - - return ( array ); -} function ToInteger( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( n != n ) { - return 0; - } - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { - return n; - } - return ( sign * Math.floor(Math.abs(n)) ); + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); } function ToInt32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); - n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; - return ( n ); + return ( n ); } function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); + return ( n ); } function ToUint16( n ) { - var sign = ( n < 0 ) ? -1 : 1; + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); - if (n <0) { - n += Math.pow(2,16); - } + if (n <0) { + n += Math.pow(2,16); + } - return ( n ); + return ( n ); } function Mask( b, n ) { - b = ToUint32BitString( b ); - b = b.substring( b.length - n ); - b = ToUint32Decimal( b ); - return ( b ); + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); } function ToUint32BitString( n ) { - var b = ""; - for ( p = 31; p >=0; p-- ) { - if ( n >= Math.pow(2,p) ) { - b += "1"; - n -= Math.pow(2,p); - } else { - b += "0"; - } + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; } - return b; + } + return b; } function ToInt32BitString( n ) { - var b = ""; - var sign = ( n < 0 ) ? -1 : 1; + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; - b += ( sign == 1 ) ? "0" : "1"; + b += ( sign == 1 ) ? "0" : "1"; - for ( p = 30; p >=0; p-- ) { - if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { - b += ( sign == 1 ) ? "1" : "0"; - n -= sign * Math.pow( 2, p ); - } else { - b += ( sign == 1 ) ? "0" : "1"; - } + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; } + } - return b; + return b; } function ToInt32Decimal( bin ) { - var r = 0; - var sign; + var r = 0; + var sign; - if ( Number(bin.charAt(0)) == 0 ) { - sign = 1; - r = 0; - } else { - sign = -1; - r = -(Math.pow(2,31)); - } + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } - for ( var j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } - return r; + return r; } function ToUint32Decimal( bin ) { - var r = 0; + var r = 0; - for ( l = bin.length; l < 32; l++ ) { - bin = "0" + bin; - } + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } - for ( j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + } - return r; + return r; } function And( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; } - return ToInt32Decimal(result); + } + return ToInt32Decimal(result); } function Xor( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || - (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") - ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; } + } - return ToInt32Decimal(result); + return ToInt32Decimal(result); } function Or( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; } + } - return ToInt32Decimal(result); + return ToInt32Decimal(result); } diff --git a/mozilla/js/tests/ecma/Expressions/11.10-3.js b/mozilla/js/tests/ecma/Expressions/11.10-3.js index d224aba0410..7a476599cf3 100644 --- a/mozilla/js/tests/ecma/Expressions/11.10-3.js +++ b/mozilla/js/tests/ecma/Expressions/11.10-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,249 +36,230 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 11.10-3.js - ECMA Section: 11.10-3 Binary Bitwise Operators: ^ - Description: - Semantics + File Name: 11.10-3.js + ECMA Section: 11.10-3 Binary Bitwise Operators: ^ + Description: + Semantics - The production A : A @ B, where @ is one of the bitwise operators in the - productions &, ^, | , is evaluated as follows: + The production A : A @ B, where @ is one of the bitwise operators in the + productions &, ^, | , is evaluated as follows: - 1. Evaluate A. - 2. Call GetValue(Result(1)). - 3. Evaluate B. - 4. Call GetValue(Result(3)). - 5. Call ToInt32(Result(2)). - 6. Call ToInt32(Result(4)). - 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is - a signed 32 bit integer. - 8. Return Result(7). + 1. Evaluate A. + 2. Call GetValue(Result(1)). + 3. Evaluate B. + 4. Call GetValue(Result(3)). + 5. Call ToInt32(Result(2)). + 6. Call ToInt32(Result(4)). + 7. Apply the bitwise operator @ to Result(5) and Result(6). The result is + a signed 32 bit integer. + 8. Return Result(7). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.10-3"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "11.10-3"; +var VERSION = "ECMA_1"; +startTest(); - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " Binary Bitwise Operators: ^"); - writeHeaderToLog( SECTION + " Binary Bitwise Operators: ^"); - test(); +var shiftexp = 0; +var addexp = 0; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { + shiftexp += Math.pow( 2, shiftpow ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + for ( addpow = 0; addpow < 33; addpow++ ) { + addexp += Math.pow(2, addpow); + + new TestCase( SECTION, + shiftexp + " ^ " + addexp, + Xor( shiftexp, addexp ), + shiftexp ^ addexp ); + } } -function getTestCases() { - var array = new Array(); - var item = 0; - var shiftexp = 0; - var addexp = 0; - for ( shiftpow = 0; shiftpow < 33; shiftpow++ ) { - shiftexp += Math.pow( 2, shiftpow ); +test(); - for ( addpow = 0; addpow < 33; addpow++ ) { - addexp += Math.pow(2, addpow); - - array[item++] = new TestCase( SECTION, - shiftexp + " ^ " + addexp, - Xor( shiftexp, addexp ), - shiftexp ^ addexp ); - } - } - - return ( array ); -} function ToInteger( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( n != n ) { - return 0; - } - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { - return n; - } - return ( sign * Math.floor(Math.abs(n)) ); + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); } function ToInt32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); - n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; - return ( n ); + return ( n ); } function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); + return ( n ); } function ToUint16( n ) { - var sign = ( n < 0 ) ? -1 : 1; + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); - if (n <0) { - n += Math.pow(2,16); - } + if (n <0) { + n += Math.pow(2,16); + } - return ( n ); + return ( n ); } function Mask( b, n ) { - b = ToUint32BitString( b ); - b = b.substring( b.length - n ); - b = ToUint32Decimal( b ); - return ( b ); + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); } function ToUint32BitString( n ) { - var b = ""; - for ( p = 31; p >=0; p-- ) { - if ( n >= Math.pow(2,p) ) { - b += "1"; - n -= Math.pow(2,p); - } else { - b += "0"; - } + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; } - return b; + } + return b; } function ToInt32BitString( n ) { - var b = ""; - var sign = ( n < 0 ) ? -1 : 1; + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; - b += ( sign == 1 ) ? "0" : "1"; + b += ( sign == 1 ) ? "0" : "1"; - for ( p = 30; p >=0; p-- ) { - if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { - b += ( sign == 1 ) ? "1" : "0"; - n -= sign * Math.pow( 2, p ); - } else { - b += ( sign == 1 ) ? "0" : "1"; - } + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; } + } - return b; + return b; } function ToInt32Decimal( bin ) { - var r = 0; - var sign; + var r = 0; + var sign; - if ( Number(bin.charAt(0)) == 0 ) { - sign = 1; - r = 0; - } else { - sign = -1; - r = -(Math.pow(2,31)); - } + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } - for ( var j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } - return r; + return r; } function ToUint32Decimal( bin ) { - var r = 0; + var r = 0; - for ( l = bin.length; l < 32; l++ ) { - bin = "0" + bin; - } + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } - for ( j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + for ( j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + } - return r; + return r; } function And( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" && ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; } - return ToInt32Decimal(result); + } + return ToInt32Decimal(result); } function Xor( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || - (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") - ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( (bs.charAt(bit) == "1" && ba.charAt(bit) == "0") || + (bs.charAt(bit) == "0" && ba.charAt(bit) == "1") + ) { + result += "1"; + } else { + result += "0"; } + } - return ToInt32Decimal(result); + return ToInt32Decimal(result); } function Or( s, a ) { - s = ToInt32( s ); - a = ToInt32( a ); + s = ToInt32( s ); + a = ToInt32( a ); - var bs = ToInt32BitString( s ); - var ba = ToInt32BitString( a ); + var bs = ToInt32BitString( s ); + var ba = ToInt32BitString( a ); - var result = ""; + var result = ""; - for ( var bit = 0; bit < bs.length; bit++ ) { - if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { - result += "1"; - } else { - result += "0"; - } + for ( var bit = 0; bit < bs.length; bit++ ) { + if ( bs.charAt(bit) == "1" || ba.charAt(bit) == "1" ) { + result += "1"; + } else { + result += "0"; } + } - return ToInt32Decimal(result); + return ToInt32Decimal(result); } diff --git a/mozilla/js/tests/ecma/Expressions/11.12-1.js b/mozilla/js/tests/ecma/Expressions/11.12-1.js index adecedb4de9..7111a0aaa9b 100644 --- a/mozilla/js/tests/ecma/Expressions/11.12-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.12-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,68 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.12.js - ECMA Section: 11.12 Conditional Operator - Description: - Logi + File Name: 11.12.js + ECMA Section: 11.12 Conditional Operator + Description: + Logi - calORExpression ? AssignmentExpression : AssignmentExpression + calORExpression ? AssignmentExpression : AssignmentExpression - Semantics + Semantics - The production ConditionalExpression : - LogicalORExpression ? AssignmentExpression : AssignmentExpression - is evaluated as follows: + The production ConditionalExpression : + LogicalORExpression ? AssignmentExpression : AssignmentExpression + is evaluated as follows: - 1. Evaluate LogicalORExpression. - 2. Call GetValue(Result(1)). - 3. Call ToBoolean(Result(2)). - 4. If Result(3) is false, go to step 8. - 5. Evaluate the first AssignmentExpression. - 6. Call GetValue(Result(5)). - 7. Return Result(6). - 8. Evaluate the second AssignmentExpression. - 9. Call GetValue(Result(8)). + 1. Evaluate LogicalORExpression. + 2. Call GetValue(Result(1)). + 3. Call ToBoolean(Result(2)). + 4. If Result(3) is false, go to step 8. + 5. Evaluate the first AssignmentExpression. + 6. Call GetValue(Result(5)). + 7. Return Result(6). + 8. Evaluate the second AssignmentExpression. + 9. Call GetValue(Result(8)). 10. Return Result(9). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.12"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.12"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Conditional operator( ? : )"); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +writeHeaderToLog( SECTION + " Conditional operator( ? : )"); - array[item++] = new TestCase( SECTION, "true ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); - array[item++] = new TestCase( SECTION, "false ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); +new TestCase( SECTION, + "true ? 'PASSED' : 'FAILED'", + "PASSED", + (true?"PASSED":"FAILED")); - array[item++] = new TestCase( SECTION, "1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); - array[item++] = new TestCase( SECTION, "0 ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); - array[item++] = new TestCase( SECTION, "-1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); +new TestCase( SECTION, + "false ? 'FAILED' : 'PASSED'", + "PASSED", + (false?"FAILED":"PASSED")); - array[item++] = new TestCase( SECTION, "NaN ? 'FAILED' : 'PASSED'", "PASSED", (Number.NaN?"FAILED":"PASSED")); +new TestCase( SECTION, + "1 ? 'PASSED' : 'FAILED'", + "PASSED", + (true?"PASSED":"FAILED")); - array[item++] = new TestCase( SECTION, "var VAR = true ? , : 'FAILED'", "PASSED", (VAR = true ? "PASSED" : "FAILED") ); +new TestCase( SECTION, + "0 ? 'FAILED' : 'PASSED'", + "PASSED", + (false?"FAILED":"PASSED")); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "-1 ? 'PASSED' : 'FAILED'", + "PASSED", + (true?"PASSED":"FAILED")); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "NaN ? 'FAILED' : 'PASSED'", + "PASSED", + (Number.NaN?"FAILED":"PASSED")); + +new TestCase( SECTION, + "var VAR = true ? , : 'FAILED'", + "PASSED", + (VAR = true ? "PASSED" : "FAILED") ); + +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.12-2-n.js b/mozilla/js/tests/ecma/Expressions/11.12-2-n.js index 83dad6ede50..99379ca42e2 100644 --- a/mozilla/js/tests/ecma/Expressions/11.12-2-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.12-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.12-2-n.js - ECMA Section: 11.12 - Description: + File Name: 11.12-2-n.js + ECMA Section: 11.12 + Description: - The grammar for a ConditionalExpression in ECMAScript is a little bit - different from that in C and Java, which each allow the second - subexpression to be an Expression but restrict the third expression to - be a ConditionalExpression. The motivation for this difference in - ECMAScript is to allow an assignment expression to be governed by either - arm of a conditional and to eliminate the confusing and fairly useless - case of a comma expression as the center expression. + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.12-2-n"; - var VERSION = "ECMA_1"; - startTest(); - writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); +var SECTION = "11.12-2-n"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); - var testcases = new Array(); +// the following expression should be an error in JS. - // the following expression should be an error in JS. +DESCRIPTION = "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR"; +EXPECTED = "error"; - testcases[tc] = new TestCase( SECTION, - "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR", - "error", - "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR" ); +new TestCase( SECTION, + "var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR", + "error", + eval("var MYVAR = true ? 'EXPR1', 'EXPR2' : 'EXPR3'; MYVAR") ); - // get around parse time error by putting expression in an eval statement +test(); - testcases[tc].actual = eval ( testcases[tc].actual ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.12-3.js b/mozilla/js/tests/ecma/Expressions/11.12-3.js index 6dcd3f718f8..0f2cb9b0272 100644 --- a/mozilla/js/tests/ecma/Expressions/11.12-3.js +++ b/mozilla/js/tests/ecma/Expressions/11.12-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.12-3.js - ECMA Section: 11.12 - Description: + File Name: 11.12-3.js + ECMA Section: 11.12 + Description: - The grammar for a ConditionalExpression in ECMAScript is a little bit - different from that in C and Java, which each allow the second - subexpression to be an Expression but restrict the third expression to - be a ConditionalExpression. The motivation for this difference in - ECMAScript is to allow an assignment expression to be governed by either - arm of a conditional and to eliminate the confusing and fairly useless - case of a comma expression as the center expression. + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.12-3"; - var VERSION = "ECMA_1"; - startTest(); - writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); +var SECTION = "11.12-3"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); - var testcases = new Array(); +// the following expression should NOT be an error in JS. - // the following expression should NOT be an error in JS. +new TestCase( SECTION, + "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR", + "PASSED", + eval("var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR")); - testcases[tc] = new TestCase( SECTION, - "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR", - "PASSED", - "var MYVAR = true ? ('FAIL1', 'PASSED') : 'FAIL2'; MYVAR" ); +test(); - // get around potential parse time error by putting expression in an eval statement - - testcases[tc].actual = eval ( testcases[tc].actual ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.12-4.js b/mozilla/js/tests/ecma/Expressions/11.12-4.js index 25116164d54..eb5e32093ae 100644 --- a/mozilla/js/tests/ecma/Expressions/11.12-4.js +++ b/mozilla/js/tests/ecma/Expressions/11.12-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.12-4.js - ECMA Section: 11.12 - Description: + File Name: 11.12-4.js + ECMA Section: 11.12 + Description: - The grammar for a ConditionalExpression in ECMAScript is a little bit - different from that in C and Java, which each allow the second - subexpression to be an Expression but restrict the third expression to - be a ConditionalExpression. The motivation for this difference in - ECMAScript is to allow an assignment expression to be governed by either - arm of a conditional and to eliminate the confusing and fairly useless - case of a comma expression as the center expression. + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.12-4"; - var VERSION = "ECMA_1"; - startTest(); - writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); +var SECTION = "11.12-4"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Conditional operator ( ? : )"); - var testcases = new Array(); +// the following expression should NOT be an error in JS. - // the following expression should NOT be an error in JS. +new TestCase( SECTION, + "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1", + "PASSED", + eval("true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1") ); - testcases[tc] = new TestCase( SECTION, - "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1", - "PASSED", - "true ? MYVAR1 = 'PASSED' : MYVAR1 = 'FAILED'; MYVAR1" ); +test(); - // get around potential parse time error by putting expression in an eval statement - - testcases[tc].actual = eval ( testcases[tc].actual ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.13.1.js b/mozilla/js/tests/ecma/Expressions/11.13.1.js index 0ec0b238713..2385f483141 100644 --- a/mozilla/js/tests/ecma/Expressions/11.13.1.js +++ b/mozilla/js/tests/ecma/Expressions/11.13.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 11.13.1.js - ECMA Section: 11.13.1 Simple assignment - Description: +/** + File Name: 11.13.1.js + ECMA Section: 11.13.1 Simple assignment + Description: - 11.13.1 Simple Assignment ( = ) + 11.13.1 Simple Assignment ( = ) - The production AssignmentExpression : - LeftHandSideExpression = AssignmentExpression is evaluated as follows: + The production AssignmentExpression : + LeftHandSideExpression = AssignmentExpression is evaluated as follows: - 1. Evaluate LeftHandSideExpression. - 2. Evaluate AssignmentExpression. - 3. Call GetValue(Result(2)). - 4. Call PutValue(Result(1), Result(3)). - 5. Return Result(3). + 1. Evaluate LeftHandSideExpression. + 2. Evaluate AssignmentExpression. + 3. Call GetValue(Result(2)). + 4. Call PutValue(Result(1), Result(3)). + 5. Return Result(3). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.13.1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.13.1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Simple Assignment ( = )"); - test(); +writeHeaderToLog( SECTION + " Simple Assignment ( = )"); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "SOMEVAR = true", + true, + SOMEVAR = true ); - array[item++] = new TestCase( SECTION, "SOMEVAR = true", true, SOMEVAR = true ); +test(); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.13.2-1.js b/mozilla/js/tests/ecma/Expressions/11.13.2-1.js index ae1f31ac73c..157dd0e2f3c 100644 --- a/mozilla/js/tests/ecma/Expressions/11.13.2-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.13.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,104 +35,194 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 11.13.2-1.js - ECMA Section: 11.13.2 Compound Assignment: *= - Description: +/** + File Name: 11.13.2-1.js + ECMA Section: 11.13.2 Compound Assignment: *= + Description: - *= /= %= += -= <<= >>= >>>= &= ^= |= + *= /= %= += -= <<= >>= >>>= &= ^= |= - 11.13.2 Compound assignment ( op= ) + 11.13.2 Compound assignment ( op= ) - The production AssignmentExpression : - LeftHandSideExpression @ = AssignmentExpression, where @ represents one of - the operators indicated above, is evaluated as follows: + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: - 1. Evaluate LeftHandSideExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate AssignmentExpression. - 4. Call GetValue(Result(3)). - 5. Apply operator @ to Result(2) and Result(4). - 6. Call PutValue(Result(1), Result(5)). - 7. Return Result(5). + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.13.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.13.2-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Compound Assignment: *="); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // NaN cases - - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 *= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 *= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2; VAR1") ); - - // number cases - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 *= VAR2", 0, eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1") ); - - array[item++] = new TestCase( SECTION, "VAR1 = 0xFF; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 *= VAR2") ); - - // special multiplication cases - - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 *= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); - - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 *= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); - - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 *= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 *= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 *= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 *= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); - - // string cases - array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '255', VAR1 *= VAR2", 2550, eval("VAR1 = 10; VAR2 = '255', VAR1 *= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2", 2550, eval("VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2") ); - - array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); - - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); - - // boolean cases - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 *= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 *= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 *= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 *= VAR2") ); - - // object cases - array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2", 225, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2") ); +writeHeaderToLog( SECTION + " Compound Assignment: *="); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// NaN cases + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 *= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 *= VAR2; VAR1") ); + +// number cases +new TestCase( SECTION, + "VAR1 = 0; VAR2=1; VAR1 *= VAR2", + 0, + eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1", + 0, + eval("VAR1 = 0; VAR2=1; VAR1 *= VAR2;VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0xFF; VAR2 = 0xA, VAR1 *= VAR2", + 2550, + eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 *= VAR2") ); + +// special multiplication cases + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR1 *= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR2 *= VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR2 *= VAR1", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR2 *= VAR1", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR2 *= VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 *= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= Infinity; VAR1 *= VAR2", + Number.POSITIVE_INFINITY, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= -Infinity; VAR1 *= VAR2", + Number.NEGATIVE_INFINITY, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2= Infinity; VAR1 *= VAR2", + Number.NEGATIVE_INFINITY, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2=-Infinity; VAR1 *= VAR2", + Number.POSITIVE_INFINITY, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 *= VAR2; VAR1") ); + +// string cases +new TestCase( SECTION, + "VAR1 = 10; VAR2 = '255', VAR1 *= VAR2", + 2550, + eval("VAR1 = 10; VAR2 = '255', VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2", + 2550, + eval("VAR1 = '255'; VAR2 = 10, VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2", + 2550, + eval("VAR1 = 10; VAR2 = '0XFF', VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", + 2550, + eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2", + 2550, + eval("VAR1 = '10'; VAR2 = '255', VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2", + 2550, + eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 *= VAR2", + 2550, + eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 *= VAR2") ); + +// boolean cases +new TestCase( SECTION, + "VAR1 = true; VAR2 = false; VAR1 *= VAR2", + 0, + eval("VAR1 = true; VAR2 = false; VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = true; VAR2 = true; VAR1 *= VAR2", + 1, + eval("VAR1 = true; VAR2 = true; VAR1 *= VAR2") ); + +// object cases +new TestCase( SECTION, + "VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2;VAR1", + 10, + eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1", + 110, + eval("VAR1 = new Number(11); VAR2 = 10; VAR1 *= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2", + 110, + eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 *= VAR2") ); + +new TestCase( SECTION, + "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2", + 225, + eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 *= VAR2") ); + +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.13.2-2.js b/mozilla/js/tests/ecma/Expressions/11.13.2-2.js index 1ebfe8faee7..1d66e2c7cfd 100644 --- a/mozilla/js/tests/ecma/Expressions/11.13.2-2.js +++ b/mozilla/js/tests/ecma/Expressions/11.13.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,118 +35,216 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 11.13.2-2js - ECMA Section: 11.13.2 Compound Assignment: /= - Description: +/** + File Name: 11.13.2-2js + ECMA Section: 11.13.2 Compound Assignment: /= + Description: - *= /= %= += -= <<= >>= >>>= &= ^= |= + *= /= %= += -= <<= >>= >>>= &= ^= |= - 11.13.2 Compound assignment ( op= ) + 11.13.2 Compound assignment ( op= ) - The production AssignmentExpression : - LeftHandSideExpression @ = AssignmentExpression, where @ represents one of - the operators indicated above, is evaluated as follows: + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: - 1. Evaluate LeftHandSideExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate AssignmentExpression. - 4. Call GetValue(Result(3)). - 5. Apply operator @ to Result(2) and Result(4). - 6. Call PutValue(Result(1), Result(5)). - 7. Return Result(5). + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.13.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.13.2-2"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Compound Assignment: /="); - test(); +writeHeaderToLog( SECTION + " Compound Assignment: /="); -function getTestCases() { - var array = new Array(); - var item = 0; - // NaN cases +// NaN cases - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2") ); - // number cases - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") ); +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 /= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2", 25.5, eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") ); +new TestCase( SECTION, + "VAR1 = NaN; VAR2=0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2") ); - // special division cases +new TestCase( SECTION, + "VAR1 = NaN; VAR2=0; VAR1 /= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=0; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2", 0, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2", 0, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2", 0, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 /= VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 /= VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 /= VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 /= VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); +new TestCase( SECTION, + "VAR1 = 0; VAR2=NaN; VAR1 /= VAR2; VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2=Number.NaN; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); +// number cases +new TestCase( SECTION, + "VAR1 = 0; VAR2=1; VAR1 /= VAR2", + 0, + eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 /= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1", + 0, + eval("VAR1 = 0; VAR2=1; VAR1 /= VAR2;VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= 0; VAR1 /= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -0; VAR1 /= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= 0; VAR1 /= VAR2", Number.NEGATIVE_INFINITY, eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -0; VAR1 /= VAR2", Number.POSITIVE_INFINITY, eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = 0xFF; VAR2 = 0xA, VAR1 /= VAR2", + 25.5, + eval("VAR1 = 0XFF; VAR2 = 0XA, VAR1 /= VAR2") ); - // string cases - array[item++] = new TestCase( SECTION, "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1", 100, eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1", 100, eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") ); +// special division cases + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR1 /= VAR2", + 0, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR1 /= VAR2", + 0, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR1 /= VAR2", + 0, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR1 /= VAR2", + 0, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR2 /= VAR1", + Number.POSITIVE_INFINITY, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR2 /= VAR1", + Number.NEGATIVE_INFINITY, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR2 /= VAR1", + Number.POSITIVE_INFINITY, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR2 /= VAR1", + Number.NEGATIVE_INFINITY, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 /= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= Infinity; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= -Infinity; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2= Infinity; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2=-Infinity; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= 0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= 0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -0; VAR1 /= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= 0; VAR1 /= VAR2", + Number.POSITIVE_INFINITY, + eval("VAR1 = 1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= -0; VAR1 /= VAR2", + Number.NEGATIVE_INFINITY, + eval("VAR1 = 1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= 0; VAR1 /= VAR2", + Number.NEGATIVE_INFINITY, + eval("VAR1 = -1; VAR2 = 0; VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= -0; VAR1 /= VAR2", + Number.POSITIVE_INFINITY, + eval("VAR1 = -1; VAR2 = -0; VAR1 /= VAR2; VAR1") ); + +// string cases +new TestCase( SECTION, + "VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1", + 100, + eval("VAR1 = 1000; VAR2 = '10', VAR1 /= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1", + 100, + eval("VAR1 = '1000'; VAR2 = 10, VAR1 /= VAR2; VAR1") ); /* - array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 /= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 /= VAR2") ); - // boolean cases - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 /= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 /= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 /= VAR2") ); + // boolean cases + new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 /= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 /= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 /= VAR2") ); - // object cases - array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2") ); + // object cases + new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 /= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 /= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 /= VAR2") ); + new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 /= VAR2") ); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + diff --git a/mozilla/js/tests/ecma/Expressions/11.13.2-3.js b/mozilla/js/tests/ecma/Expressions/11.13.2-3.js index 903c2f63b0e..c49af4af6c2 100644 --- a/mozilla/js/tests/ecma/Expressions/11.13.2-3.js +++ b/mozilla/js/tests/ecma/Expressions/11.13.2-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,131 +35,263 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 11.13.2-4.js - ECMA Section: 11.13.2 Compound Assignment: %= - Description: +/** + File Name: 11.13.2-4.js + ECMA Section: 11.13.2 Compound Assignment: %= + Description: - *= /= %= += -= <<= >>= >>>= &= ^= |= + *= /= %= += -= <<= >>= >>>= &= ^= |= - 11.13.2 Compound assignment ( op= ) + 11.13.2 Compound assignment ( op= ) - The production AssignmentExpression : - LeftHandSideExpression @ = AssignmentExpression, where @ represents one of - the operators indicated above, is evaluated as follows: + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: - 1. Evaluate LeftHandSideExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate AssignmentExpression. - 4. Call GetValue(Result(3)). - 5. Apply operator @ to Result(2) and Result(4). - 6. Call PutValue(Result(1), Result(5)). - 7. Return Result(5). + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.13.2-3"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.13.2-3"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Compound Assignment: +="); - test(); +writeHeaderToLog( SECTION + " Compound Assignment: +="); -function getTestCases() { - var array = new Array(); - var item = 0; +// If either operand is NaN, result is NaN - // If either operand is NaN, result is NaN +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 %= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = NaN; VAR2=1; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=1; VAR1 %= VAR2; VAR1") ); - // if the dividend is infinity or the divisor is zero or both, the result is NaN +new TestCase( SECTION, + "VAR1 = NaN; VAR2=0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 %= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = NaN; VAR2=0; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NaN; VAR2=0; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); +new TestCase( SECTION, + "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -Infinity; VAR2 %= VAR1", Number.NaN, eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); +new TestCase( SECTION, + "VAR1 = 0; VAR2=NaN; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2=Number.NaN; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); +// if the dividend is infinity or the divisor is zero or both, the result is NaN - array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = 1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= 0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -0; VAR1 %= VAR2", Number.NaN, eval("VAR1 = -1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - // if the dividend is finite and the divisor is an infinity, the result equals the dividend. +new TestCase( SECTION, + "VAR1 = Infinity; VAR2= -Infinity; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 %= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 %= VAR2;VAR1", -0, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", -0, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", 0, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2= Infinity; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= Infinity; VAR1 %= VAR2;VAR1", 1, eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= Infinity; VAR1 %= VAR2;VAR1", -1, eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", -1, eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", 1, eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 =-Infinity; VAR2=-Infinity; VAR1 %= VAR2; VAR1", + Number.NaN, + eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); - // if the dividend is a zero and the divisor is finite, the result is the same as the dividend +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 %= VAR2; VAR1", -0, eval("VAR1 = -0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 %= VAR2; VAR1", -0, eval("VAR1 = -0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); - // string cases - array[item++] = new TestCase( SECTION, "VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1", 0, eval("VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1", 0, eval("VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1") ); +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= -Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= -Infinity; VAR2 %= VAR1", + Number.NaN, + eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR2 %= VAR1; VAR2") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= 0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= 0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = -0; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= 0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= -0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = 1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= 0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = -1; VAR2 = 0; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= -0; VAR1 %= VAR2", + Number.NaN, + eval("VAR1 = -1; VAR2 = -0; VAR1 %= VAR2; VAR1") ); + +// if the dividend is finite and the divisor is an infinity, the result equals the dividend. + +new TestCase( SECTION, + "VAR1 = 0; VAR2= Infinity; VAR1 %= VAR2;VAR1", + 0, + eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= Infinity; VAR1 %= VAR2;VAR1", + -0, + eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", + -0, + eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -Infinity; VAR1 %= VAR2;VAR1", + 0, + eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= Infinity; VAR1 %= VAR2;VAR1", + 1, + eval("VAR1 = 1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= Infinity; VAR1 %= VAR2;VAR1", + -1, + eval("VAR1 = -1; VAR2 = Number.POSITIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", + -1, + eval("VAR1 = -1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 1; VAR2= -Infinity; VAR1 %= VAR2;VAR1", + 1, + eval("VAR1 = 1; VAR2 = Number.NEGATIVE_INFINITY; VAR1 %= VAR2; VAR1") ); + +// if the dividend is a zero and the divisor is finite, the result is the same as the dividend + +new TestCase( SECTION, + "VAR1 = 0; VAR2= 1; VAR1 %= VAR2; VAR1", + 0, + eval("VAR1 = 0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= 1; VAR1 %= VAR2; VAR1", + -0, + eval("VAR1 = -0; VAR2 = 1; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = -0; VAR2= -1; VAR1 %= VAR2; VAR1", + -0, + eval("VAR1 = -0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = 0; VAR2= -1; VAR1 %= VAR2; VAR1", + 0, + eval("VAR1 = 0; VAR2 = -1; VAR1 %= VAR2; VAR1") ); + +// string cases +new TestCase( SECTION, + "VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1", + 0, + eval("VAR1 = 1000; VAR2 = '10', VAR1 %= VAR2; VAR1") ); + +new TestCase( SECTION, + "VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1", + 0, + eval("VAR1 = '1000'; VAR2 = 10, VAR1 %= VAR2; VAR1") ); /* - array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 %= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 %= VAR2") ); - // boolean cases - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 %= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 %= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 %= VAR2") ); + // boolean cases + new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 %= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 %= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 %= VAR2") ); - // object cases - array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2") ); + // object cases + new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 %= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 %= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 %= VAR2") ); + new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 %= VAR2") ); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason %= ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + diff --git a/mozilla/js/tests/ecma/Expressions/11.13.2-4.js b/mozilla/js/tests/ecma/Expressions/11.13.2-4.js index 01b6f9de341..5d9f4911dac 100644 --- a/mozilla/js/tests/ecma/Expressions/11.13.2-4.js +++ b/mozilla/js/tests/ecma/Expressions/11.13.2-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,119 +35,100 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 11.13.2-4.js - ECMA Section: 11.13.2 Compound Assignment:+= - Description: +/** + File Name: 11.13.2-4.js + ECMA Section: 11.13.2 Compound Assignment:+= + Description: - *= /= %= += -= <<= >>= >>>= &= ^= |= + *= /= %= += -= <<= >>= >>>= &= ^= |= - 11.13.2 Compound assignment ( op= ) + 11.13.2 Compound assignment ( op= ) - The production AssignmentExpression : - LeftHandSideExpression @ = AssignmentExpression, where @ represents one of - the operators indicated above, is evaluated as follows: + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: - 1. Evaluate LeftHandSideExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate AssignmentExpression. - 4. Call GetValue(Result(3)). - 5. Apply operator @ to Result(2) and Result(4). - 6. Call PutValue(Result(1), Result(5)). - 7. Return Result(5). + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.13.2-4"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.13.2-4"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Compound Assignment: +="); - test(); +writeHeaderToLog( SECTION + " Compound Assignment: +="); -function getTestCases() { - var array = new Array(); - var item = 0; +// If either operand is NaN, result is NaN - // If either operand is NaN, result is NaN +new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 += VAR2; VAR1") ); +// the sum of two Infinities the same sign is the infinity of that sign +// the sum of two Infinities of opposite sign is NaN - // the sum of two Infinities the same sign is the infinity of that sign - // the sum of two Infinities of opposite sign is NaN +new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 += VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 += VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 += VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); +// the sum of an infinity and a finite value is equal to the infinite operand - // the sum of an infinity and a finite value is equal to the infinite operand +new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 += VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 += VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 += VAR2; VAR1") ); +// the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 - // the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 +new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 += VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 += VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 += VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 += VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 += VAR2; VAR1") ); +// the sum of a zero and a nonzero finite value is eqal to the nonzero operand - // the sum of a zero and a nonzero finite value is eqal to the nonzero operand +new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = 0; VAR2 = 1; VAR2 += VAR1; VAR2") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = -0; VAR2 = 1; VAR2 += VAR1; VAR2") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = -0; VAR2 = -1; VAR2 += VAR1; VAR2") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = 0; VAR2 = -1; VAR2 += VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = 0; VAR2 = 1; VAR2 += VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR2 += VAR1; VAR2", 1, eval("VAR1 = -0; VAR2 = 1; VAR2 += VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = -0; VAR2 = -1; VAR2 += VAR1; VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR2 += VAR1; VAR2", -1, eval("VAR1 = 0; VAR2 = -1; VAR2 += VAR1; VAR2") ); +// the sum of a zero and a nozero finite value is equal to the nonzero operand. +new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1") ); - // the sum of a zero and a nozero finite value is equal to the nonzero operand. - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=1; VAR1 += VAR2;VAR1") ); - - // the sum of two nonzero finite values of the same magnitude and opposite sign is +0 - array[item++] = new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1") ); +// the sum of two nonzero finite values of the same magnitude and opposite sign is +0 +new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= -Number.MAX_VALUE; VAR1 += VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= -Number.MIN_VALUE; VAR1 += VAR2; VAR1") ); /* - array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 += VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 += VAR2") ); - // boolean cases - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 += VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 += VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 += VAR2") ); + // boolean cases + new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 += VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 += VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 += VAR2") ); - // object cases - array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 += VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 += VAR2") ); + // object cases + new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 += VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 += VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 += VAR2") ); + new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 += VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 += VAR2") ); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.13.2-5.js b/mozilla/js/tests/ecma/Expressions/11.13.2-5.js index 11b62da7015..5d9fcb16053 100644 --- a/mozilla/js/tests/ecma/Expressions/11.13.2-5.js +++ b/mozilla/js/tests/ecma/Expressions/11.13.2-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,119 +35,100 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 11.13.2-5.js - ECMA Section: 11.13.2 Compound Assignment: -= - Description: +/** + File Name: 11.13.2-5.js + ECMA Section: 11.13.2 Compound Assignment: -= + Description: - *= /= %= -= -= <<= >>= >>>= &= ^= |= + *= /= %= -= -= <<= >>= >>>= &= ^= |= - 11.13.2 Compound assignment ( op= ) + 11.13.2 Compound assignment ( op= ) - The production AssignmentExpression : - LeftHandSideExpression @ = AssignmentExpression, where @ represents one of - the operators indicated above, is evaluated as follows: + The production AssignmentExpression : + LeftHandSideExpression @ = AssignmentExpression, where @ represents one of + the operators indicated above, is evaluated as follows: - 1. Evaluate LeftHandSideExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate AssignmentExpression. - 4. Call GetValue(Result(3)). - 5. Apply operator @ to Result(2) and Result(4). - 6. Call PutValue(Result(1), Result(5)). - 7. Return Result(5). + 1. Evaluate LeftHandSideExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Apply operator @ to Result(2) and Result(4). + 6. Call PutValue(Result(1), Result(5)). + 7. Return Result(5). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.13.2-5"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.13.2-5"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Compound Assignment: -="); - test(); +writeHeaderToLog( SECTION + " Compound Assignment: -="); -function getTestCases() { - var array = new Array(); - var item = 0; +// If either operand is NaN, result is NaN - // If either operand is NaN, result is NaN +new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2") ); +new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=1; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=1; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = NaN; VAR2=0; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NaN; VAR2=0; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=NaN; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = 0; VAR2=Number.NaN; VAR1 -= VAR2; VAR1") ); +// the sum of two Infinities the same sign is the infinity of that sign +// the sum of two Infinities of opposite sign is NaN - // the sum of two Infinities the same sign is the infinity of that sign - // the sum of two Infinities of opposite sign is NaN +new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 -= VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Infinity; VAR2= -Infinity; VAR1 -= VAR2; VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = Number.POSITIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2= Infinity; VAR1 -= VAR2; VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 =-Infinity; VAR2=-Infinity; VAR1 -= VAR2; VAR1", Number.NaN, eval("VAR1 = Number.NEGATIVE_INFINITY; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +// the sum of an infinity and a finite value is equal to the infinite operand - // the sum of an infinity and a finite value is equal to the infinite operand +new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= Infinity; VAR1 -= VAR2;VAR1", Number.NEGATIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.POSITIVE_INFINITY; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = 0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -Infinity; VAR1 -= VAR2;VAR1", Number.POSITIVE_INFINITY, eval("VAR1 = -0; VAR2 = Number.NEGATIVE_INFINITY; VAR1 -= VAR2; VAR1") ); +// the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 - // the sum of two negative zeros is -0. the sum of two positive zeros, or of two zeros of opposite sign, is +0 +new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 -= VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 0; VAR1 -= VAR2", 0, eval("VAR1 = 0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -0; VAR1 -= VAR2", 0, eval("VAR1 = -0; VAR2 = 0; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 0; VAR1 -= VAR2", -0, eval("VAR1 = -0; VAR2 = -0; VAR1 -= VAR2; VAR1") ); +// the sum of a zero and a nonzero finite value is eqal to the nonzero operand - // the sum of a zero and a nonzero finite value is eqal to the nonzero operand +new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = 0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = -0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = -0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = 0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = 0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= -1; VAR1 -= VAR2; VAR1", 1, eval("VAR1 = -0; VAR2 = -1; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = -0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = -0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2= 1; VAR1 -= VAR2; VAR1", -1, eval("VAR1 = 0; VAR2 = 1; VAR1 -= VAR2; VAR1") ); +// the sum of a zero and a nozero finite value is equal to the nonzero operand. +new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); +new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); - // the sum of a zero and a nozero finite value is equal to the nonzero operand. - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1", 1, eval("VAR1 = 0; VAR2=-1; VAR1 -= VAR2;VAR1") ); - - // the sum of two nonzero finite values of the same magnitude and opposite sign is +0 - array[item++] = new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1") ); +// the sum of two nonzero finite values of the same magnitude and opposite sign is +0 +new TestCase( SECTION, "VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MAX_VALUE; VAR2= Number.MAX_VALUE; VAR1 -= VAR2; VAR1") ); +new TestCase( SECTION, "VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1", 0, eval("VAR1 = Number.MIN_VALUE; VAR2= Number.MIN_VALUE; VAR1 -= VAR2; VAR1") ); /* - array[item++] = new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = 10; VAR2 = '0XFF', VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '255', VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2", 2550, eval("VAR1 = '10'; VAR2 = '0XFF', VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = '0xFF'; VAR2 = 0xA, VAR1 -= VAR2", 2550, eval("VAR1 = '0XFF'; VAR2 = 0XA, VAR1 -= VAR2") ); - // boolean cases - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 -= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 -= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 -= VAR2") ); + // boolean cases + new TestCase( SECTION, "VAR1 = true; VAR2 = false; VAR1 -= VAR2", 0, eval("VAR1 = true; VAR2 = false; VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = true; VAR2 = true; VAR1 -= VAR2", 1, eval("VAR1 = true; VAR2 = true; VAR1 -= VAR2") ); - // object cases - array[item++] = new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1") ); - array[item++] = new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2") ); - array[item++] = new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2") ); + // object cases + new TestCase( SECTION, "VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2;VAR1", 10, eval("VAR1 = new Boolean(true); VAR2 = 10; VAR1 -= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1", 110, eval("VAR1 = new Number(11); VAR2 = 10; VAR1 -= VAR2; VAR1") ); + new TestCase( SECTION, "VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2", 110, eval("VAR1 = new Number(11); VAR2 = new Number(10); VAR1 -= VAR2") ); + new TestCase( SECTION, "VAR1 = new String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2", 255, eval("VAR1 = String('15'); VAR2 = new String('0xF'); VAR1 -= VAR2") ); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason -= ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.13.js b/mozilla/js/tests/ecma/Expressions/11.13.js index 283402033ba..685b7673ea0 100644 --- a/mozilla/js/tests/ecma/Expressions/11.13.js +++ b/mozilla/js/tests/ecma/Expressions/11.13.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,68 +35,49 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 11.12.js - ECMA Section: 11.12 Conditional Operator - Description: - Logi +/** + File Name: 11.12.js + ECMA Section: 11.12 Conditional Operator + Description: + Logi - calORExpression ? AssignmentExpression : AssignmentExpression + calORExpression ? AssignmentExpression : AssignmentExpression - Semantics + Semantics - The production ConditionalExpression : - LogicalORExpression ? AssignmentExpression : AssignmentExpression - is evaluated as follows: + The production ConditionalExpression : + LogicalORExpression ? AssignmentExpression : AssignmentExpression + is evaluated as follows: - 1. Evaluate LogicalORExpression. - 2. Call GetValue(Result(1)). - 3. Call ToBoolean(Result(2)). - 4. If Result(3) is false, go to step 8. - 5. Evaluate the first AssignmentExpression. - 6. Call GetValue(Result(5)). - 7. Return Result(6). - 8. Evaluate the second AssignmentExpression. - 9. Call GetValue(Result(8)). + 1. Evaluate LogicalORExpression. + 2. Call GetValue(Result(1)). + 3. Call ToBoolean(Result(2)). + 4. If Result(3) is false, go to step 8. + 5. Evaluate the first AssignmentExpression. + 6. Call GetValue(Result(5)). + 7. Return Result(6). + 8. Evaluate the second AssignmentExpression. + 9. Call GetValue(Result(8)). 10. Return Result(9). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.12"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.12"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Conditional operator( ? : )"); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +writeHeaderToLog( SECTION + " Conditional operator( ? : )"); - array[item++] = new TestCase( SECTION, "true ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); - array[item++] = new TestCase( SECTION, "false ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); +new TestCase( SECTION, "true ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); +new TestCase( SECTION, "false ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); - array[item++] = new TestCase( SECTION, "1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); - array[item++] = new TestCase( SECTION, "0 ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); - array[item++] = new TestCase( SECTION, "-1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); +new TestCase( SECTION, "1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); +new TestCase( SECTION, "0 ? 'FAILED' : 'PASSED'", "PASSED", (false?"FAILED":"PASSED")); +new TestCase( SECTION, "-1 ? 'PASSED' : 'FAILED'", "PASSED", (true?"PASSED":"FAILED")); - array[item++] = new TestCase( SECTION, "NaN ? 'FAILED' : 'PASSED'", "PASSED", (Number.NaN?"FAILED":"PASSED")); +new TestCase( SECTION, "NaN ? 'FAILED' : 'PASSED'", "PASSED", (Number.NaN?"FAILED":"PASSED")); - array[item++] = new TestCase( SECTION, "var VAR = true ? , : 'FAILED'", "PASSED", (VAR = true ? "PASSED" : "FAILED") ); +new TestCase( SECTION, "var VAR = true ? , : 'FAILED'", "PASSED", (VAR = true ? "PASSED" : "FAILED") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.14-1.js b/mozilla/js/tests/ecma/Expressions/11.14-1.js index 228e9f5cb62..0e3d736669f 100644 --- a/mozilla/js/tests/ecma/Expressions/11.14-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.14-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,55 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.14-1.js - ECMA Section: 11.14 Comma operator (,) - Description: - Expression : + File Name: 11.14-1.js + ECMA Section: 11.14 Comma operator (,) + Description: + Expression : - AssignmentExpression - Expression , AssignmentExpression + AssignmentExpression + Expression , AssignmentExpression - Semantics + Semantics - The production Expression : Expression , AssignmentExpression is evaluated as follows: + The production Expression : Expression , AssignmentExpression is evaluated as follows: - 1. Evaluate Expression. - 2. Call GetValue(Result(1)). - 3. Evaluate AssignmentExpression. - 4. Call GetValue(Result(3)). - 5. Return Result(4). + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Evaluate AssignmentExpression. + 4. Call GetValue(Result(3)). + 5. Return Result(4). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.14-1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.14-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Comma operator (,)"); - test(); +writeHeaderToLog( SECTION + " Comma operator (,)"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "true, false", false, eval("true, false") ); +new TestCase( SECTION, "VAR1=true, VAR2=false", false, eval("VAR1=true, VAR2=false") ); +new TestCase( SECTION, "VAR1=true, VAR2=false;VAR1", true, eval("VAR1=true, VAR2=false; VAR1") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "true, false", false, eval("true, false") ); - array[item++] = new TestCase( SECTION, "VAR1=true, VAR2=false", false, eval("VAR1=true, VAR2=false") ); - array[item++] = new TestCase( SECTION, "VAR1=true, VAR2=false;VAR1", true, eval("VAR1=true, VAR2=false; VAR1") ); - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.2.1-1.js b/mozilla/js/tests/ecma/Expressions/11.2.1-1.js index 9385680a5f3..dcef273f26a 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.1-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,249 +36,234 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 11.2.1-1.js - ECMA Section: 11.2.1 Property Accessors - Description: + File Name: 11.2.1-1.js + ECMA Section: 11.2.1 Property Accessors + Description: - Properties are accessed by name, using either the dot notation: - MemberExpression . Identifier - CallExpression . Identifier + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier - or the bracket notation: MemberExpression [ Expression ] - CallExpression [ Expression ] + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] - The dot notation is explained by the following syntactic conversion: - MemberExpression . Identifier - is identical in its behavior to - MemberExpression [ ] - and similarly - CallExpression . Identifier - is identical in its behavior to - CallExpression [ ] - where is a string literal containing the same sequence - of characters as the Identifier. + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. - The production MemberExpression : MemberExpression [ Expression ] is - evaluated as follows: + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: - 1. Evaluate MemberExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate Expression. - 4. Call GetValue(Result(3)). - 5. Call ToObject(Result(2)). - 6. Call ToString(Result(4)). - 7. Return a value of type Reference whose base object is Result(5) and - whose property name is Result(6). + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). - The production CallExpression : CallExpression [ Expression ] is evaluated - in exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Property Accessors"; - writeHeaderToLog( SECTION + " "+TITLE ); +var SECTION = "11.2.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); - var testcases = new Array(); +// go through all Native Function objects, methods, and properties and get their typeof. - // go through all Native Function objects, methods, and properties and get their typeof. +var PROPERTY = new Array(); +var p = 0; - var PROPERTY = new Array(); - var p = 0; +// properties and functions of the global object - // properties and functions of the global object +PROPERTY[p++] = new Property( "this", "NaN", "number" ); +PROPERTY[p++] = new Property( "this", "Infinity", "number" ); +PROPERTY[p++] = new Property( "this", "eval", "function" ); +PROPERTY[p++] = new Property( "this", "parseInt", "function" ); +PROPERTY[p++] = new Property( "this", "parseFloat", "function" ); +PROPERTY[p++] = new Property( "this", "escape", "function" ); +PROPERTY[p++] = new Property( "this", "unescape", "function" ); +PROPERTY[p++] = new Property( "this", "isNaN", "function" ); +PROPERTY[p++] = new Property( "this", "isFinite", "function" ); +PROPERTY[p++] = new Property( "this", "Object", "function" ); +PROPERTY[p++] = new Property( "this", "Number", "function" ); +PROPERTY[p++] = new Property( "this", "Function", "function" ); +PROPERTY[p++] = new Property( "this", "Array", "function" ); +PROPERTY[p++] = new Property( "this", "String", "function" ); +PROPERTY[p++] = new Property( "this", "Boolean", "function" ); +PROPERTY[p++] = new Property( "this", "Date", "function" ); +PROPERTY[p++] = new Property( "this", "Math", "object" ); - PROPERTY[p++] = new Property( "this", "NaN", "number" ); - PROPERTY[p++] = new Property( "this", "Infinity", "number" ); - PROPERTY[p++] = new Property( "this", "eval", "function" ); - PROPERTY[p++] = new Property( "this", "parseInt", "function" ); - PROPERTY[p++] = new Property( "this", "parseFloat", "function" ); - PROPERTY[p++] = new Property( "this", "escape", "function" ); - PROPERTY[p++] = new Property( "this", "unescape", "function" ); - PROPERTY[p++] = new Property( "this", "isNaN", "function" ); - PROPERTY[p++] = new Property( "this", "isFinite", "function" ); - PROPERTY[p++] = new Property( "this", "Object", "function" ); - PROPERTY[p++] = new Property( "this", "Number", "function" ); - PROPERTY[p++] = new Property( "this", "Function", "function" ); - PROPERTY[p++] = new Property( "this", "Array", "function" ); - PROPERTY[p++] = new Property( "this", "String", "function" ); - PROPERTY[p++] = new Property( "this", "Boolean", "function" ); - PROPERTY[p++] = new Property( "this", "Date", "function" ); - PROPERTY[p++] = new Property( "this", "Math", "object" ); +// properties and methods of Object objects - // properties and methods of Object objects +PROPERTY[p++] = new Property( "Object", "prototype", "object" ); +PROPERTY[p++] = new Property( "Object", "toString", "function" ); +PROPERTY[p++] = new Property( "Object", "valueOf", "function" ); +PROPERTY[p++] = new Property( "Object", "constructor", "function" ); - PROPERTY[p++] = new Property( "Object", "prototype", "object" ); - PROPERTY[p++] = new Property( "Object", "toString", "function" ); - PROPERTY[p++] = new Property( "Object", "valueOf", "function" ); - PROPERTY[p++] = new Property( "Object", "constructor", "function" ); +// properties of the Function object - // properties of the Function object +PROPERTY[p++] = new Property( "Function", "prototype", "function" ); +PROPERTY[p++] = new Property( "Function.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "Function.prototype", "length", "number" ); +PROPERTY[p++] = new Property( "Function.prototype", "valueOf", "function" ); - PROPERTY[p++] = new Property( "Function", "prototype", "function" ); - PROPERTY[p++] = new Property( "Function.prototype", "toString", "function" ); - PROPERTY[p++] = new Property( "Function.prototype", "length", "number" ); - PROPERTY[p++] = new Property( "Function.prototype", "valueOf", "function" ); +Function.prototype.myProperty = "hi"; - Function.prototype.myProperty = "hi"; +PROPERTY[p++] = new Property( "Function.prototype", "myProperty", "string" ); - PROPERTY[p++] = new Property( "Function.prototype", "myProperty", "string" ); +// properties of the Array object +PROPERTY[p++] = new Property( "Array", "prototype", "object" ); +PROPERTY[p++] = new Property( "Array", "length", "number" ); +PROPERTY[p++] = new Property( "Array.prototype", "constructor", "function" ); +PROPERTY[p++] = new Property( "Array.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "Array.prototype", "join", "function" ); +PROPERTY[p++] = new Property( "Array.prototype", "reverse", "function" ); +PROPERTY[p++] = new Property( "Array.prototype", "sort", "function" ); - // properties of the Array object - PROPERTY[p++] = new Property( "Array", "prototype", "object" ); - PROPERTY[p++] = new Property( "Array", "length", "number" ); - PROPERTY[p++] = new Property( "Array.prototype", "constructor", "function" ); - PROPERTY[p++] = new Property( "Array.prototype", "toString", "function" ); - PROPERTY[p++] = new Property( "Array.prototype", "join", "function" ); - PROPERTY[p++] = new Property( "Array.prototype", "reverse", "function" ); - PROPERTY[p++] = new Property( "Array.prototype", "sort", "function" ); +// properties of the String object +PROPERTY[p++] = new Property( "String", "prototype", "object" ); +PROPERTY[p++] = new Property( "String", "fromCharCode", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "constructor", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "valueOf", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "charAt", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "charCodeAt", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "indexOf", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "lastIndexOf", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "split", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "substring", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "toLowerCase", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "toUpperCase", "function" ); +PROPERTY[p++] = new Property( "String.prototype", "length", "number" ); - // properties of the String object - PROPERTY[p++] = new Property( "String", "prototype", "object" ); - PROPERTY[p++] = new Property( "String", "fromCharCode", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "toString", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "constructor", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "valueOf", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "charAt", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "charCodeAt", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "indexOf", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "lastIndexOf", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "split", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "substring", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "toLowerCase", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "toUpperCase", "function" ); - PROPERTY[p++] = new Property( "String.prototype", "length", "number" ); +// properties of the Boolean object +PROPERTY[p++] = new Property( "Boolean", "prototype", "object" ); +PROPERTY[p++] = new Property( "Boolean", "constructor", "function" ); +PROPERTY[p++] = new Property( "Boolean.prototype", "valueOf", "function" ); +PROPERTY[p++] = new Property( "Boolean.prototype", "toString", "function" ); - // properties of the Boolean object - PROPERTY[p++] = new Property( "Boolean", "prototype", "object" ); - PROPERTY[p++] = new Property( "Boolean", "constructor", "function" ); - PROPERTY[p++] = new Property( "Boolean.prototype", "valueOf", "function" ); - PROPERTY[p++] = new Property( "Boolean.prototype", "toString", "function" ); +// properties of the Number object - // properties of the Number object +PROPERTY[p++] = new Property( "Number", "MAX_VALUE", "number" ); +PROPERTY[p++] = new Property( "Number", "MIN_VALUE", "number" ); +PROPERTY[p++] = new Property( "Number", "NaN", "number" ); +PROPERTY[p++] = new Property( "Number", "NEGATIVE_INFINITY", "number" ); +PROPERTY[p++] = new Property( "Number", "POSITIVE_INFINITY", "number" ); +PROPERTY[p++] = new Property( "Number.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "Number.prototype", "constructor", "function" ); +PROPERTY[p++] = new Property( "Number.prototype", "valueOf", "function" ); - PROPERTY[p++] = new Property( "Number", "MAX_VALUE", "number" ); - PROPERTY[p++] = new Property( "Number", "MIN_VALUE", "number" ); - PROPERTY[p++] = new Property( "Number", "NaN", "number" ); - PROPERTY[p++] = new Property( "Number", "NEGATIVE_INFINITY", "number" ); - PROPERTY[p++] = new Property( "Number", "POSITIVE_INFINITY", "number" ); - PROPERTY[p++] = new Property( "Number.prototype", "toString", "function" ); - PROPERTY[p++] = new Property( "Number.prototype", "constructor", "function" ); - PROPERTY[p++] = new Property( "Number.prototype", "valueOf", "function" ); +// properties of the Math Object. +PROPERTY[p++] = new Property( "Math", "E", "number" ); +PROPERTY[p++] = new Property( "Math", "LN10", "number" ); +PROPERTY[p++] = new Property( "Math", "LN2", "number" ); +PROPERTY[p++] = new Property( "Math", "LOG2E", "number" ); +PROPERTY[p++] = new Property( "Math", "LOG10E", "number" ); +PROPERTY[p++] = new Property( "Math", "PI", "number" ); +PROPERTY[p++] = new Property( "Math", "SQRT1_2", "number" ); +PROPERTY[p++] = new Property( "Math", "SQRT2", "number" ); +PROPERTY[p++] = new Property( "Math", "abs", "function" ); +PROPERTY[p++] = new Property( "Math", "acos", "function" ); +PROPERTY[p++] = new Property( "Math", "asin", "function" ); +PROPERTY[p++] = new Property( "Math", "atan", "function" ); +PROPERTY[p++] = new Property( "Math", "atan2", "function" ); +PROPERTY[p++] = new Property( "Math", "ceil", "function" ); +PROPERTY[p++] = new Property( "Math", "cos", "function" ); +PROPERTY[p++] = new Property( "Math", "exp", "function" ); +PROPERTY[p++] = new Property( "Math", "floor", "function" ); +PROPERTY[p++] = new Property( "Math", "log", "function" ); +PROPERTY[p++] = new Property( "Math", "max", "function" ); +PROPERTY[p++] = new Property( "Math", "min", "function" ); +PROPERTY[p++] = new Property( "Math", "pow", "function" ); +PROPERTY[p++] = new Property( "Math", "random", "function" ); +PROPERTY[p++] = new Property( "Math", "round", "function" ); +PROPERTY[p++] = new Property( "Math", "sin", "function" ); +PROPERTY[p++] = new Property( "Math", "sqrt", "function" ); +PROPERTY[p++] = new Property( "Math", "tan", "function" ); - // properties of the Math Object. - PROPERTY[p++] = new Property( "Math", "E", "number" ); - PROPERTY[p++] = new Property( "Math", "LN10", "number" ); - PROPERTY[p++] = new Property( "Math", "LN2", "number" ); - PROPERTY[p++] = new Property( "Math", "LOG2E", "number" ); - PROPERTY[p++] = new Property( "Math", "LOG10E", "number" ); - PROPERTY[p++] = new Property( "Math", "PI", "number" ); - PROPERTY[p++] = new Property( "Math", "SQRT1_2", "number" ); - PROPERTY[p++] = new Property( "Math", "SQRT2", "number" ); - PROPERTY[p++] = new Property( "Math", "abs", "function" ); - PROPERTY[p++] = new Property( "Math", "acos", "function" ); - PROPERTY[p++] = new Property( "Math", "asin", "function" ); - PROPERTY[p++] = new Property( "Math", "atan", "function" ); - PROPERTY[p++] = new Property( "Math", "atan2", "function" ); - PROPERTY[p++] = new Property( "Math", "ceil", "function" ); - PROPERTY[p++] = new Property( "Math", "cos", "function" ); - PROPERTY[p++] = new Property( "Math", "exp", "function" ); - PROPERTY[p++] = new Property( "Math", "floor", "function" ); - PROPERTY[p++] = new Property( "Math", "log", "function" ); - PROPERTY[p++] = new Property( "Math", "max", "function" ); - PROPERTY[p++] = new Property( "Math", "min", "function" ); - PROPERTY[p++] = new Property( "Math", "pow", "function" ); - PROPERTY[p++] = new Property( "Math", "random", "function" ); - PROPERTY[p++] = new Property( "Math", "round", "function" ); - PROPERTY[p++] = new Property( "Math", "sin", "function" ); - PROPERTY[p++] = new Property( "Math", "sqrt", "function" ); - PROPERTY[p++] = new Property( "Math", "tan", "function" ); +// properties of the Date object +PROPERTY[p++] = new Property( "Date", "parse", "function" ); +PROPERTY[p++] = new Property( "Date", "prototype", "object" ); +PROPERTY[p++] = new Property( "Date", "UTC", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "constructor", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "toString", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "valueOf", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getTime", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getFullYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCFullYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getMonth", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCMonth", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getDate", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCDate", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getDay", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCDay", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getHours", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCHours", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getMinutes", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCMinutes", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getSeconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCSeconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getMilliseconds","function" ); +PROPERTY[p++] = new Property( "Date.prototype", "getUTCMilliseconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setTime", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setMilliseconds","function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCMilliseconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setSeconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCSeconds", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setMinutes", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCMinutes", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setHours", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCHours", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setDate", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCDate", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setMonth", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCMonth", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setFullYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setUTCFullYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "setYear", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "toLocaleString", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "toUTCString", "function" ); +PROPERTY[p++] = new Property( "Date.prototype", "toGMTString", "function" ); - // properties of the Date object - PROPERTY[p++] = new Property( "Date", "parse", "function" ); - PROPERTY[p++] = new Property( "Date", "prototype", "object" ); - PROPERTY[p++] = new Property( "Date", "UTC", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "constructor", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "toString", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "valueOf", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getTime", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getYear", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getFullYear", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getUTCFullYear", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getMonth", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getUTCMonth", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getDate", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getUTCDate", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getDay", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getUTCDay", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getHours", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getUTCHours", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getMinutes", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getUTCMinutes", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getSeconds", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getUTCSeconds", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getMilliseconds","function" ); - PROPERTY[p++] = new Property( "Date.prototype", "getUTCMilliseconds", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setTime", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setMilliseconds","function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setUTCMilliseconds", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setSeconds", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setUTCSeconds", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setMinutes", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setUTCMinutes", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setHours", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setUTCHours", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setDate", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setUTCDate", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setMonth", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setUTCMonth", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setFullYear", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setUTCFullYear", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "setYear", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "toLocaleString", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "toUTCString", "function" ); - PROPERTY[p++] = new Property( "Date.prototype", "toGMTString", "function" ); +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + RESULT = eval("typeof " + PROPERTY[i].object + "." + PROPERTY[i].name ); - for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { - RESULT = eval("typeof " + PROPERTY[i].object + "." + PROPERTY[i].name ); + new TestCase( SECTION, + "typeof " + PROPERTY[i].object + "." + PROPERTY[i].name, + PROPERTY[i].type, + RESULT ); - testcases[tc++] = new TestCase( SECTION, - "typeof " + PROPERTY[i].object + "." + PROPERTY[i].name, - PROPERTY[i].type, - RESULT ); + RESULT = eval("typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']"); - RESULT = eval("typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']"); - - testcases[tc++] = new TestCase( SECTION, - "typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']", - PROPERTY[i].type, - RESULT ); - } - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + "typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']", + PROPERTY[i].type, + RESULT ); } + +test(); + function MyObject( arg0, arg1, arg2, arg3, arg4 ) { - this.name = arg0; + this.name = arg0; } function Property( object, name, type ) { - this.object = object; - this.name = name; - this.type = type; + this.object = object; + this.name = name; + this.type = type; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.1-2.js b/mozilla/js/tests/ecma/Expressions/11.2.1-2.js index 95bb2e5c7b9..009a6acc1af 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.1-2.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,106 +35,92 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.1-2.js - ECMA Section: 11.2.1 Property Accessors - Description: + File Name: 11.2.1-2.js + ECMA Section: 11.2.1 Property Accessors + Description: - Properties are accessed by name, using either the dot notation: - MemberExpression . Identifier - CallExpression . Identifier + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier - or the bracket notation: MemberExpression [ Expression ] - CallExpression [ Expression ] + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] - The dot notation is explained by the following syntactic conversion: - MemberExpression . Identifier - is identical in its behavior to - MemberExpression [ ] - and similarly - CallExpression . Identifier - is identical in its behavior to - CallExpression [ ] - where is a string literal containing the same sequence - of characters as the Identifier. + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. - The production MemberExpression : MemberExpression [ Expression ] is - evaluated as follows: + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: - 1. Evaluate MemberExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate Expression. - 4. Call GetValue(Result(3)). - 5. Call ToObject(Result(2)). - 6. Call ToString(Result(4)). - 7. Return a value of type Reference whose base object is Result(5) and - whose property name is Result(6). + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). - The production CallExpression : CallExpression [ Expression ] is evaluated - in exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Property Accessors"; - writeHeaderToLog( SECTION + " "+TITLE ); +var SECTION = "11.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); - var testcases = new Array(); +// go through all Native Function objects, methods, and properties and get their typeof. - // go through all Native Function objects, methods, and properties and get their typeof. +var PROPERTY = new Array(); +var p = 0; - var PROPERTY = new Array(); - var p = 0; +// try to access properties of primitive types - // try to access properties of primitive types - - PROPERTY[p++] = new Property( "\"hi\"", "hi", "hi", NaN ); - PROPERTY[p++] = new Property( NaN, NaN, "NaN", NaN ); +PROPERTY[p++] = new Property( "\"hi\"", "hi", "hi", NaN ); +PROPERTY[p++] = new Property( NaN, NaN, "NaN", NaN ); // PROPERTY[p++] = new Property( 3, 3, "3", 3 ); - PROPERTY[p++] = new Property( true, true, "true", 1 ); - PROPERTY[p++] = new Property( false, false, "false", 0 ); +PROPERTY[p++] = new Property( true, true, "true", 1 ); +PROPERTY[p++] = new Property( false, false, "false", 0 ); - for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { - testcases[tc++] = new TestCase( SECTION, - PROPERTY[i].object + ".valueOf()", - PROPERTY[i].value, - eval( PROPERTY[i].object+ ".valueOf()" ) ); +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); - testcases[tc++] = new TestCase( SECTION, - PROPERTY[i].object + ".toString()", - PROPERTY[i].string, - eval( PROPERTY[i].object+ ".toString()" ) ); + new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( PROPERTY[i].object+ ".toString()" ) ); - } - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); } + +test(); + function MyObject( value ) { - this.value = value; - this.stringValue = value +""; - this.numberValue = Number(value); - return this; + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; } function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; -} \ No newline at end of file + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.1-3-n.js b/mozilla/js/tests/ecma/Expressions/11.2.1-3-n.js index 6efdfecdaf6..91d44910027 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.1-3-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.1-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,102 +35,92 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.1-2.js - ECMA Section: 11.2.1 Property Accessors - Description: + File Name: 11.2.1-2.js + ECMA Section: 11.2.1 Property Accessors + Description: - Properties are accessed by name, using either the dot notation: - MemberExpression . Identifier - CallExpression . Identifier + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier - or the bracket notation: MemberExpression [ Expression ] - CallExpression [ Expression ] + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] - The dot notation is explained by the following syntactic conversion: - MemberExpression . Identifier - is identical in its behavior to - MemberExpression [ ] - and similarly - CallExpression . Identifier - is identical in its behavior to - CallExpression [ ] - where is a string literal containing the same sequence - of characters as the Identifier. + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. - The production MemberExpression : MemberExpression [ Expression ] is - evaluated as follows: + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: - 1. Evaluate MemberExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate Expression. - 4. Call GetValue(Result(3)). - 5. Call ToObject(Result(2)). - 6. Call ToString(Result(4)). - 7. Return a value of type Reference whose base object is Result(5) and - whose property name is Result(6). + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). - The production CallExpression : CallExpression [ Expression ] is evaluated - in exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Property Accessors"; - writeHeaderToLog( SECTION + " "+TITLE ); +var SECTION = "11.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); - var testcases = new Array(); +// go through all Native Function objects, methods, and properties and get their typeof. - // go through all Native Function objects, methods, and properties and get their typeof. +var PROPERTY = new Array(); +var p = 0; - var PROPERTY = new Array(); - var p = 0; +// try to access properties of primitive types - // try to access properties of primitive types +PROPERTY[p++] = new Property( "undefined", void 0, "undefined", NaN ); - PROPERTY[p++] = new Property( "undefined", void 0, "undefined", NaN ); +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { - for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { - testcases[tc++] = new TestCase( SECTION, - PROPERTY[i].object + ".valueOf()", - PROPERTY[i].value, - eval( PROPERTY[i].object+ ".valueOf()" ) ); + DESCRIPTION = PROPERTY[i].object + ".valueOf()"; + EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, - PROPERTY[i].object + ".toString()", - PROPERTY[i].string, - eval( PROPERTY[i].object+ ".toString()" ) ); + new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); - } - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval(PROPERTY[i].object+ ".toString()") ); } +test(); + + function MyObject( value ) { - this.value = value; - this.stringValue = value +""; - this.numberValue = Number(value); - return this; + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; } + function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; -} \ No newline at end of file + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.1-4-n.js b/mozilla/js/tests/ecma/Expressions/11.2.1-4-n.js index dcb16d4a76f..1c70cadcb30 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.1-4-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.1-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,83 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.1-4-n.js - ECMA Section: 11.2.1 Property Accessors - Description: + File Name: 11.2.1-4-n.js + ECMA Section: 11.2.1 Property Accessors + Description: - Properties are accessed by name, using either the dot notation: - MemberExpression . Identifier - CallExpression . Identifier + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier - or the bracket notation: MemberExpression [ Expression ] - CallExpression [ Expression ] + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] - The dot notation is explained by the following syntactic conversion: - MemberExpression . Identifier - is identical in its behavior to - MemberExpression [ ] - and similarly - CallExpression . Identifier - is identical in its behavior to - CallExpression [ ] - where is a string literal containing the same sequence - of characters as the Identifier. + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. - The production MemberExpression : MemberExpression [ Expression ] is - evaluated as follows: + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: - 1. Evaluate MemberExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate Expression. - 4. Call GetValue(Result(3)). - 5. Call ToObject(Result(2)). - 6. Call ToString(Result(4)). - 7. Return a value of type Reference whose base object is Result(5) and - whose property name is Result(6). + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). - The production CallExpression : CallExpression [ Expression ] is evaluated - in exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.1-4-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Property Accessors"; - writeHeaderToLog( SECTION + " "+TITLE ); +var SECTION = "11.2.1-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); - var testcases = new Array(); +// go through all Native Function objects, methods, and properties and get their typeof. - // go through all Native Function objects, methods, and properties and get their typeof. +var PROPERTY = new Array(); +var p = 0; - var PROPERTY = new Array(); - var p = 0; +// try to access properties of primitive types - // try to access properties of primitive types +PROPERTY[p++] = new Property( "null", null, "null", 0 ); - PROPERTY[p++] = new Property( "null", null, "null", 0 ); +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { - for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { - testcases[tc++] = new TestCase( SECTION, - PROPERTY[i].object + ".valueOf()", - PROPERTY[i].value, - eval( PROPERTY[i].object+ ".valueOf()" ) ); + DESCRIPTION = PROPERTY[i].object + ".valueOf()"; + EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, - PROPERTY[i].object + ".toString()", - PROPERTY[i].string, - eval( PROPERTY[i].object+ ".toString()" ) ); + new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( PROPERTY[i].object+ ".valueOf()" ) ); - } + new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval(PROPERTY[i].object+ ".toString()") ); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); } + +test(); + function MyObject( value ) { this.value = value; this.stringValue = value +""; @@ -132,4 +123,4 @@ function Property( object, value, string, number ) { this.string = String(value); this.number = Number(value); this.value = value; -} \ No newline at end of file +} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.1-5.js b/mozilla/js/tests/ecma/Expressions/11.2.1-5.js index 1aee7a7844c..88eecf7133a 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.1-5.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.1-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,106 +35,92 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.1-5.js - ECMA Section: 11.2.1 Property Accessors - Description: + File Name: 11.2.1-5.js + ECMA Section: 11.2.1 Property Accessors + Description: - Properties are accessed by name, using either the dot notation: - MemberExpression . Identifier - CallExpression . Identifier + Properties are accessed by name, using either the dot notation: + MemberExpression . Identifier + CallExpression . Identifier - or the bracket notation: MemberExpression [ Expression ] - CallExpression [ Expression ] + or the bracket notation: MemberExpression [ Expression ] + CallExpression [ Expression ] - The dot notation is explained by the following syntactic conversion: - MemberExpression . Identifier - is identical in its behavior to - MemberExpression [ ] - and similarly - CallExpression . Identifier - is identical in its behavior to - CallExpression [ ] - where is a string literal containing the same sequence - of characters as the Identifier. + The dot notation is explained by the following syntactic conversion: + MemberExpression . Identifier + is identical in its behavior to + MemberExpression [ ] + and similarly + CallExpression . Identifier + is identical in its behavior to + CallExpression [ ] + where is a string literal containing the same sequence + of characters as the Identifier. - The production MemberExpression : MemberExpression [ Expression ] is - evaluated as follows: + The production MemberExpression : MemberExpression [ Expression ] is + evaluated as follows: - 1. Evaluate MemberExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate Expression. - 4. Call GetValue(Result(3)). - 5. Call ToObject(Result(2)). - 6. Call ToString(Result(4)). - 7. Return a value of type Reference whose base object is Result(5) and - whose property name is Result(6). + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate Expression. + 4. Call GetValue(Result(3)). + 5. Call ToObject(Result(2)). + 6. Call ToString(Result(4)). + 7. Return a value of type Reference whose base object is Result(5) and + whose property name is Result(6). - The production CallExpression : CallExpression [ Expression ] is evaluated - in exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression [ Expression ] is evaluated + in exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.1-5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Property Accessors"; - writeHeaderToLog( SECTION + " "+TITLE ); +var SECTION = "11.2.1-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); - var testcases = new Array(); +// go through all Native Function objects, methods, and properties and get their typeof. - // go through all Native Function objects, methods, and properties and get their typeof. +var PROPERTY = new Array(); +var p = 0; - var PROPERTY = new Array(); - var p = 0; +// try to access properties of primitive types - // try to access properties of primitive types +PROPERTY[p++] = new Property( new String("hi"), "hi", "hi", NaN ); +PROPERTY[p++] = new Property( new Number(NaN), NaN, "NaN", NaN ); +PROPERTY[p++] = new Property( new Number(3), 3, "3", 3 ); +PROPERTY[p++] = new Property( new Boolean(true), true, "true", 1 ); +PROPERTY[p++] = new Property( new Boolean(false), false, "false", 0 ); - PROPERTY[p++] = new Property( new String("hi"), "hi", "hi", NaN ); - PROPERTY[p++] = new Property( new Number(NaN), NaN, "NaN", NaN ); - PROPERTY[p++] = new Property( new Number(3), 3, "3", 3 ); - PROPERTY[p++] = new Property( new Boolean(true), true, "true", 1 ); - PROPERTY[p++] = new Property( new Boolean(false), false, "false", 0 ); +for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { + new TestCase( SECTION, + PROPERTY[i].object + ".valueOf()", + PROPERTY[i].value, + eval( "PROPERTY[i].object.valueOf()" ) ); - for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { - testcases[tc++] = new TestCase( SECTION, - PROPERTY[i].object + ".valueOf()", - PROPERTY[i].value, - eval( "PROPERTY[i].object.valueOf()" ) ); + new TestCase( SECTION, + PROPERTY[i].object + ".toString()", + PROPERTY[i].string, + eval( "PROPERTY[i].object.toString()" ) ); - testcases[tc++] = new TestCase( SECTION, - PROPERTY[i].object + ".toString()", - PROPERTY[i].string, - eval( "PROPERTY[i].object.toString()" ) ); - - } - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); } + +test(); + function MyObject( value ) { - this.value = value; - this.stringValue = value +""; - this.numberValue = Number(value); - return this; + this.value = value; + this.stringValue = value +""; + this.numberValue = Number(value); + return this; } function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; -} \ No newline at end of file + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-1-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-1-n.js index 932d03ef06a..8faa63c9bdd 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-1-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-1.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-1.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-1-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-1-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var OBJECT = new Object(); +DESCRIPTION = "OBJECT = new Object; var o = new OBJECT()"; +EXPECTED = "error"; - var OBJECT = new Object(); - - testcases[tc++] = new TestCase( SECTION, - "OBJECT = new Object; var o = new OBJECT()", - "error", - o = new OBJECT() ); - test(); +new TestCase( SECTION, + "OBJECT = new Object; var o = new OBJECT()", + "error", + eval("o = new OBJECT()") ); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-1.js b/mozilla/js/tests/ecma/Expressions/11.2.2-1.js index e523c5b4ce1..9901717e359 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,64 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-1.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-1.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "(new TestFunction(0,1,2,3,4,5)).length", + 6, + (new TestFunction(0,1,2,3,4,5)).length ); - - testcases[tc++] = new TestCase( SECTION, - "(new TestFunction(0,1,2,3,4,5)).length", - 6, - (new TestFunction(0,1,2,3,4,5)).length ); - - - - test(); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-10-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-10-n.js index 0abb2451365..03fc2c18d2f 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-10-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-10-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,66 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-9-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-9-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-9-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +DESCRIPTION = "var m = new Math()"; +EXPECTED = "error"; - - testcases[tc++] = new TestCase( SECTION, - "var m = new Math()", - "error", - m = new Math() ); - test(); +new TestCase( SECTION, + "var m = new Math()", + "error", + eval("m = new Math()") ); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-11.js b/mozilla/js/tests/ecma/Expressions/11.2.2-11.js index bb2146dd88c..640d64cdbf0 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-11.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-11.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-9-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-9-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-9-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var FUNCTION = new Function(); - var FUNCTION = new Function(); +new TestCase( SECTION, + "var FUNCTION = new Function(); f = new FUNCTION(); typeof f", + "object", + eval("var FUNCTION = new Function(); f = new FUNCTION(); typeof f") ); - testcases[tc++] = new TestCase( SECTION, - "var FUNCTION = new Function(); f = new FUNCTION(); typeof f", - "object", - eval("var FUNCTION = new Function(); f = new FUNCTION(); typeof f") ); +new TestCase( SECTION, + "var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f", + "object", + eval("var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f") ); - testcases[tc++] = new TestCase( SECTION, - "var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f", - "object", - eval("var FUNCTION = new Function('return this'); f = new FUNCTION(); typeof f") ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-2-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-2-n.js index bc5c7a50c16..904e2d19f3c 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-2-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-2.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-2.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-2-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-2-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var UNDEFINED = void 0; +DESCRIPTION = "UNDEFINED = void 0; var o = new UNDEFINED()"; +EXPECTED = "error"; - var UNDEFINED = void 0; - - testcases[tc++] = new TestCase( SECTION, - "UNDEFINED = void 0; var o = new UNDEFINED()", - "error", - o = new UNDEFINED() ); - test(); +new TestCase( SECTION, + "UNDEFINED = void 0; var o = new UNDEFINED()", + "error", + eval("o = new UNDEFINED()") ); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-3-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-3-n.js index 9b22a7b0496..583dfc2739d 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-3-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,64 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-3-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-3-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-3-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-3-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var DESCRIPTION = "NULL = null; var o = new NULL()"; +var EXPECTED = "error"; +var NULL = null; +new TestCase( SECTION, + "NULL = null; var o = new NULL()", + "error", + eval("o = new NULL()") ); +test(); - var NULL = null; - - testcases[tc++] = new TestCase( SECTION, - "NULL = null; var o = new NULL()", - "error", - o = new NULL() ); - test(); - -function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-4-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-4-n.js index 2d71c091d15..4d678d0694d 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-4-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-4-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-4-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-4-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-4-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var STRING = ""; +DESCRIPTION = "STRING = '', var s = new STRING()"; +EXPECTED = "error"; - var STRING = ""; - - testcases[tc++] = new TestCase( SECTION, - "STRING = '', var s = new STRING()", - "error", - s = new STRING() ); - test(); +new TestCase( SECTION, + "STRING = '', var s = new STRING()", + "error", + eval("s = new STRING()") ); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-5-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-5-n.js index 20dd1539223..e347aaca7e0 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-5-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-5-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-5-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-5-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-5-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-5-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var NUMBER = 0; +DESCRIPTION = "NUMBER=0, var n = new NUMBER()"; +EXPECTED = "error"; - var NUMBER = 0; - - testcases[tc++] = new TestCase( SECTION, - "NUMBER=0, var n = new NUMBER()", - "error", - n = new NUMBER() ); - test(); +new TestCase( SECTION, + "NUMBER=0, var n = new NUMBER()", + "error", + eval("n = new NUMBER()") ); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-6-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-6-n.js index 2b5fea2648e..eafb728709f 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-6-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-6-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,63 +35,67 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-6-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-6-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-6-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var BOOLEAN = true; +var BOOLEAN = true; +DESCRIPTION = "BOOLEAN = true; var b = new BOOLEAN()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, - "BOOLEAN = true; var b = new BOOLEAN()", - "error", - b = new BOOLEAN() ); - test(); +new TestCase( SECTION, + "BOOLEAN = true; var b = new BOOLEAN()", + "error", + eval("b = new BOOLEAN()") ); +test(); function TestFunction() { - return arguments; + return arguments; } + diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-7-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-7-n.js index 19ba7bdbba6..93708a76ba4 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-7-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-7-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-6-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-6-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-6-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var STRING = new String("hi"); +DESCRIPTION = "var STRING = new String('hi'); var s = new STRING()"; +EXPECTED = "error"; - var STRING = new String("hi"); - - testcases[tc++] = new TestCase( SECTION, - "var STRING = new String('hi'); var s = new STRING()", - "error", - s = new STRING() ); - test(); +new TestCase( SECTION, + "var STRING = new String('hi'); var s = new STRING()", + "error", + eval("s = new STRING()") ); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-8-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-8-n.js index 64507e7fb6b..d3d042ba2ff 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-8-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-8-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-8-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-8-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-8-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-8-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var NUMBER = new Number(1); +DESCRIPTION = "var NUMBER = new Number(1); var n = new NUMBER()"; +EXPECTED = "error"; - var NUMBER = new Number(1); - - testcases[tc++] = new TestCase( SECTION, - "var NUMBER = new Number(1); var n = new NUMBER()", - "error", - n = new NUMBER() ); - test(); +new TestCase( SECTION, + "var NUMBER = new Number(1); var n = new NUMBER()", + "error", + eval("n = new NUMBER()") ); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.2-9-n.js b/mozilla/js/tests/ecma/Expressions/11.2.2-9-n.js index d2370873035..ce8fc31e4f3 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.2-9-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.2-9-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.2-9-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: 11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: - MemberExpression: - PrimaryExpression - MemberExpression[Expression] - MemberExpression.Identifier - new MemberExpression Arguments + MemberExpression: + PrimaryExpression + MemberExpression[Expression] + MemberExpression.Identifier + new MemberExpression Arguments - new NewExpression + new NewExpression - The production NewExpression : new NewExpression is evaluated as follows: + The production NewExpression : new NewExpression is evaluated as follows: 1. Evaluate NewExpression. 2. Call GetValue(Result(1)). 3. If Type(Result(2)) is not Object, generate a runtime error. 4. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 5. Call the [[Construct]] method on Result(2), providing no arguments - (that is, an empty list of arguments). + (that is, an empty list of arguments). 6. If Type(Result(5)) is not Object, generate a runtime error. 7. Return Result(5). - The production MemberExpression : new MemberExpression Arguments is evaluated as follows: + The production MemberExpression : new MemberExpression Arguments is evaluated as follows: 1. Evaluate MemberExpression. 2. Call GetValue(Result(1)). 3. Evaluate Arguments, producing an internal list of argument values - (section 0). + (section 0). 4. If Type(Result(2)) is not Object, generate a runtime error. 5. If Result(2) does not implement the internal [[Construct]] method, - generate a runtime error. + generate a runtime error. 6. Call the [[Construct]] method on Result(2), providing the list - Result(3) as the argument values. + Result(3) as the argument values. 7. If Type(Result(6)) is not Object, generate a runtime error. 8 .Return Result(6). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.2-9-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The new operator"; +var SECTION = "11.2.2-9-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The new operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var BOOLEAN = new Boolean(); +DESCRIPTION = "var BOOLEAN = new Boolean(); var b = new BOOLEAN()"; +EXPECTED = "error"; - var BOOLEAN = new Boolean(); - - testcases[tc++] = new TestCase( SECTION, - "var BOOLEAN = new Boolean(); var b = new BOOLEAN()", - "error", - b = new BOOLEAN() ); - test(); +new TestCase( SECTION, + "var BOOLEAN = new Boolean(); var b = new BOOLEAN()", + "error", + eval("b = new BOOLEAN()") ); +test(); function TestFunction() { - return arguments; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + return arguments; } diff --git a/mozilla/js/tests/ecma/Expressions/11.2.3-1.js b/mozilla/js/tests/ecma/Expressions/11.2.3-1.js index 371f3db0745..c13e87e2e93 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.3-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,103 +35,89 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.3-1.js - ECMA Section: 11.2.3. Function Calls - Description: + File Name: 11.2.3-1.js + ECMA Section: 11.2.3. Function Calls + Description: - The production CallExpression : MemberExpression Arguments is evaluated as - follows: + The production CallExpression : MemberExpression Arguments is evaluated as + follows: - 1.Evaluate MemberExpression. - 2.Evaluate Arguments, producing an internal list of argument values - (section 0). - 3.Call GetValue(Result(1)). - 4.If Type(Result(3)) is not Object, generate a runtime error. - 5.If Result(3) does not implement the internal [[Call]] method, generate a - runtime error. - 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, - Result(6) is null. - 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is - the same as Result(6). - 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value - and providing the list Result(2) as the argument values. - 9.Return Result(8). + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). - The production CallExpression : CallExpression Arguments is evaluated in - exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Note: Result(8) will never be of type Reference if Result(3) is a native - ECMAScript object. Whether calling a host object can return a value of - type Reference is implementation-dependent. + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function Calls"; +var SECTION = "11.2.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +writeHeaderToLog( SECTION + " "+ TITLE); /* this.eval() is no longer legal syntax. - // MemberExpression : this +// MemberExpression : this - testcases[tc++] = new TestCase( SECTION, - "this.eval()", - void 0, - this.eval() ); +new TestCase( SECTION, +"this.eval()", +void 0, +this.eval() ); - testcases[tc++] = new TestCase( SECTION, - "this.eval('NaN')", - NaN, - this.eval("NaN") ); +new TestCase( SECTION, +"this.eval('NaN')", +NaN, +this.eval("NaN") ); */ - // MemberExpression: Identifier +// MemberExpression: Identifier - var OBJECT = true; +var OBJECT = true; - testcases[tc++] = new TestCase( SECTION, - "OBJECT.toString()", - "true", - OBJECT.toString() ); +new TestCase( SECTION, + "OBJECT.toString()", + "true", + OBJECT.toString() ); - // MemberExpression[ Expression] +// MemberExpression[ Expression] - testcases[tc++] = new TestCase( SECTION, - "(new Array())['length'].valueOf()", - 0, - (new Array())["length"].valueOf() ); +new TestCase( SECTION, + "(new Array())['length'].valueOf()", + 0, + (new Array())["length"].valueOf() ); - // MemberExpression . Identifier - testcases[tc++] = new TestCase( SECTION, - "(new Array()).length.valueOf()", - 0, - (new Array()).length.valueOf() ); - // new MemberExpression Arguments +// MemberExpression . Identifier +new TestCase( SECTION, + "(new Array()).length.valueOf()", + 0, + (new Array()).length.valueOf() ); +// new MemberExpression Arguments - testcases[tc++] = new TestCase( SECTION, - "(new Array(20))['length'].valueOf()", - 20, - (new Array(20))["length"].valueOf() ); +new TestCase( SECTION, + "(new Array(20))['length'].valueOf()", + 20, + (new Array(20))["length"].valueOf() ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.3-2-n.js b/mozilla/js/tests/ecma/Expressions/11.2.3-2-n.js index 208a9ae92e3..0b0e54d55e1 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.3-2-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.3-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,58 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.3-2-n.js - ECMA Section: 11.2.3. Function Calls - Description: + File Name: 11.2.3-2-n.js + ECMA Section: 11.2.3. Function Calls + Description: - The production CallExpression : MemberExpression Arguments is evaluated as - follows: + The production CallExpression : MemberExpression Arguments is evaluated as + follows: - 1.Evaluate MemberExpression. - 2.Evaluate Arguments, producing an internal list of argument values - (section 0). - 3.Call GetValue(Result(1)). - 4.If Type(Result(3)) is not Object, generate a runtime error. - 5.If Result(3) does not implement the internal [[Call]] method, generate a - runtime error. - 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, - Result(6) is null. - 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is - the same as Result(6). - 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value - and providing the list Result(2) as the argument values. - 9.Return Result(8). + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). - The production CallExpression : CallExpression Arguments is evaluated in - exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Note: Result(8) will never be of type Reference if Result(3) is a native - ECMAScript object. Whether calling a host object can return a value of - type Reference is implementation-dependent. + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.3-2-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function Calls"; +var SECTION = "11.2.3-2-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "3.valueOf()", + 3, + eval("3.valueOf()") ); - testcases[tc++] = new TestCase( SECTION, - "3.valueOf()", - 3, - 3.valueOf() ); +new TestCase( SECTION, + "(3).valueOf()", + 3, + eval("(3).valueOf()") ); - testcases[tc++] = new TestCase( SECTION, - "(3).valueOf()", - 3, - (3).valueOf() ); +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.3-3-n.js b/mozilla/js/tests/ecma/Expressions/11.2.3-3-n.js index 81d39477125..4fbc52684d1 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.3-3-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.3-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,63 +35,55 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.3-3-n.js - ECMA Section: 11.2.3. Function Calls - Description: + File Name: 11.2.3-3-n.js + ECMA Section: 11.2.3. Function Calls + Description: - The production CallExpression : MemberExpression Arguments is evaluated as - follows: + The production CallExpression : MemberExpression Arguments is evaluated as + follows: - 1.Evaluate MemberExpression. - 2.Evaluate Arguments, producing an internal list of argument values - (section 0). - 3.Call GetValue(Result(1)). - 4.If Type(Result(3)) is not Object, generate a runtime error. - 5.If Result(3) does not implement the internal [[Call]] method, generate a - runtime error. - 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, - Result(6) is null. - 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is - the same as Result(6). - 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value - and providing the list Result(2) as the argument values. - 9.Return Result(8). + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). - The production CallExpression : CallExpression Arguments is evaluated in - exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Note: Result(8) will never be of type Reference if Result(3) is a native - ECMAScript object. Whether calling a host object can return a value of - type Reference is implementation-dependent. + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.3-3-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function Calls"; +var SECTION = "11.2.3-3-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +DESCRIPTION = "(void 0).valueOf()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, "(void 0).valueOf()", "error", (void 0).valueOf() ); - test(); +new TestCase( SECTION, + "(void 0).valueOf()", + "error", + eval("(void 0).valueOf()") ); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.3-4-n.js b/mozilla/js/tests/ecma/Expressions/11.2.3-4-n.js index 3fef8194440..63517bbbf82 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.3-4-n.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.3-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,63 +35,55 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.3-4-n.js - ECMA Section: 11.2.3. Function Calls - Description: + File Name: 11.2.3-4-n.js + ECMA Section: 11.2.3. Function Calls + Description: - The production CallExpression : MemberExpression Arguments is evaluated as - follows: + The production CallExpression : MemberExpression Arguments is evaluated as + follows: - 1.Evaluate MemberExpression. - 2.Evaluate Arguments, producing an internal list of argument values - (section 0). - 3.Call GetValue(Result(1)). - 4.If Type(Result(3)) is not Object, generate a runtime error. - 5.If Result(3) does not implement the internal [[Call]] method, generate a - runtime error. - 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, - Result(6) is null. - 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is - the same as Result(6). - 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value - and providing the list Result(2) as the argument values. - 9.Return Result(8). + 1.Evaluate MemberExpression. + 2.Evaluate Arguments, producing an internal list of argument values + (section 0). + 3.Call GetValue(Result(1)). + 4.If Type(Result(3)) is not Object, generate a runtime error. + 5.If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6.If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7.If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8.Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9.Return Result(8). - The production CallExpression : CallExpression Arguments is evaluated in - exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Note: Result(8) will never be of type Reference if Result(3) is a native - ECMAScript object. Whether calling a host object can return a value of - type Reference is implementation-dependent. + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.3-4-n.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function Calls"; +var SECTION = "11.2.3-4-n.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +DESCRIPTION = "null.valueOf()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, "null.valueOf()", "error", null.valueOf() ); - test(); +new TestCase( SECTION, + "null.valueOf()", + "error", + eval("null.valueOf()") ); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.2.3-5.js b/mozilla/js/tests/ecma/Expressions/11.2.3-5.js index 8f28d4d262b..37cd797d1ab 100644 --- a/mozilla/js/tests/ecma/Expressions/11.2.3-5.js +++ b/mozilla/js/tests/ecma/Expressions/11.2.3-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,63 +35,49 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.2.3-5-n.js - ECMA Section: 11.2.3. Function Calls - Description: + File Name: 11.2.3-5-n.js + ECMA Section: 11.2.3. Function Calls + Description: - The production CallExpression : MemberExpression Arguments is evaluated as - follows: + The production CallExpression : MemberExpression Arguments is evaluated as + follows: - 1. Evaluate MemberExpression. - 2. Evaluate Arguments, producing an internal list of argument values - (section 0). - 3. Call GetValue(Result(1)). - 4. If Type(Result(3)) is not Object, generate a runtime error. - 5. If Result(3) does not implement the internal [[Call]] method, generate a - runtime error. - 6. If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, - Result(6) is null. - 7. If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is - the same as Result(6). - 8. Call the [[Call]] method on Result(3), providing Result(7) as the this value - and providing the list Result(2) as the argument values. - 9. Return Result(8). + 1. Evaluate MemberExpression. + 2. Evaluate Arguments, producing an internal list of argument values + (section 0). + 3. Call GetValue(Result(1)). + 4. If Type(Result(3)) is not Object, generate a runtime error. + 5. If Result(3) does not implement the internal [[Call]] method, generate a + runtime error. + 6. If Type(Result(1)) is Reference, Result(6) is GetBase(Result(1)). Otherwise, + Result(6) is null. + 7. If Result(6) is an activation object, Result(7) is null. Otherwise, Result(7) is + the same as Result(6). + 8. Call the [[Call]] method on Result(3), providing Result(7) as the this value + and providing the list Result(2) as the argument values. + 9. Return Result(8). - The production CallExpression : CallExpression Arguments is evaluated in - exactly the same manner, except that the contained CallExpression is - evaluated in step 1. + The production CallExpression : CallExpression Arguments is evaluated in + exactly the same manner, except that the contained CallExpression is + evaluated in step 1. - Note: Result(8) will never be of type Reference if Result(3) is a native - ECMAScript object. Whether calling a host object can return a value of - type Reference is implementation-dependent. + Note: Result(8) will never be of type Reference if Result(3) is a native + ECMAScript object. Whether calling a host object can return a value of + type Reference is implementation-dependent. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.2.3-5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function Calls"; +var SECTION = "11.2.3-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function Calls"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, "true.valueOf()", true, true.valueOf() ); +test(); - testcases[tc++] = new TestCase( SECTION, "true.valueOf()", true, true.valueOf() ); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.3.1.js b/mozilla/js/tests/ecma/Expressions/11.3.1.js index 4d1c125e42f..a191b59ccd8 100644 --- a/mozilla/js/tests/ecma/Expressions/11.3.1.js +++ b/mozilla/js/tests/ecma/Expressions/11.3.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,136 +35,117 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.3.1.js - ECMA Section: 11.3.1 Postfix increment operator - Description: - The production MemberExpression : MemberExpression ++ is evaluated as - follows: + File Name: 11.3.1.js + ECMA Section: 11.3.1 Postfix increment operator + Description: + The production MemberExpression : MemberExpression ++ is evaluated as + follows: - 1. Evaluate MemberExpression. - 2. Call GetValue(Result(1)). - 3. Call ToNumber(Result(2)). - 4. Add the value 1 to Result(3), using the same rules as for the + - operator (section 0). - 5. Call PutValue(Result(1), Result(4)). - 6. Return Result(3). + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Add the value 1 to Result(3), using the same rules as for the + + operator (section 0). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(3). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.3.1"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "11.3.1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Postfix increment operator"); +writeHeaderToLog( SECTION + " Postfix increment operator"); - testcases = getTestCases(); - test(); +// special numbers +new TestCase( SECTION, "var MYVAR; MYVAR++", NaN, eval("var MYVAR; MYVAR++") ); +new TestCase( SECTION, "var MYVAR= void 0; MYVAR++", NaN, eval("var MYVAR=void 0; MYVAR++") ); +new TestCase( SECTION, "var MYVAR=null; MYVAR++", 0, eval("var MYVAR=null; MYVAR++") ); +new TestCase( SECTION, "var MYVAR=true; MYVAR++", 1, eval("var MYVAR=true; MYVAR++") ); +new TestCase( SECTION, "var MYVAR=false; MYVAR++", 0, eval("var MYVAR=false; MYVAR++") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// verify return value - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++") ); - // special numbers - array[item++] = new TestCase( SECTION, "var MYVAR; MYVAR++", NaN, eval("var MYVAR; MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR= void 0; MYVAR++", NaN, eval("var MYVAR=void 0; MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=null; MYVAR++", 0, eval("var MYVAR=null; MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=true; MYVAR++", 1, eval("var MYVAR=true; MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false; MYVAR++", 0, eval("var MYVAR=false; MYVAR++") ); +// verify value of variable - // verify return value +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++") ); +// number primitives +new TestCase( SECTION, "var MYVAR=0;MYVAR++", 0, eval("var MYVAR=0;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++", 0.2345, eval("var MYVAR=0.2345;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++", -0.2345, eval("var MYVAR=-0.2345;MYVAR++") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++;MYVAR", 1.2345, eval("var MYVAR=0.2345;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++;MYVAR", 0.7655, eval("var MYVAR=-0.2345;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); - // number primitives - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++", 0, eval("var MYVAR=0;MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++", 0.2345, eval("var MYVAR=0.2345;MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++", -0.2345, eval("var MYVAR=-0.2345;MYVAR++") ); +// boolean values +// verify return value - // verify value of variable +new TestCase( SECTION, "var MYVAR=true;MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=false;MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR++;MYVAR", 1.2345, eval("var MYVAR=0.2345;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR++;MYVAR", 0.7655, eval("var MYVAR=-0.2345;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR++;MYVAR", 1, eval("var MYVAR=0;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=true;MYVAR++;MYVAR", 2, eval("var MYVAR=true;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;MYVAR++;MYVAR", 1, eval("var MYVAR=false;MYVAR++;MYVAR") ); - // boolean values - // verify return value +// boolean objects +// verify return value - array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); - // verify value of variable +new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR++;MYVAR", 2, eval("var MYVAR=true;MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR++;MYVAR", 1, eval("var MYVAR=false;MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++;MYVAR", 2, eval("var MYVAR=new Boolean(true);MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++;MYVAR", 1, eval("var MYVAR=new Boolean(false);MYVAR++;MYVAR") ); - // boolean objects - // verify return value +// string primitives +new TestCase( SECTION, "var MYVAR='string';MYVAR++", Number.NaN, eval("var MYVAR='string';MYVAR++") ); +new TestCase( SECTION, "var MYVAR='12345';MYVAR++", 12345, eval("var MYVAR='12345';MYVAR++") ); +new TestCase( SECTION, "var MYVAR='-12345';MYVAR++", -12345, eval("var MYVAR='-12345';MYVAR++") ); +new TestCase( SECTION, "var MYVAR='0Xf';MYVAR++", 15, eval("var MYVAR='0Xf';MYVAR++") ); +new TestCase( SECTION, "var MYVAR='077';MYVAR++", 77, eval("var MYVAR='077';MYVAR++") ); +new TestCase( SECTION, "var MYVAR=''; MYVAR++", 0, eval("var MYVAR='';MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++", 1, eval("var MYVAR=true;MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++", 0, eval("var MYVAR=false;MYVAR++") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR++;MYVAR", 2, eval("var MYVAR=new Boolean(true);MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR++;MYVAR", 1, eval("var MYVAR=new Boolean(false);MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='string';MYVAR++;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';MYVAR++;MYVAR", 12346, eval("var MYVAR='12345';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';MYVAR++;MYVAR", -12344, eval("var MYVAR='-12345';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='0xf';MYVAR++;MYVAR", 16, eval("var MYVAR='0xf';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';MYVAR++;MYVAR", 78, eval("var MYVAR='077';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR='';MYVAR++;MYVAR", 1, eval("var MYVAR='';MYVAR++;MYVAR") ); - // string primitives - array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR++", Number.NaN, eval("var MYVAR='string';MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR++", 12345, eval("var MYVAR='12345';MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR++", -12345, eval("var MYVAR='-12345';MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';MYVAR++", 15, eval("var MYVAR='0Xf';MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR++", 77, eval("var MYVAR='077';MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=''; MYVAR++", 0, eval("var MYVAR='';MYVAR++") ); +// string objects +new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++", Number.NaN, eval("var MYVAR=new String('string');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++", 12345, eval("var MYVAR=new String('12345');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++", -12345, eval("var MYVAR=new String('-12345');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR++", 15, eval("var MYVAR=new String('0Xf');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++", 77, eval("var MYVAR=new String('077');MYVAR++") ); +new TestCase( SECTION, "var MYVAR=new String(''); MYVAR++", 0, eval("var MYVAR=new String('');MYVAR++") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR++;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR++;MYVAR", 12346, eval("var MYVAR='12345';MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR++;MYVAR", -12344, eval("var MYVAR='-12345';MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='0xf';MYVAR++;MYVAR", 16, eval("var MYVAR='0xf';MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR++;MYVAR", 78, eval("var MYVAR='077';MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='';MYVAR++;MYVAR", 1, eval("var MYVAR='';MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++;MYVAR", 12346, eval("var MYVAR=new String('12345');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++;MYVAR", -12344, eval("var MYVAR=new String('-12345');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR++;MYVAR", 16, eval("var MYVAR=new String('0xf');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++;MYVAR", 78, eval("var MYVAR=new String('077');MYVAR++;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('');MYVAR++;MYVAR", 1, eval("var MYVAR=new String('');MYVAR++;MYVAR") ); - // string objects - array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++", Number.NaN, eval("var MYVAR=new String('string');MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++", 12345, eval("var MYVAR=new String('12345');MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++", -12345, eval("var MYVAR=new String('-12345');MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR++", 15, eval("var MYVAR=new String('0Xf');MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++", 77, eval("var MYVAR=new String('077');MYVAR++") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); MYVAR++", 0, eval("var MYVAR=new String('');MYVAR++") ); +test(); - // verify value of variable - - array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR++;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR++;MYVAR", 12346, eval("var MYVAR=new String('12345');MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR++;MYVAR", -12344, eval("var MYVAR=new String('-12345');MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR++;MYVAR", 16, eval("var MYVAR=new String('0xf');MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR++;MYVAR", 78, eval("var MYVAR=new String('077');MYVAR++;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('');MYVAR++;MYVAR", 1, eval("var MYVAR=new String('');MYVAR++;MYVAR") ); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.3.2.js b/mozilla/js/tests/ecma/Expressions/11.3.2.js index 955a1cd0170..afc0c8b8491 100644 --- a/mozilla/js/tests/ecma/Expressions/11.3.2.js +++ b/mozilla/js/tests/ecma/Expressions/11.3.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,136 +35,117 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.3.2.js - ECMA Section: 11.3.2 Postfix decrement operator - Description: + File Name: 11.3.2.js + ECMA Section: 11.3.2 Postfix decrement operator + Description: - 11.3.2 Postfix decrement operator + 11.3.2 Postfix decrement operator - The production MemberExpression : MemberExpression -- is evaluated as follows: - 1. Evaluate MemberExpression. - 2. Call GetValue(Result(1)). - 3. Call ToNumber(Result(2)). - 4. Subtract the value 1 from Result(3), using the same rules as for the - - operator (section 0). - 5. Call PutValue(Result(1), Result(4)). - 6. Return Result(3). + The production MemberExpression : MemberExpression -- is evaluated as follows: + 1. Evaluate MemberExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Subtract the value 1 from Result(3), using the same rules as for the - + operator (section 0). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(3). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.3.2"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.3.2"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Postfix decrement operator"); - test(); +writeHeaderToLog( SECTION + " Postfix decrement operator"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// special numbers +new TestCase( SECTION, "var MYVAR; MYVAR--", NaN, eval("var MYVAR; MYVAR--") ); +new TestCase( SECTION, "var MYVAR= void 0; MYVAR--", NaN, eval("var MYVAR=void 0; MYVAR--") ); +new TestCase( SECTION, "var MYVAR=null; MYVAR--", 0, eval("var MYVAR=null; MYVAR--") ); +new TestCase( SECTION, "var MYVAR=true; MYVAR--", 1, eval("var MYVAR=true; MYVAR--") ); +new TestCase( SECTION, "var MYVAR=false; MYVAR--", 0, eval("var MYVAR=false; MYVAR--") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +// verify return value - // special numbers - array[item++] = new TestCase( SECTION, "var MYVAR; MYVAR--", NaN, eval("var MYVAR; MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR= void 0; MYVAR--", NaN, eval("var MYVAR=void 0; MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=null; MYVAR--", 0, eval("var MYVAR=null; MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=true; MYVAR--", 1, eval("var MYVAR=true; MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false; MYVAR--", 0, eval("var MYVAR=false; MYVAR--") ); +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--") ); - // verify return value +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--;MYVAR") ); - // verify value of variable +// number primitives +new TestCase( SECTION, "var MYVAR=0;MYVAR--", 0, eval("var MYVAR=0;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--", 0.2345, eval("var MYVAR=0.2345;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--", -0.2345, eval("var MYVAR=-0.2345;MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;MYVAR--;MYVAR") ); +// verify value of variable - // number primitives - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--", 0, eval("var MYVAR=0;MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--", 0.2345, eval("var MYVAR=0.2345;MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--", -0.2345, eval("var MYVAR=-0.2345;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--;MYVAR", -0.7655, eval("var MYVAR=0.2345;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--;MYVAR", -1.2345, eval("var MYVAR=-0.2345;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); - // verify value of variable +// boolean values +// verify return value - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;MYVAR--;MYVAR", -0.7655, eval("var MYVAR=0.2345;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;MYVAR--;MYVAR", -1.2345, eval("var MYVAR=-0.2345;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;MYVAR--;MYVAR", -1, eval("var MYVAR=0;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=true;MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=false;MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); +// verify value of variable - // boolean values - // verify return value +new TestCase( SECTION, "var MYVAR=true;MYVAR--;MYVAR", 0, eval("var MYVAR=true;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;MYVAR--;MYVAR", -1, eval("var MYVAR=false;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); - // verify value of variable +// boolean objects +// verify return value - array[item++] = new TestCase( SECTION, "var MYVAR=true;MYVAR--;MYVAR", 0, eval("var MYVAR=true;MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false;MYVAR--;MYVAR", -1, eval("var MYVAR=false;MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); +// verify value of variable - // boolean objects - // verify return value +new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--;MYVAR", 0, eval("var MYVAR=new Boolean(true);MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--;MYVAR", -1, eval("var MYVAR=new Boolean(false);MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--", 1, eval("var MYVAR=true;MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--", 0, eval("var MYVAR=false;MYVAR--") ); - // verify value of variable +// string primitives +new TestCase( SECTION, "var MYVAR='string';MYVAR--", Number.NaN, eval("var MYVAR='string';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='12345';MYVAR--", 12345, eval("var MYVAR='12345';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='-12345';MYVAR--", -12345, eval("var MYVAR='-12345';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='0Xf';MYVAR--", 15, eval("var MYVAR='0Xf';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='077';MYVAR--", 77, eval("var MYVAR='077';MYVAR--") ); +new TestCase( SECTION, "var MYVAR=''; MYVAR--", 0, eval("var MYVAR='';MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);MYVAR--;MYVAR", 0, eval("var MYVAR=new Boolean(true);MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);MYVAR--;MYVAR", -1, eval("var MYVAR=new Boolean(false);MYVAR--;MYVAR") ); +// verify value of variable - // string primitives - array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR--", Number.NaN, eval("var MYVAR='string';MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR--", 12345, eval("var MYVAR='12345';MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR--", -12345, eval("var MYVAR='-12345';MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';MYVAR--", 15, eval("var MYVAR='0Xf';MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR--", 77, eval("var MYVAR='077';MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=''; MYVAR--", 0, eval("var MYVAR='';MYVAR--") ); +new TestCase( SECTION, "var MYVAR='string';MYVAR--;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';MYVAR--;MYVAR", 12344, eval("var MYVAR='12345';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';MYVAR--;MYVAR", -12346, eval("var MYVAR='-12345';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='0xf';MYVAR--;MYVAR", 14, eval("var MYVAR='0xf';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';MYVAR--;MYVAR", 76, eval("var MYVAR='077';MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR='';MYVAR--;MYVAR", -1, eval("var MYVAR='';MYVAR--;MYVAR") ); - // verify value of variable +// string objects +new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--", Number.NaN, eval("var MYVAR=new String('string');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--", 12345, eval("var MYVAR=new String('12345');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--", -12345, eval("var MYVAR=new String('-12345');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR--", 15, eval("var MYVAR=new String('0Xf');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--", 77, eval("var MYVAR=new String('077');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String(''); MYVAR--", 0, eval("var MYVAR=new String('');MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR='string';MYVAR--;MYVAR", Number.NaN, eval("var MYVAR='string';MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='12345';MYVAR--;MYVAR", 12344, eval("var MYVAR='12345';MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='-12345';MYVAR--;MYVAR", -12346, eval("var MYVAR='-12345';MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='0xf';MYVAR--;MYVAR", 14, eval("var MYVAR='0xf';MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='077';MYVAR--;MYVAR", 76, eval("var MYVAR='077';MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='';MYVAR--;MYVAR", -1, eval("var MYVAR='';MYVAR--;MYVAR") ); +// verify value of variable - // string objects - array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--", Number.NaN, eval("var MYVAR=new String('string');MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--", 12345, eval("var MYVAR=new String('12345');MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--", -12345, eval("var MYVAR=new String('-12345');MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');MYVAR--", 15, eval("var MYVAR=new String('0Xf');MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--", 77, eval("var MYVAR=new String('077');MYVAR--") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); MYVAR--", 0, eval("var MYVAR=new String('');MYVAR--") ); +new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--;MYVAR", 12344, eval("var MYVAR=new String('12345');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--;MYVAR", -12346, eval("var MYVAR=new String('-12345');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR--;MYVAR", 14, eval("var MYVAR=new String('0xf');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--;MYVAR", 76, eval("var MYVAR=new String('077');MYVAR--;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('');MYVAR--;MYVAR", -1, eval("var MYVAR=new String('');MYVAR--;MYVAR") ); - // verify value of variable - - array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');MYVAR--;MYVAR", Number.NaN, eval("var MYVAR=new String('string');MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');MYVAR--;MYVAR", 12344, eval("var MYVAR=new String('12345');MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');MYVAR--;MYVAR", -12346, eval("var MYVAR=new String('-12345');MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');MYVAR--;MYVAR", 14, eval("var MYVAR=new String('0xf');MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');MYVAR--;MYVAR", 76, eval("var MYVAR=new String('077');MYVAR--;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('');MYVAR--;MYVAR", -1, eval("var MYVAR=new String('');MYVAR--;MYVAR") ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.4.1.js b/mozilla/js/tests/ecma/Expressions/11.4.1.js index e0b9440672c..c5cbfe469f2 100644 --- a/mozilla/js/tests/ecma/Expressions/11.4.1.js +++ b/mozilla/js/tests/ecma/Expressions/11.4.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,77 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.4.1.js - ECMA Section: 11.4.1 the Delete Operator - Description: returns true if the property could be deleted - returns false if it could not be deleted - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 11.4.1.js + ECMA Section: 11.4.1 the Delete Operator + Description: returns true if the property could be deleted + returns false if it could not be deleted + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "11.4.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The delete operator"; +var SECTION = "11.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The delete operator"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - -// array[item++] = new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.length", 2, eval("x=[9,8,7];delete(x[2]);x.length") ); -// array[item++] = new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.toString()", "9,8", eval("x=[9,8,7];delete(x[2]);x.toString()") ); - array[item++] = new TestCase( SECTION, "x=new Date();delete x;typeof(x)", "undefined", eval("x=new Date();delete x;typeof(x)") ); +// new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.length", 2, eval("x=[9,8,7];delete(x[2]);x.length") ); +// new TestCase( SECTION, "x=[9,8,7];delete(x[2]);x.toString()", "9,8", eval("x=[9,8,7];delete(x[2]);x.toString()") ); +new TestCase( SECTION, "x=new Date();delete x;typeof(x)", "undefined", eval("x=new Date();delete x;typeof(x)") ); // array[item++] = new TestCase( SECTION, "delete(x=new Date())", true, delete(x=new Date()) ); // array[item++] = new TestCase( SECTION, "delete('string primitive')", true, delete("string primitive") ); // array[item++] = new TestCase( SECTION, "delete(new String( 'string object' ) )", true, delete(new String("string object")) ); // array[item++] = new TestCase( SECTION, "delete(new Number(12345) )", true, delete(new Number(12345)) ); - array[item++] = new TestCase( SECTION, "delete(Math.PI)", false, delete(Math.PI) ); +new TestCase( SECTION, "delete(Math.PI)", false, delete(Math.PI) ); // array[item++] = new TestCase( SECTION, "delete(null)", true, delete(null) ); // array[item++] = new TestCase( SECTION, "delete(void(0))", true, delete(void(0)) ); - // variables declared with the var statement are not deletable. +// variables declared with the var statement are not deletable. - var abc; - array[item++] = new TestCase( SECTION, "var abc; delete(abc)", false, delete abc ); +var abc; +new TestCase( SECTION, "var abc; delete(abc)", false, delete abc ); - array[item++] = new TestCase( SECTION, - "var OB = new MyObject(); for ( p in OB ) { delete p }", - true, - eval("var OB = new MyObject(); for ( p in OB ) { delete p }") ); - return ( array ); -} +new TestCase( SECTION, + "var OB = new MyObject(); for ( p in OB ) { delete p }", + true, + eval("var OB = new MyObject(); for ( p in OB ) { delete p }") ); -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - - } - stopTest(); - return ( testcases ); -} +test(); function MyObject() { - this.prop1 = true; - this.prop2 = false; - this.prop3 = null - this.prop4 = void 0; - this.prop5 = "hi"; - this.prop6 = 42; - this.prop7 = new Date(); - this.prop8 = Math.PI; -} \ No newline at end of file + this.prop1 = true; + this.prop2 = false; + this.prop3 = null; + this.prop4 = void 0; + this.prop5 = "hi"; + this.prop6 = 42; + this.prop7 = new Date(); + this.prop8 = Math.PI; +} diff --git a/mozilla/js/tests/ecma/Expressions/11.4.2.js b/mozilla/js/tests/ecma/Expressions/11.4.2.js index 9ed2d480e0e..872c482af81 100644 --- a/mozilla/js/tests/ecma/Expressions/11.4.2.js +++ b/mozilla/js/tests/ecma/Expressions/11.4.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 11.4.2.js ECMA Section: 11.4.2 the Void Operator @@ -49,52 +51,31 @@ writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "void(new String('string object'))", void 0, void(new String( 'string object' )) ); - array[item++] = new TestCase( SECTION, "void('string primitive')", void 0, void("string primitive") ); - array[item++] = new TestCase( SECTION, "void(Number.NaN)", void 0, void(Number.NaN) ); - array[item++] = new TestCase( SECTION, "void(Number.POSITIVE_INFINITY)", void 0, void(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "void(1)", void 0, void(1) ); - array[item++] = new TestCase( SECTION, "void(0)", void 0, void(0) ); - array[item++] = new TestCase( SECTION, "void(-1)", void 0, void(-1) ); - array[item++] = new TestCase( SECTION, "void(Number.NEGATIVE_INFINITY)", void 0, void(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "void(Math.PI)", void 0, void(Math.PI) ); - array[item++] = new TestCase( SECTION, "void(true)", void 0, void(true) ); - array[item++] = new TestCase( SECTION, "void(false)", void 0, void(false) ); - array[item++] = new TestCase( SECTION, "void(null)", void 0, void(null) ); - array[item++] = new TestCase( SECTION, "void new String('string object')", void 0, void new String( 'string object' ) ); - array[item++] = new TestCase( SECTION, "void 'string primitive'", void 0, void "string primitive" ); - array[item++] = new TestCase( SECTION, "void Number.NaN", void 0, void Number.NaN ); - array[item++] = new TestCase( SECTION, "void Number.POSITIVE_INFINITY", void 0, void Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "void 1", void 0, void 1 ); - array[item++] = new TestCase( SECTION, "void 0", void 0, void 0 ); - array[item++] = new TestCase( SECTION, "void -1", void 0, void -1 ); - array[item++] = new TestCase( SECTION, "void Number.NEGATIVE_INFINITY", void 0, void Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "void Math.PI", void 0, void Math.PI ); - array[item++] = new TestCase( SECTION, "void true", void 0, void true ); - array[item++] = new TestCase( SECTION, "void false", void 0, void false ); - array[item++] = new TestCase( SECTION, "void null", void 0, void null ); +new TestCase( SECTION, "void(new String('string object'))", void 0, void(new String( 'string object' )) ); +new TestCase( SECTION, "void('string primitive')", void 0, void("string primitive") ); +new TestCase( SECTION, "void(Number.NaN)", void 0, void(Number.NaN) ); +new TestCase( SECTION, "void(Number.POSITIVE_INFINITY)", void 0, void(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "void(1)", void 0, void(1) ); +new TestCase( SECTION, "void(0)", void 0, void(0) ); +new TestCase( SECTION, "void(-1)", void 0, void(-1) ); +new TestCase( SECTION, "void(Number.NEGATIVE_INFINITY)", void 0, void(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "void(Math.PI)", void 0, void(Math.PI) ); +new TestCase( SECTION, "void(true)", void 0, void(true) ); +new TestCase( SECTION, "void(false)", void 0, void(false) ); +new TestCase( SECTION, "void(null)", void 0, void(null) ); +new TestCase( SECTION, "void new String('string object')", void 0, void new String( 'string object' ) ); +new TestCase( SECTION, "void 'string primitive'", void 0, void "string primitive" ); +new TestCase( SECTION, "void Number.NaN", void 0, void Number.NaN ); +new TestCase( SECTION, "void Number.POSITIVE_INFINITY", void 0, void Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "void 1", void 0, void 1 ); +new TestCase( SECTION, "void 0", void 0, void 0 ); +new TestCase( SECTION, "void -1", void 0, void -1 ); +new TestCase( SECTION, "void Number.NEGATIVE_INFINITY", void 0, void Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "void Math.PI", void 0, void Math.PI ); +new TestCase( SECTION, "void true", void 0, void true ); +new TestCase( SECTION, "void false", void 0, void false ); +new TestCase( SECTION, "void null", void 0, void null ); // array[item++] = new TestCase( SECTION, "void()", void 0, void() ); - return ( array ); -} - -function test() { - for ( i = 0; i < testcases.length; i++ ) { - testcases[i].passed = writeTestCaseResult( - testcases[i].expect, - testcases[i].actual, - testcases[i].description +" = "+ testcases[i].actual ); - testcases[i].reason += ( testcases[i].passed ) ? "" : "wrong value " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.4.3.js b/mozilla/js/tests/ecma/Expressions/11.4.3.js index c84f9d86449..0d5bbb161f2 100644 --- a/mozilla/js/tests/ecma/Expressions/11.4.3.js +++ b/mozilla/js/tests/ecma/Expressions/11.4.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,91 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: typeof_1.js - ECMA Section: 11.4.3 typeof operator - Description: typeof evaluates unary expressions: - undefined "undefined" - null "object" - Boolean "boolean" - Number "number" - String "string" - Object "object" [native, doesn't implement Call] - Object "function" [native, implements [Call]] - Object implementation dependent - [not sure how to test this] - Author: christine@netscape.com - Date: june 30, 1997 + File Name: typeof_1.js + ECMA Section: 11.4.3 typeof operator + Description: typeof evaluates unary expressions: + undefined "undefined" + null "object" + Boolean "boolean" + Number "number" + String "string" + Object "object" [native, doesn't implement Call] + Object "function" [native, implements [Call]] + Object implementation dependent + [not sure how to test this] + Author: christine@netscape.com + Date: june 30, 1997 */ - var SECTION = "11.4.3"; +var SECTION = "11.4.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = " The typeof operator"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = " The typeof operator"; +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, "typeof(void(0))", "undefined", typeof(void(0)) ); +new TestCase( SECTION, "typeof(null)", "object", typeof(null) ); +new TestCase( SECTION, "typeof(true)", "boolean", typeof(true) ); +new TestCase( SECTION, "typeof(false)", "boolean", typeof(false) ); +new TestCase( SECTION, "typeof(new Boolean())", "object", typeof(new Boolean()) ); +new TestCase( SECTION, "typeof(new Boolean(true))", "object", typeof(new Boolean(true)) ); +new TestCase( SECTION, "typeof(Boolean())", "boolean", typeof(Boolean()) ); +new TestCase( SECTION, "typeof(Boolean(false))", "boolean", typeof(Boolean(false)) ); +new TestCase( SECTION, "typeof(Boolean(true))", "boolean", typeof(Boolean(true)) ); +new TestCase( SECTION, "typeof(NaN)", "number", typeof(Number.NaN) ); +new TestCase( SECTION, "typeof(Infinity)", "number", typeof(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "typeof(-Infinity)", "number", typeof(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "typeof(Math.PI)", "number", typeof(Math.PI) ); +new TestCase( SECTION, "typeof(0)", "number", typeof(0) ); +new TestCase( SECTION, "typeof(1)", "number", typeof(1) ); +new TestCase( SECTION, "typeof(-1)", "number", typeof(-1) ); +new TestCase( SECTION, "typeof('0')", "string", typeof("0") ); +new TestCase( SECTION, "typeof(Number())", "number", typeof(Number()) ); +new TestCase( SECTION, "typeof(Number(0))", "number", typeof(Number(0)) ); +new TestCase( SECTION, "typeof(Number(1))", "number", typeof(Number(1)) ); +new TestCase( SECTION, "typeof(Nubmer(-1))", "number", typeof(Number(-1)) ); +new TestCase( SECTION, "typeof(new Number())", "object", typeof(new Number()) ); +new TestCase( SECTION, "typeof(new Number(0))", "object", typeof(new Number(0)) ); +new TestCase( SECTION, "typeof(new Number(1))", "object", typeof(new Number(1)) ); + +// Math does not implement [[Construct]] or [[Call]] so its type is object. + +new TestCase( SECTION, "typeof(Math)", "object", typeof(Math) ); + +new TestCase( SECTION, "typeof(Number.prototype.toString)", "function", typeof(Number.prototype.toString) ); + +new TestCase( SECTION, "typeof('a string')", "string", typeof("a string") ); +new TestCase( SECTION, "typeof('')", "string", typeof("") ); +new TestCase( SECTION, "typeof(new Date())", "object", typeof(new Date()) ); +new TestCase( SECTION, "typeof(new Array(1,2,3))", "object", typeof(new Array(1,2,3)) ); +new TestCase( SECTION, "typeof(new String('string object'))", "object", typeof(new String("string object")) ); +new TestCase( SECTION, "typeof(String('string primitive'))", "string", typeof(String("string primitive")) ); +new TestCase( SECTION, "typeof(['array', 'of', 'strings'])", "object", typeof(["array", "of", "strings"]) ); +new TestCase( SECTION, "typeof(new Function())", "function", typeof( new Function() ) ); +new TestCase( SECTION, "typeof(parseInt)", "function", typeof( parseInt ) ); +new TestCase( SECTION, "typeof(test)", "function", typeof( test ) ); +new TestCase( SECTION, "typeof(String.fromCharCode)", "function", typeof( String.fromCharCode ) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(void(0))", "undefined", typeof(void(0)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(null)", "object", typeof(null) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(true)", "boolean", typeof(true) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(false)", "boolean", typeof(false) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new Boolean())", "object", typeof(new Boolean()) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new Boolean(true))", "object", typeof(new Boolean(true)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean())", "boolean", typeof(Boolean()) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean(false))", "boolean", typeof(Boolean(false)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Boolean(true))", "boolean", typeof(Boolean(true)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(NaN)", "number", typeof(Number.NaN) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Infinity)", "number", typeof(Number.POSITIVE_INFINITY) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(-Infinity)", "number", typeof(Number.NEGATIVE_INFINITY) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Math.PI)", "number", typeof(Math.PI) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(0)", "number", typeof(0) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(1)", "number", typeof(1) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(-1)", "number", typeof(-1) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof('0')", "string", typeof("0") ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Number())", "number", typeof(Number()) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Number(0))", "number", typeof(Number(0)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Number(1))", "number", typeof(Number(1)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(Nubmer(-1))", "number", typeof(Number(-1)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number())", "object", typeof(new Number()) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number(0))", "object", typeof(new Number(0)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new Number(1))", "object", typeof(new Number(1)) ); +test(); - // Math does not implement [[Construct]] or [[Call]] so its type is object. - - testcases[testcases.length] = new TestCase( SECTION, "typeof(Math)", "object", typeof(Math) ); - - testcases[testcases.length] = new TestCase( SECTION, "typeof(Number.prototype.toString)", "function", typeof(Number.prototype.toString) ); - - testcases[testcases.length] = new TestCase( SECTION, "typeof('a string')", "string", typeof("a string") ); - testcases[testcases.length] = new TestCase( SECTION, "typeof('')", "string", typeof("") ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new Date())", "object", typeof(new Date()) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new Array(1,2,3))", "object", typeof(new Array(1,2,3)) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new String('string object'))", "object", typeof(new String("string object")) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(String('string primitive'))", "string", typeof(String("string primitive")) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(['array', 'of', 'strings'])", "object", typeof(["array", "of", "strings"]) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(new Function())", "function", typeof( new Function() ) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(parseInt)", "function", typeof( parseInt ) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(test)", "function", typeof( test ) ); - testcases[testcases.length] = new TestCase( SECTION, "typeof(String.fromCharCode)", "function", typeof( String.fromCharCode ) ); - - - writeHeaderToLog( SECTION + " "+ TITLE); - test(); - - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.4.4.js b/mozilla/js/tests/ecma/Expressions/11.4.4.js index a0d727a31a9..a6d27343a42 100644 --- a/mozilla/js/tests/ecma/Expressions/11.4.4.js +++ b/mozilla/js/tests/ecma/Expressions/11.4.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,138 +35,120 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.4.4.js - ECMA Section: 11.4.4 Prefix increment operator - Description: - The production UnaryExpression : ++ UnaryExpression is evaluated as - follows: + File Name: 11.4.4.js + ECMA Section: 11.4.4 Prefix increment operator + Description: + The production UnaryExpression : ++ UnaryExpression is evaluated as + follows: - 1. Evaluate UnaryExpression. - 2. Call GetValue(Result(1)). - 3. Call ToNumber(Result(2)). - 4. Add the value 1 to Result(3), using the same rules as for the + - operator (section 11.6.3). - 5. Call PutValue(Result(1), Result(4)). - 6. Return Result(4). + 1. Evaluate UnaryExpression. + 2. Call GetValue(Result(1)). + 3. Call ToNumber(Result(2)). + 4. Add the value 1 to Result(3), using the same rules as for the + + operator (section 11.6.3). + 5. Call PutValue(Result(1), Result(4)). + 6. Return Result(4). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.4.4"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.4.4"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Prefix increment operator"); - test(); +writeHeaderToLog( SECTION + " Prefix increment operator"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// special case: var is not defined - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var MYVAR; ++MYVAR", NaN, eval("var MYVAR; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR= void 0; ++MYVAR", NaN, eval("var MYVAR=void 0; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR=null; ++MYVAR", 1, eval("var MYVAR=null; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR=true; ++MYVAR", 2, eval("var MYVAR=true; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR=false; ++MYVAR", 1, eval("var MYVAR=false; ++MYVAR") ); - // special case: var is not defined +// special numbers +// verify return value - array[item++] = new TestCase( SECTION, "var MYVAR; ++MYVAR", NaN, eval("var MYVAR; ++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR= void 0; ++MYVAR", NaN, eval("var MYVAR=void 0; ++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=null; ++MYVAR", 1, eval("var MYVAR=null; ++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=true; ++MYVAR", 2, eval("var MYVAR=true; ++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false; ++MYVAR", 1, eval("var MYVAR=false; ++MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR") ); - // special numbers - // verify return value +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR") ); - - // verify value of variable - - array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;++MYVAR;MYVAR") ); - // number primitives - array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR", 1, eval("var MYVAR=0;++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR") ); +// number primitives +new TestCase( SECTION, "var MYVAR=0;++MYVAR", 1, eval("var MYVAR=0;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR;MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR;MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;++MYVAR;MYVAR", 1.2345, eval("var MYVAR=0.2345;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;++MYVAR;MYVAR", 0.7655, eval("var MYVAR=-0.2345;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;++MYVAR;MYVAR", 1, eval("var MYVAR=0;++MYVAR;MYVAR") ); - // boolean values - // verify return value +// boolean values +// verify return value - array[item++] = new TestCase( SECTION, "var MYVAR=true;++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false;++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); - // verify value of variable +new TestCase( SECTION, "var MYVAR=true;++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=true;++MYVAR;MYVAR", 2, eval("var MYVAR=true;++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false;++MYVAR;MYVAR", 1, eval("var MYVAR=false;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=true;++MYVAR;MYVAR", 2, eval("var MYVAR=true;++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;++MYVAR;MYVAR", 1, eval("var MYVAR=false;++MYVAR;MYVAR") ); - // boolean objects - // verify return value +// boolean objects +// verify return value - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); - // verify value of variable +new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR", 2, eval("var MYVAR=true;++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR", 1, eval("var MYVAR=false;++MYVAR") ); +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR;MYVAR", 2, eval("var MYVAR=new Boolean(true);++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR;MYVAR", 1, eval("var MYVAR=new Boolean(false);++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(true);++MYVAR;MYVAR", 2, eval("var MYVAR=new Boolean(true);++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);++MYVAR;MYVAR", 1, eval("var MYVAR=new Boolean(false);++MYVAR;MYVAR") ); - // string primitives - array[item++] = new TestCase( SECTION, "var MYVAR='string';++MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='12345';++MYVAR", 12346, eval("var MYVAR='12345';++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='-12345';++MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';++MYVAR", 16, eval("var MYVAR='0Xf';++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='077';++MYVAR", 78, eval("var MYVAR='077';++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=''; ++MYVAR", 1, eval("var MYVAR='';++MYVAR") ); +// string primitives +new TestCase( SECTION, "var MYVAR='string';++MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';++MYVAR", 12346, eval("var MYVAR='12345';++MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';++MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR") ); +new TestCase( SECTION, "var MYVAR='0Xf';++MYVAR", 16, eval("var MYVAR='0Xf';++MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';++MYVAR", 78, eval("var MYVAR='077';++MYVAR") ); +new TestCase( SECTION, "var MYVAR=''; ++MYVAR", 1, eval("var MYVAR='';++MYVAR") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR='string';++MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='12345';++MYVAR;MYVAR", 12346, eval("var MYVAR='12345';++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='-12345';++MYVAR;MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='0xf';++MYVAR;MYVAR", 16, eval("var MYVAR='0xf';++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='077';++MYVAR;MYVAR", 78, eval("var MYVAR='077';++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='';++MYVAR;MYVAR", 1, eval("var MYVAR='';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='string';++MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';++MYVAR;MYVAR", 12346, eval("var MYVAR='12345';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';++MYVAR;MYVAR", -12344, eval("var MYVAR='-12345';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='0xf';++MYVAR;MYVAR", 16, eval("var MYVAR='0xf';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';++MYVAR;MYVAR", 78, eval("var MYVAR='077';++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='';++MYVAR;MYVAR", 1, eval("var MYVAR='';++MYVAR;MYVAR") ); - // string objects - array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');++MYVAR", 16, eval("var MYVAR=new String('0Xf');++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); ++MYVAR", 1, eval("var MYVAR=new String('');++MYVAR") ); +// string objects +new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0Xf');++MYVAR", 16, eval("var MYVAR=new String('0Xf');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String(''); ++MYVAR", 1, eval("var MYVAR=new String('');++MYVAR") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR;MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR;MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');++MYVAR;MYVAR", 16, eval("var MYVAR=new String('0xf');++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR;MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('');++MYVAR;MYVAR", 1, eval("var MYVAR=new String('');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('string');++MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');++MYVAR;MYVAR", 12346, eval("var MYVAR=new String('12345');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');++MYVAR;MYVAR", -12344, eval("var MYVAR=new String('-12345');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0xf');++MYVAR;MYVAR", 16, eval("var MYVAR=new String('0xf');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');++MYVAR;MYVAR", 78, eval("var MYVAR=new String('077');++MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('');++MYVAR;MYVAR", 1, eval("var MYVAR=new String('');++MYVAR;MYVAR") ); + +test(); - return ( array ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.4.5.js b/mozilla/js/tests/ecma/Expressions/11.4.5.js index c7ca3e20e37..415fb3e3390 100644 --- a/mozilla/js/tests/ecma/Expressions/11.4.5.js +++ b/mozilla/js/tests/ecma/Expressions/11.4.5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,136 +35,118 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.4.5.js - ECMA Section: 11.4.5 Prefix decrement operator - Description: + File Name: 11.4.5.js + ECMA Section: 11.4.5 Prefix decrement operator + Description: - The production UnaryExpression : -- UnaryExpression is evaluated as follows: + The production UnaryExpression : -- UnaryExpression is evaluated as follows: - 1.Evaluate UnaryExpression. - 2.Call GetValue(Result(1)). - 3.Call ToNumber(Result(2)). - 4.Subtract the value 1 from Result(3), using the same rules as for the - operator (section 11.6.3). - 5.Call PutValue(Result(1), Result(4)). + 1.Evaluate UnaryExpression. + 2.Call GetValue(Result(1)). + 3.Call ToNumber(Result(2)). + 4.Subtract the value 1 from Result(3), using the same rules as for the - operator (section 11.6.3). + 5.Call PutValue(Result(1), Result(4)). - 1.Return Result(4). - Author: christine@netscape.com - Date: 12 november 1997 + 1.Return Result(4). + Author: christine@netscape.com + Date: \ 12 november 1997 */ - var SECTION = "11.4.5"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.4.5"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Prefix decrement operator"); - test(); +writeHeaderToLog( SECTION + " Prefix decrement operator"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// +new TestCase( SECTION, "var MYVAR; --MYVAR", NaN, eval("var MYVAR; --MYVAR") ); +new TestCase( SECTION, "var MYVAR= void 0; --MYVAR", NaN, eval("var MYVAR=void 0; --MYVAR") ); +new TestCase( SECTION, "var MYVAR=null; --MYVAR", -1, eval("var MYVAR=null; --MYVAR") ); +new TestCase( SECTION, "var MYVAR=true; --MYVAR", 0, eval("var MYVAR=true; --MYVAR") ); +new TestCase( SECTION, "var MYVAR=false; --MYVAR", -1, eval("var MYVAR=false; --MYVAR") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +// special numbers +// verify return value - // - array[item++] = new TestCase( SECTION, "var MYVAR; --MYVAR", NaN, eval("var MYVAR; --MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR= void 0; --MYVAR", NaN, eval("var MYVAR=void 0; --MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=null; --MYVAR", -1, eval("var MYVAR=null; --MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=true; --MYVAR", 0, eval("var MYVAR=true; --MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false; --MYVAR", -1, eval("var MYVAR=false; --MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR") ); - // special numbers - // verify return value +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR") ); - - // verify value of variable - - array[item++] = new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR", Number.POSITIVE_INFINITY, eval("var MYVAR=Number.POSITIVE_INFINITY;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR", Number.NEGATIVE_INFINITY, eval("var MYVAR=Number.NEGATIVE_INFINITY;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=Number.NaN;--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=Number.NaN;--MYVAR;MYVAR") ); - // number primitives - array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR", -1, eval("var MYVAR=0;--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR") ); +// number primitives +new TestCase( SECTION, "var MYVAR=0;--MYVAR", -1, eval("var MYVAR=0;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR;MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR;MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0.2345;--MYVAR;MYVAR", -0.7655, eval("var MYVAR=0.2345;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=-0.2345;--MYVAR;MYVAR", -1.2345, eval("var MYVAR=-0.2345;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=0;--MYVAR;MYVAR", -1, eval("var MYVAR=0;--MYVAR;MYVAR") ); - // boolean values - // verify return value +// boolean values +// verify return value - array[item++] = new TestCase( SECTION, "var MYVAR=true;--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false;--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); - // verify value of variable +new TestCase( SECTION, "var MYVAR=true;--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=true;--MYVAR;MYVAR", 0, eval("var MYVAR=true;--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=false;--MYVAR;MYVAR", -1, eval("var MYVAR=false;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=true;--MYVAR;MYVAR", 0, eval("var MYVAR=true;--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=false;--MYVAR;MYVAR", -1, eval("var MYVAR=false;--MYVAR;MYVAR") ); - // boolean objects - // verify return value +// boolean objects +// verify return value - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); - // verify value of variable +new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR", 0, eval("var MYVAR=true;--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR", -1, eval("var MYVAR=false;--MYVAR") ); +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR;MYVAR", 0, eval("var MYVAR=new Boolean(true);--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR;MYVAR", -1, eval("var MYVAR=new Boolean(false);--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(true);--MYVAR;MYVAR", 0, eval("var MYVAR=new Boolean(true);--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new Boolean(false);--MYVAR;MYVAR", -1, eval("var MYVAR=new Boolean(false);--MYVAR;MYVAR") ); - // string primitives - array[item++] = new TestCase( SECTION, "var MYVAR='string';--MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='12345';--MYVAR", 12344, eval("var MYVAR='12345';--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='-12345';--MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='0Xf';--MYVAR", 14, eval("var MYVAR='0Xf';--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='077';--MYVAR", 76, eval("var MYVAR='077';--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=''; --MYVAR", -1, eval("var MYVAR='';--MYVAR") ); +// string primitives +new TestCase( SECTION, "var MYVAR='string';--MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';--MYVAR", 12344, eval("var MYVAR='12345';--MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';--MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR") ); +new TestCase( SECTION, "var MYVAR='0Xf';--MYVAR", 14, eval("var MYVAR='0Xf';--MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';--MYVAR", 76, eval("var MYVAR='077';--MYVAR") ); +new TestCase( SECTION, "var MYVAR=''; --MYVAR", -1, eval("var MYVAR='';--MYVAR") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR='string';--MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='12345';--MYVAR;MYVAR", 12344, eval("var MYVAR='12345';--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='-12345';--MYVAR;MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='0xf';--MYVAR;MYVAR", 14, eval("var MYVAR='0xf';--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='077';--MYVAR;MYVAR", 76, eval("var MYVAR='077';--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR='';--MYVAR;MYVAR", -1, eval("var MYVAR='';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='string';--MYVAR;MYVAR", Number.NaN, eval("var MYVAR='string';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='12345';--MYVAR;MYVAR", 12344, eval("var MYVAR='12345';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='-12345';--MYVAR;MYVAR", -12346, eval("var MYVAR='-12345';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='0xf';--MYVAR;MYVAR", 14, eval("var MYVAR='0xf';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='077';--MYVAR;MYVAR", 76, eval("var MYVAR='077';--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR='';--MYVAR;MYVAR", -1, eval("var MYVAR='';--MYVAR;MYVAR") ); - // string objects - array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('0Xf');--MYVAR", 14, eval("var MYVAR=new String('0Xf');--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String(''); --MYVAR", -1, eval("var MYVAR=new String('');--MYVAR") ); +// string objects +new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0Xf');--MYVAR", 14, eval("var MYVAR=new String('0Xf');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String(''); --MYVAR", -1, eval("var MYVAR=new String('');--MYVAR") ); - // verify value of variable +// verify value of variable - array[item++] = new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR;MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR;MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('0xf');--MYVAR;MYVAR", 14, eval("var MYVAR=new String('0xf');--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR;MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR;MYVAR") ); - array[item++] = new TestCase( SECTION, "var MYVAR=new String('');--MYVAR;MYVAR", -1, eval("var MYVAR=new String('');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('string');--MYVAR;MYVAR", Number.NaN, eval("var MYVAR=new String('string');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('12345');--MYVAR;MYVAR", 12344, eval("var MYVAR=new String('12345');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('-12345');--MYVAR;MYVAR", -12346, eval("var MYVAR=new String('-12345');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('0xf');--MYVAR;MYVAR", 14, eval("var MYVAR=new String('0xf');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('077');--MYVAR;MYVAR", 76, eval("var MYVAR=new String('077');--MYVAR;MYVAR") ); +new TestCase( SECTION, "var MYVAR=new String('');--MYVAR;MYVAR", -1, eval("var MYVAR=new String('');--MYVAR;MYVAR") ); + +test(); - return ( array ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.4.6.js b/mozilla/js/tests/ecma/Expressions/11.4.6.js index 366c699f31b..9db559a51cb 100644 --- a/mozilla/js/tests/ecma/Expressions/11.4.6.js +++ b/mozilla/js/tests/ecma/Expressions/11.4.6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,280 +36,261 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 11.4.6.js - ECMA Section: 11.4.6 Unary + Operator - Description: convert operand to Number type - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 11.4.6.js + ECMA Section: 11.4.6 Unary + Operator + Description: convert operand to Number type + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "11.4.6"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); - var BUGNUMBER="77391"; +var SECTION = "11.4.6"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Unary + operator"); - test(); +var BUGNUMBER="77391"; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +writeHeaderToLog( SECTION + " Unary + operator"); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "+('')", 0, +("") ); - array[item++] = new TestCase( SECTION, "+(' ')", 0, +(" ") ); - array[item++] = new TestCase( SECTION, "+(\\t)", 0, +("\t") ); - array[item++] = new TestCase( SECTION, "+(\\n)", 0, +("\n") ); - array[item++] = new TestCase( SECTION, "+(\\r)", 0, +("\r") ); - array[item++] = new TestCase( SECTION, "+(\\f)", 0, +("\f") ); +new TestCase( SECTION, "+('')", 0, +("") ); +new TestCase( SECTION, "+(' ')", 0, +(" ") ); +new TestCase( SECTION, "+(\\t)", 0, +("\t") ); +new TestCase( SECTION, "+(\\n)", 0, +("\n") ); +new TestCase( SECTION, "+(\\r)", 0, +("\r") ); +new TestCase( SECTION, "+(\\f)", 0, +("\f") ); - array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x0009)", 0, +(String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x0020)", 0, +(String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000C)", 0, +(String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000B)", 0, +(String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000D)", 0, +(String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "+(String.fromCharCode(0x000A)", 0, +(String.fromCharCode(0x000A)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x0009)", 0, +(String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x0020)", 0, +(String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x000C)", 0, +(String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x000B)", 0, +(String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x000D)", 0, +(String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+(String.fromCharCode(0x000A)", 0, +(String.fromCharCode(0x000A)) ); - // a StringNumericLiteral may be preceeded or followed by whitespace and/or - // line terminators +// a StringNumericLiteral may be preceeded or followed by whitespace and/or +// line terminators - array[item++] = new TestCase( SECTION, "+( ' ' + 999 )", 999, +( ' '+999) ); - array[item++] = new TestCase( SECTION, "+( '\\n' + 999 )", 999, +( '\n' +999) ); - array[item++] = new TestCase( SECTION, "+( '\\r' + 999 )", 999, +( '\r' +999) ); - array[item++] = new TestCase( SECTION, "+( '\\t' + 999 )", 999, +( '\t' +999) ); - array[item++] = new TestCase( SECTION, "+( '\\f' + 999 )", 999, +( '\f' +999) ); +new TestCase( SECTION, "+( ' ' + 999 )", 999, +( ' '+999) ); +new TestCase( SECTION, "+( '\\n' + 999 )", 999, +( '\n' +999) ); +new TestCase( SECTION, "+( '\\r' + 999 )", 999, +( '\r' +999) ); +new TestCase( SECTION, "+( '\\t' + 999 )", 999, +( '\t' +999) ); +new TestCase( SECTION, "+( '\\f' + 999 )", 999, +( '\f' +999) ); - array[item++] = new TestCase( SECTION, "+( 999 + ' ' )", 999, +( 999+' ') ); - array[item++] = new TestCase( SECTION, "+( 999 + '\\n' )", 999, +( 999+'\n' ) ); - array[item++] = new TestCase( SECTION, "+( 999 + '\\r' )", 999, +( 999+'\r' ) ); - array[item++] = new TestCase( SECTION, "+( 999 + '\\t' )", 999, +( 999+'\t' ) ); - array[item++] = new TestCase( SECTION, "+( 999 + '\\f' )", 999, +( 999+'\f' ) ); +new TestCase( SECTION, "+( 999 + ' ' )", 999, +( 999+' ') ); +new TestCase( SECTION, "+( 999 + '\\n' )", 999, +( 999+'\n' ) ); +new TestCase( SECTION, "+( 999 + '\\r' )", 999, +( 999+'\r' ) ); +new TestCase( SECTION, "+( 999 + '\\t' )", 999, +( 999+'\t' ) ); +new TestCase( SECTION, "+( 999 + '\\f' )", 999, +( 999+'\f' ) ); - array[item++] = new TestCase( SECTION, "+( '\\n' + 999 + '\\n' )", 999, +( '\n' +999+'\n' ) ); - array[item++] = new TestCase( SECTION, "+( '\\r' + 999 + '\\r' )", 999, +( '\r' +999+'\r' ) ); - array[item++] = new TestCase( SECTION, "+( '\\t' + 999 + '\\t' )", 999, +( '\t' +999+'\t' ) ); - array[item++] = new TestCase( SECTION, "+( '\\f' + 999 + '\\f' )", 999, +( '\f' +999+'\f' ) ); +new TestCase( SECTION, "+( '\\n' + 999 + '\\n' )", 999, +( '\n' +999+'\n' ) ); +new TestCase( SECTION, "+( '\\r' + 999 + '\\r' )", 999, +( '\r' +999+'\r' ) ); +new TestCase( SECTION, "+( '\\t' + 999 + '\\t' )", 999, +( '\t' +999+'\t' ) ); +new TestCase( SECTION, "+( '\\f' + 999 + '\\f' )", 999, +( '\f' +999+'\f' ) ); - array[item++] = new TestCase( SECTION, "+( ' ' + '999' )", 999, +( ' '+'999') ); - array[item++] = new TestCase( SECTION, "+( '\\n' + '999' )", 999, +( '\n' +'999') ); - array[item++] = new TestCase( SECTION, "+( '\\r' + '999' )", 999, +( '\r' +'999') ); - array[item++] = new TestCase( SECTION, "+( '\\t' + '999' )", 999, +( '\t' +'999') ); - array[item++] = new TestCase( SECTION, "+( '\\f' + '999' )", 999, +( '\f' +'999') ); +new TestCase( SECTION, "+( ' ' + '999' )", 999, +( ' '+'999') ); +new TestCase( SECTION, "+( '\\n' + '999' )", 999, +( '\n' +'999') ); +new TestCase( SECTION, "+( '\\r' + '999' )", 999, +( '\r' +'999') ); +new TestCase( SECTION, "+( '\\t' + '999' )", 999, +( '\t' +'999') ); +new TestCase( SECTION, "+( '\\f' + '999' )", 999, +( '\f' +'999') ); - array[item++] = new TestCase( SECTION, "+( '999' + ' ' )", 999, +( '999'+' ') ); - array[item++] = new TestCase( SECTION, "+( '999' + '\\n' )", 999, +( '999'+'\n' ) ); - array[item++] = new TestCase( SECTION, "+( '999' + '\\r' )", 999, +( '999'+'\r' ) ); - array[item++] = new TestCase( SECTION, "+( '999' + '\\t' )", 999, +( '999'+'\t' ) ); - array[item++] = new TestCase( SECTION, "+( '999' + '\\f' )", 999, +( '999'+'\f' ) ); +new TestCase( SECTION, "+( '999' + ' ' )", 999, +( '999'+' ') ); +new TestCase( SECTION, "+( '999' + '\\n' )", 999, +( '999'+'\n' ) ); +new TestCase( SECTION, "+( '999' + '\\r' )", 999, +( '999'+'\r' ) ); +new TestCase( SECTION, "+( '999' + '\\t' )", 999, +( '999'+'\t' ) ); +new TestCase( SECTION, "+( '999' + '\\f' )", 999, +( '999'+'\f' ) ); - array[item++] = new TestCase( SECTION, "+( '\\n' + '999' + '\\n' )", 999, +( '\n' +'999'+'\n' ) ); - array[item++] = new TestCase( SECTION, "+( '\\r' + '999' + '\\r' )", 999, +( '\r' +'999'+'\r' ) ); - array[item++] = new TestCase( SECTION, "+( '\\t' + '999' + '\\t' )", 999, +( '\t' +'999'+'\t' ) ); - array[item++] = new TestCase( SECTION, "+( '\\f' + '999' + '\\f' )", 999, +( '\f' +'999'+'\f' ) ); +new TestCase( SECTION, "+( '\\n' + '999' + '\\n' )", 999, +( '\n' +'999'+'\n' ) ); +new TestCase( SECTION, "+( '\\r' + '999' + '\\r' )", 999, +( '\r' +'999'+'\r' ) ); +new TestCase( SECTION, "+( '\\t' + '999' + '\\t' )", 999, +( '\t' +'999'+'\t' ) ); +new TestCase( SECTION, "+( '\\f' + '999' + '\\f' )", 999, +( '\f' +'999'+'\f' ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' )", 99, +( String.fromCharCode(0x0009) + '99' ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' )", 99, +( String.fromCharCode(0x0020) + '99' ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' )", 99, +( String.fromCharCode(0x000C) + '99' ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' )", 99, +( String.fromCharCode(0x000B) + '99' ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' )", 99, +( String.fromCharCode(0x000D) + '99' ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' )", 99, +( String.fromCharCode(0x000A) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' )", 99, +( String.fromCharCode(0x0009) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' )", 99, +( String.fromCharCode(0x0020) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' )", 99, +( String.fromCharCode(0x000C) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' )", 99, +( String.fromCharCode(0x000B) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' )", 99, +( String.fromCharCode(0x000D) + '99' ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' )", 99, +( String.fromCharCode(0x000A) + '99' ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); - array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0009)", 99, +( '99' + String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0020)", 99, +( '99' + String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000C)", 99, +( '99' + String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000D)", 99, +( '99' + String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000B)", 99, +( '99' + String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000A)", 99, +( '99' + String.fromCharCode(0x000A)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0009)", 99, +( '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x0020)", 99, +( '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000C)", 99, +( '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000D)", 99, +( '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000B)", 99, +( '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+( '99' + String.fromCharCode(0x000A)", 99, +( '99' + String.fromCharCode(0x000A)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 )", 99, +( String.fromCharCode(0x0009) + 99 ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 )", 99, +( String.fromCharCode(0x0020) + 99 ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 )", 99, +( String.fromCharCode(0x000C) + 99 ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 )", 99, +( String.fromCharCode(0x000B) + 99 ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 )", 99, +( String.fromCharCode(0x000D) + 99 ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 )", 99, +( String.fromCharCode(0x000A) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 )", 99, +( String.fromCharCode(0x0009) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 )", 99, +( String.fromCharCode(0x0020) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 )", 99, +( String.fromCharCode(0x000C) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 )", 99, +( String.fromCharCode(0x000B) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 )", 99, +( String.fromCharCode(0x000D) + 99 ) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 )", 99, +( String.fromCharCode(0x000A) + 99 ) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, +( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); - array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0009)", 99, +( 99 + String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0020)", 99, +( 99 + String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000C)", 99, +( 99 + String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000D)", 99, +( 99 + String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000B)", 99, +( 99 + String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000A)", 99, +( 99 + String.fromCharCode(0x000A)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0009)", 99, +( 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x0020)", 99, +( 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000C)", 99, +( 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000D)", 99, +( 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000B)", 99, +( 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "+( 99 + String.fromCharCode(0x000A)", 99, +( 99 + String.fromCharCode(0x000A)) ); - // StrNumericLiteral:::StrDecimalLiteral:::Infinity +// StrNumericLiteral:::StrDecimalLiteral:::Infinity - array[item++] = new TestCase( SECTION, "+('Infinity')", Math.pow(10,10000), +("Infinity") ); - array[item++] = new TestCase( SECTION, "+('-Infinity')", -Math.pow(10,10000), +("-Infinity") ); - array[item++] = new TestCase( SECTION, "+('+Infinity')", Math.pow(10,10000), +("+Infinity") ); +new TestCase( SECTION, "+('Infinity')", Math.pow(10,10000), +("Infinity") ); +new TestCase( SECTION, "+('-Infinity')", -Math.pow(10,10000), +("-Infinity") ); +new TestCase( SECTION, "+('+Infinity')", Math.pow(10,10000), +("+Infinity") ); - // StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt +// StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt - array[item++] = new TestCase( SECTION, "+('0')", 0, +("0") ); - array[item++] = new TestCase( SECTION, "+('-0')", -0, +("-0") ); - array[item++] = new TestCase( SECTION, "+('+0')", 0, +("+0") ); +new TestCase( SECTION, "+('0')", 0, +("0") ); +new TestCase( SECTION, "+('-0')", -0, +("-0") ); +new TestCase( SECTION, "+('+0')", 0, +("+0") ); - array[item++] = new TestCase( SECTION, "+('1')", 1, +("1") ); - array[item++] = new TestCase( SECTION, "+('-1')", -1, +("-1") ); - array[item++] = new TestCase( SECTION, "+('+1')", 1, +("+1") ); +new TestCase( SECTION, "+('1')", 1, +("1") ); +new TestCase( SECTION, "+('-1')", -1, +("-1") ); +new TestCase( SECTION, "+('+1')", 1, +("+1") ); - array[item++] = new TestCase( SECTION, "+('2')", 2, +("2") ); - array[item++] = new TestCase( SECTION, "+('-2')", -2, +("-2") ); - array[item++] = new TestCase( SECTION, "+('+2')", 2, +("+2") ); +new TestCase( SECTION, "+('2')", 2, +("2") ); +new TestCase( SECTION, "+('-2')", -2, +("-2") ); +new TestCase( SECTION, "+('+2')", 2, +("+2") ); - array[item++] = new TestCase( SECTION, "+('3')", 3, +("3") ); - array[item++] = new TestCase( SECTION, "+('-3')", -3, +("-3") ); - array[item++] = new TestCase( SECTION, "+('+3')", 3, +("+3") ); +new TestCase( SECTION, "+('3')", 3, +("3") ); +new TestCase( SECTION, "+('-3')", -3, +("-3") ); +new TestCase( SECTION, "+('+3')", 3, +("+3") ); - array[item++] = new TestCase( SECTION, "+('4')", 4, +("4") ); - array[item++] = new TestCase( SECTION, "+('-4')", -4, +("-4") ); - array[item++] = new TestCase( SECTION, "+('+4')", 4, +("+4") ); +new TestCase( SECTION, "+('4')", 4, +("4") ); +new TestCase( SECTION, "+('-4')", -4, +("-4") ); +new TestCase( SECTION, "+('+4')", 4, +("+4") ); - array[item++] = new TestCase( SECTION, "+('5')", 5, +("5") ); - array[item++] = new TestCase( SECTION, "+('-5')", -5, +("-5") ); - array[item++] = new TestCase( SECTION, "+('+5')", 5, +("+5") ); +new TestCase( SECTION, "+('5')", 5, +("5") ); +new TestCase( SECTION, "+('-5')", -5, +("-5") ); +new TestCase( SECTION, "+('+5')", 5, +("+5") ); - array[item++] = new TestCase( SECTION, "+('6')", 6, +("6") ); - array[item++] = new TestCase( SECTION, "+('-6')", -6, +("-6") ); - array[item++] = new TestCase( SECTION, "+('+6')", 6, +("+6") ); +new TestCase( SECTION, "+('6')", 6, +("6") ); +new TestCase( SECTION, "+('-6')", -6, +("-6") ); +new TestCase( SECTION, "+('+6')", 6, +("+6") ); - array[item++] = new TestCase( SECTION, "+('7')", 7, +("7") ); - array[item++] = new TestCase( SECTION, "+('-7')", -7, +("-7") ); - array[item++] = new TestCase( SECTION, "+('+7')", 7, +("+7") ); +new TestCase( SECTION, "+('7')", 7, +("7") ); +new TestCase( SECTION, "+('-7')", -7, +("-7") ); +new TestCase( SECTION, "+('+7')", 7, +("+7") ); - array[item++] = new TestCase( SECTION, "+('8')", 8, +("8") ); - array[item++] = new TestCase( SECTION, "+('-8')", -8, +("-8") ); - array[item++] = new TestCase( SECTION, "+('+8')", 8, +("+8") ); +new TestCase( SECTION, "+('8')", 8, +("8") ); +new TestCase( SECTION, "+('-8')", -8, +("-8") ); +new TestCase( SECTION, "+('+8')", 8, +("+8") ); - array[item++] = new TestCase( SECTION, "+('9')", 9, +("9") ); - array[item++] = new TestCase( SECTION, "+('-9')", -9, +("-9") ); - array[item++] = new TestCase( SECTION, "+('+9')", 9, +("+9") ); +new TestCase( SECTION, "+('9')", 9, +("9") ); +new TestCase( SECTION, "+('-9')", -9, +("-9") ); +new TestCase( SECTION, "+('+9')", 9, +("+9") ); - array[item++] = new TestCase( SECTION, "+('3.14159')", 3.14159, +("3.14159") ); - array[item++] = new TestCase( SECTION, "+('-3.14159')", -3.14159, +("-3.14159") ); - array[item++] = new TestCase( SECTION, "+('+3.14159')", 3.14159, +("+3.14159") ); +new TestCase( SECTION, "+('3.14159')", 3.14159, +("3.14159") ); +new TestCase( SECTION, "+('-3.14159')", -3.14159, +("-3.14159") ); +new TestCase( SECTION, "+('+3.14159')", 3.14159, +("+3.14159") ); - array[item++] = new TestCase( SECTION, "+('3.')", 3, +("3.") ); - array[item++] = new TestCase( SECTION, "+('-3.')", -3, +("-3.") ); - array[item++] = new TestCase( SECTION, "+('+3.')", 3, +("+3.") ); +new TestCase( SECTION, "+('3.')", 3, +("3.") ); +new TestCase( SECTION, "+('-3.')", -3, +("-3.") ); +new TestCase( SECTION, "+('+3.')", 3, +("+3.") ); - array[item++] = new TestCase( SECTION, "+('3.e1')", 30, +("3.e1") ); - array[item++] = new TestCase( SECTION, "+('-3.e1')", -30, +("-3.e1") ); - array[item++] = new TestCase( SECTION, "+('+3.e1')", 30, +("+3.e1") ); +new TestCase( SECTION, "+('3.e1')", 30, +("3.e1") ); +new TestCase( SECTION, "+('-3.e1')", -30, +("-3.e1") ); +new TestCase( SECTION, "+('+3.e1')", 30, +("+3.e1") ); - array[item++] = new TestCase( SECTION, "+('3.e+1')", 30, +("3.e+1") ); - array[item++] = new TestCase( SECTION, "+('-3.e+1')", -30, +("-3.e+1") ); - array[item++] = new TestCase( SECTION, "+('+3.e+1')", 30, +("+3.e+1") ); +new TestCase( SECTION, "+('3.e+1')", 30, +("3.e+1") ); +new TestCase( SECTION, "+('-3.e+1')", -30, +("-3.e+1") ); +new TestCase( SECTION, "+('+3.e+1')", 30, +("+3.e+1") ); - array[item++] = new TestCase( SECTION, "+('3.e-1')", .30, +("3.e-1") ); - array[item++] = new TestCase( SECTION, "+('-3.e-1')", -.30, +("-3.e-1") ); - array[item++] = new TestCase( SECTION, "+('+3.e-1')", .30, +("+3.e-1") ); +new TestCase( SECTION, "+('3.e-1')", .30, +("3.e-1") ); +new TestCase( SECTION, "+('-3.e-1')", -.30, +("-3.e-1") ); +new TestCase( SECTION, "+('+3.e-1')", .30, +("+3.e-1") ); - // StrDecimalLiteral::: .DecimalDigits ExponentPart opt +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt - array[item++] = new TestCase( SECTION, "+('.00001')", 0.00001, +(".00001") ); - array[item++] = new TestCase( SECTION, "+('+.00001')", 0.00001, +("+.00001") ); - array[item++] = new TestCase( SECTION, "+('-0.0001')", -0.00001, +("-.00001") ); +new TestCase( SECTION, "+('.00001')", 0.00001, +(".00001") ); +new TestCase( SECTION, "+('+.00001')", 0.00001, +("+.00001") ); +new TestCase( SECTION, "+('-0.0001')", -0.00001, +("-.00001") ); - array[item++] = new TestCase( SECTION, "+('.01e2')", 1, +(".01e2") ); - array[item++] = new TestCase( SECTION, "+('+.01e2')", 1, +("+.01e2") ); - array[item++] = new TestCase( SECTION, "+('-.01e2')", -1, +("-.01e2") ); +new TestCase( SECTION, "+('.01e2')", 1, +(".01e2") ); +new TestCase( SECTION, "+('+.01e2')", 1, +("+.01e2") ); +new TestCase( SECTION, "+('-.01e2')", -1, +("-.01e2") ); - array[item++] = new TestCase( SECTION, "+('.01e+2')", 1, +(".01e+2") ); - array[item++] = new TestCase( SECTION, "+('+.01e+2')", 1, +("+.01e+2") ); - array[item++] = new TestCase( SECTION, "+('-.01e+2')", -1, +("-.01e+2") ); +new TestCase( SECTION, "+('.01e+2')", 1, +(".01e+2") ); +new TestCase( SECTION, "+('+.01e+2')", 1, +("+.01e+2") ); +new TestCase( SECTION, "+('-.01e+2')", -1, +("-.01e+2") ); - array[item++] = new TestCase( SECTION, "+('.01e-2')", 0.0001, +(".01e-2") ); - array[item++] = new TestCase( SECTION, "+('+.01e-2')", 0.0001, +("+.01e-2") ); - array[item++] = new TestCase( SECTION, "+('-.01e-2')", -0.0001, +("-.01e-2") ); +new TestCase( SECTION, "+('.01e-2')", 0.0001, +(".01e-2") ); +new TestCase( SECTION, "+('+.01e-2')", 0.0001, +("+.01e-2") ); +new TestCase( SECTION, "+('-.01e-2')", -0.0001, +("-.01e-2") ); - // StrDecimalLiteral::: DecimalDigits ExponentPart opt +// StrDecimalLiteral::: DecimalDigits ExponentPart opt - array[item++] = new TestCase( SECTION, "+('1234e5')", 123400000, +("1234e5") ); - array[item++] = new TestCase( SECTION, "+('+1234e5')", 123400000, +("+1234e5") ); - array[item++] = new TestCase( SECTION, "+('-1234e5')", -123400000, +("-1234e5") ); +new TestCase( SECTION, "+('1234e5')", 123400000, +("1234e5") ); +new TestCase( SECTION, "+('+1234e5')", 123400000, +("+1234e5") ); +new TestCase( SECTION, "+('-1234e5')", -123400000, +("-1234e5") ); - array[item++] = new TestCase( SECTION, "+('1234e+5')", 123400000, +("1234e+5") ); - array[item++] = new TestCase( SECTION, "+('+1234e+5')", 123400000, +("+1234e+5") ); - array[item++] = new TestCase( SECTION, "+('-1234e+5')", -123400000, +("-1234e+5") ); +new TestCase( SECTION, "+('1234e+5')", 123400000, +("1234e+5") ); +new TestCase( SECTION, "+('+1234e+5')", 123400000, +("+1234e+5") ); +new TestCase( SECTION, "+('-1234e+5')", -123400000, +("-1234e+5") ); - array[item++] = new TestCase( SECTION, "+('1234e-5')", 0.01234, +("1234e-5") ); - array[item++] = new TestCase( SECTION, "+('+1234e-5')", 0.01234, +("+1234e-5") ); - array[item++] = new TestCase( SECTION, "+('-1234e-5')", -0.01234, +("-1234e-5") ); +new TestCase( SECTION, "+('1234e-5')", 0.01234, +("1234e-5") ); +new TestCase( SECTION, "+('+1234e-5')", 0.01234, +("+1234e-5") ); +new TestCase( SECTION, "+('-1234e-5')", -0.01234, +("-1234e-5") ); - // StrNumericLiteral::: HexIntegerLiteral +// StrNumericLiteral::: HexIntegerLiteral - array[item++] = new TestCase( SECTION, "+('0x0')", 0, +("0x0")); - array[item++] = new TestCase( SECTION, "+('0x1')", 1, +("0x1")); - array[item++] = new TestCase( SECTION, "+('0x2')", 2, +("0x2")); - array[item++] = new TestCase( SECTION, "+('0x3')", 3, +("0x3")); - array[item++] = new TestCase( SECTION, "+('0x4')", 4, +("0x4")); - array[item++] = new TestCase( SECTION, "+('0x5')", 5, +("0x5")); - array[item++] = new TestCase( SECTION, "+('0x6')", 6, +("0x6")); - array[item++] = new TestCase( SECTION, "+('0x7')", 7, +("0x7")); - array[item++] = new TestCase( SECTION, "+('0x8')", 8, +("0x8")); - array[item++] = new TestCase( SECTION, "+('0x9')", 9, +("0x9")); - array[item++] = new TestCase( SECTION, "+('0xa')", 10, +("0xa")); - array[item++] = new TestCase( SECTION, "+('0xb')", 11, +("0xb")); - array[item++] = new TestCase( SECTION, "+('0xc')", 12, +("0xc")); - array[item++] = new TestCase( SECTION, "+('0xd')", 13, +("0xd")); - array[item++] = new TestCase( SECTION, "+('0xe')", 14, +("0xe")); - array[item++] = new TestCase( SECTION, "+('0xf')", 15, +("0xf")); - array[item++] = new TestCase( SECTION, "+('0xA')", 10, +("0xA")); - array[item++] = new TestCase( SECTION, "+('0xB')", 11, +("0xB")); - array[item++] = new TestCase( SECTION, "+('0xC')", 12, +("0xC")); - array[item++] = new TestCase( SECTION, "+('0xD')", 13, +("0xD")); - array[item++] = new TestCase( SECTION, "+('0xE')", 14, +("0xE")); - array[item++] = new TestCase( SECTION, "+('0xF')", 15, +("0xF")); +new TestCase( SECTION, "+('0x0')", 0, +("0x0")); +new TestCase( SECTION, "+('0x1')", 1, +("0x1")); +new TestCase( SECTION, "+('0x2')", 2, +("0x2")); +new TestCase( SECTION, "+('0x3')", 3, +("0x3")); +new TestCase( SECTION, "+('0x4')", 4, +("0x4")); +new TestCase( SECTION, "+('0x5')", 5, +("0x5")); +new TestCase( SECTION, "+('0x6')", 6, +("0x6")); +new TestCase( SECTION, "+('0x7')", 7, +("0x7")); +new TestCase( SECTION, "+('0x8')", 8, +("0x8")); +new TestCase( SECTION, "+('0x9')", 9, +("0x9")); +new TestCase( SECTION, "+('0xa')", 10, +("0xa")); +new TestCase( SECTION, "+('0xb')", 11, +("0xb")); +new TestCase( SECTION, "+('0xc')", 12, +("0xc")); +new TestCase( SECTION, "+('0xd')", 13, +("0xd")); +new TestCase( SECTION, "+('0xe')", 14, +("0xe")); +new TestCase( SECTION, "+('0xf')", 15, +("0xf")); +new TestCase( SECTION, "+('0xA')", 10, +("0xA")); +new TestCase( SECTION, "+('0xB')", 11, +("0xB")); +new TestCase( SECTION, "+('0xC')", 12, +("0xC")); +new TestCase( SECTION, "+('0xD')", 13, +("0xD")); +new TestCase( SECTION, "+('0xE')", 14, +("0xE")); +new TestCase( SECTION, "+('0xF')", 15, +("0xF")); - array[item++] = new TestCase( SECTION, "+('0X0')", 0, +("0X0")); - array[item++] = new TestCase( SECTION, "+('0X1')", 1, +("0X1")); - array[item++] = new TestCase( SECTION, "+('0X2')", 2, +("0X2")); - array[item++] = new TestCase( SECTION, "+('0X3')", 3, +("0X3")); - array[item++] = new TestCase( SECTION, "+('0X4')", 4, +("0X4")); - array[item++] = new TestCase( SECTION, "+('0X5')", 5, +("0X5")); - array[item++] = new TestCase( SECTION, "+('0X6')", 6, +("0X6")); - array[item++] = new TestCase( SECTION, "+('0X7')", 7, +("0X7")); - array[item++] = new TestCase( SECTION, "+('0X8')", 8, +("0X8")); - array[item++] = new TestCase( SECTION, "+('0X9')", 9, +("0X9")); - array[item++] = new TestCase( SECTION, "+('0Xa')", 10, +("0Xa")); - array[item++] = new TestCase( SECTION, "+('0Xb')", 11, +("0Xb")); - array[item++] = new TestCase( SECTION, "+('0Xc')", 12, +("0Xc")); - array[item++] = new TestCase( SECTION, "+('0Xd')", 13, +("0Xd")); - array[item++] = new TestCase( SECTION, "+('0Xe')", 14, +("0Xe")); - array[item++] = new TestCase( SECTION, "+('0Xf')", 15, +("0Xf")); - array[item++] = new TestCase( SECTION, "+('0XA')", 10, +("0XA")); - array[item++] = new TestCase( SECTION, "+('0XB')", 11, +("0XB")); - array[item++] = new TestCase( SECTION, "+('0XC')", 12, +("0XC")); - array[item++] = new TestCase( SECTION, "+('0XD')", 13, +("0XD")); - array[item++] = new TestCase( SECTION, "+('0XE')", 14, +("0XE")); - array[item++] = new TestCase( SECTION, "+('0XF')", 15, +("0XF")); +new TestCase( SECTION, "+('0X0')", 0, +("0X0")); +new TestCase( SECTION, "+('0X1')", 1, +("0X1")); +new TestCase( SECTION, "+('0X2')", 2, +("0X2")); +new TestCase( SECTION, "+('0X3')", 3, +("0X3")); +new TestCase( SECTION, "+('0X4')", 4, +("0X4")); +new TestCase( SECTION, "+('0X5')", 5, +("0X5")); +new TestCase( SECTION, "+('0X6')", 6, +("0X6")); +new TestCase( SECTION, "+('0X7')", 7, +("0X7")); +new TestCase( SECTION, "+('0X8')", 8, +("0X8")); +new TestCase( SECTION, "+('0X9')", 9, +("0X9")); +new TestCase( SECTION, "+('0Xa')", 10, +("0Xa")); +new TestCase( SECTION, "+('0Xb')", 11, +("0Xb")); +new TestCase( SECTION, "+('0Xc')", 12, +("0Xc")); +new TestCase( SECTION, "+('0Xd')", 13, +("0Xd")); +new TestCase( SECTION, "+('0Xe')", 14, +("0Xe")); +new TestCase( SECTION, "+('0Xf')", 15, +("0Xf")); +new TestCase( SECTION, "+('0XA')", 10, +("0XA")); +new TestCase( SECTION, "+('0XB')", 11, +("0XB")); +new TestCase( SECTION, "+('0XC')", 12, +("0XC")); +new TestCase( SECTION, "+('0XD')", 13, +("0XD")); +new TestCase( SECTION, "+('0XE')", 14, +("0XE")); +new TestCase( SECTION, "+('0XF')", 15, +("0XF")); - return array; - -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.4.8.js b/mozilla/js/tests/ecma/Expressions/11.4.8.js index 75fdcb86439..3aed5d45eb0 100644 --- a/mozilla/js/tests/ecma/Expressions/11.4.8.js +++ b/mozilla/js/tests/ecma/Expressions/11.4.8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,197 +35,178 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ - /** - File Name: 11.4.8.js - ECMA Section: 11.4.8 Bitwise NOT Operator - Description: flip bits up to 32 bits - no special cases - Author: christine@netscape.com - Date: 7 july 1997 +/** + File Name: 11.4.8.js + ECMA Section: 11.4.8 Bitwise NOT Operator + Description: flip bits up to 32 bits + no special cases + Author: christine@netscape.com + Date: 7 july 1997 - Data File Fields: - VALUE value passed as an argument to the ~ operator - E_RESULT expected return value of ~ VALUE; + Data File Fields: + VALUE value passed as an argument to the ~ operator + E_RESULT expected return value of ~ VALUE; - Static variables: - none + Static variables: + none */ - var SECTION = "11.4.8"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.4.8"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Bitwise Not operator"); - test(); +writeHeaderToLog( SECTION + " Bitwise Not operator"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +for ( var i = 0; i < 35; i++ ) { + var p = Math.pow(2,i); + + new TestCase( SECTION, "~"+p, Not(p), ~p ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); } -function getTestCases() { - var array = new Array(); - var item = 0; +for ( i = 0; i < 35; i++ ) { + var p = -Math.pow(2,i); - for ( var i = 0; i < 35; i++ ) { - var p = Math.pow(2,i); + new TestCase( SECTION, "~"+p, Not(p), ~p ); - array[item++] = new TestCase( SECTION, "~"+p, Not(p), ~p ); - - } - for ( i = 0; i < 35; i++ ) { - var p = -Math.pow(2,i); - - array[item++] = new TestCase( SECTION, "~"+p, Not(p), ~p ); - - } - - return ( array ); } + +test(); + function ToInteger( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( n != n ) { - return 0; - } - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { - return n; - } - return ( sign * Math.floor(Math.abs(n)) ); + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); } function ToInt32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); - n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; - return ( n ); + return ( n ); } function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); + return ( n ); } function ToUint16( n ) { - var sign = ( n < 0 ) ? -1 : 1; + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); - if (n <0) { - n += Math.pow(2,16); - } + if (n <0) { + n += Math.pow(2,16); + } - return ( n ); + return ( n ); } function Mask( b, n ) { - b = ToUint32BitString( b ); - b = b.substring( b.length - n ); - b = ToUint32Decimal( b ); - return ( b ); + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); } function ToUint32BitString( n ) { - var b = ""; - for ( p = 31; p >=0; p-- ) { - if ( n >= Math.pow(2,p) ) { - b += "1"; - n -= Math.pow(2,p); - } else { - b += "0"; - } + var b = ""; + for ( var p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; } - return b; + } + return b; } function ToInt32BitString( n ) { - var b = ""; - var sign = ( n < 0 ) ? -1 : 1; + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; - b += ( sign == 1 ) ? "0" : "1"; + b += ( sign == 1 ) ? "0" : "1"; - for ( p = 30; p >=0; p-- ) { - if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { - b += ( sign == 1 ) ? "1" : "0"; - n -= sign * Math.pow( 2, p ); - } else { - b += ( sign == 1 ) ? "0" : "1"; - } + for ( var p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; } + } - return b; + return b; } function ToInt32Decimal( bin ) { - var r = 0; - var sign; + var r = 0; + var sign; - if ( Number(bin.charAt(0)) == 0 ) { - sign = 1; - r = 0; - } else { - sign = -1; - r = -(Math.pow(2,31)); - } + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } - for ( var j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } - return r; + return r; } function ToUint32Decimal( bin ) { - var r = 0; + var r = 0; - for ( l = bin.length; l < 32; l++ ) { - bin = "0" + bin; - } + for ( var l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } - for ( j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } - return r; + return r; } function Not( n ) { - n = ToInt32(n); - n = ToInt32BitString(n); + n = ToInt32(n); + n = ToInt32BitString(n); - r = "" + var r = ""; - for( var l = 0; l < n.length; l++ ) { - r += ( n.charAt(l) == "0" ) ? "1" : "0"; - } + for( var l = 0; l < n.length; l++ ) { + r += ( n.charAt(l) == "0" ) ? "1" : "0"; + } - n = ToInt32Decimal(r); + n = ToInt32Decimal(r); - return n; -} \ No newline at end of file + return n; +} diff --git a/mozilla/js/tests/ecma/Expressions/11.4.9.js b/mozilla/js/tests/ecma/Expressions/11.4.9.js index 609a8fb934f..e680c10c922 100644 --- a/mozilla/js/tests/ecma/Expressions/11.4.9.js +++ b/mozilla/js/tests/ecma/Expressions/11.4.9.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,58 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.4.9.js - ECMA Section: 11.4.9 Logical NOT Operator (!) - Description: if the ToBoolean( VALUE ) result is true, return - true. else return false. - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 11.4.9.js + ECMA Section: 11.4.9 Logical NOT Operator (!) + Description: if the ToBoolean( VALUE ) result is true, return + true. else return false. + Author: christine@netscape.com + Date: 7 july 1997 - Static variables: - none + Static variables: + none */ - var SECTION = "11.4.9"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Logical NOT operator (!)"; +var SECTION = "11.4.9"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Logical NOT operator (!)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); // version("130") - var testcases = new Array(); - testcases[tc++] = new TestCase( SECTION, "!(null)", true, !(null) ); - testcases[tc++] = new TestCase( SECTION, "!(var x)", true, !(eval("var x")) ); - testcases[tc++] = new TestCase( SECTION, "!(void 0)", true, !(void 0) ); +new TestCase( SECTION, "!(null)", true, !(null) ); +new TestCase( SECTION, "!(var x)", true, !(eval("var x")) ); +new TestCase( SECTION, "!(void 0)", true, !(void 0) ); - testcases[tc++] = new TestCase( SECTION, "!(false)", true, !(false) ); - testcases[tc++] = new TestCase( SECTION, "!(true)", false, !(true) ); - testcases[tc++] = new TestCase( SECTION, "!()", true, !(eval()) ); - testcases[tc++] = new TestCase( SECTION, "!(0)", true, !(0) ); - testcases[tc++] = new TestCase( SECTION, "!(-0)", true, !(-0) ); - testcases[tc++] = new TestCase( SECTION, "!(NaN)", true, !(Number.NaN) ); - testcases[tc++] = new TestCase( SECTION, "!(Infinity)", false, !(Number.POSITIVE_INFINITY) ); - testcases[tc++] = new TestCase( SECTION, "!(-Infinity)", false, !(Number.NEGATIVE_INFINITY) ); - testcases[tc++] = new TestCase( SECTION, "!(Math.PI)", false, !(Math.PI) ); - testcases[tc++] = new TestCase( SECTION, "!(1)", false, !(1) ); - testcases[tc++] = new TestCase( SECTION, "!(-1)", false, !(-1) ); - testcases[tc++] = new TestCase( SECTION, "!('')", true, !("") ); - testcases[tc++] = new TestCase( SECTION, "!('\t')", false, !("\t") ); - testcases[tc++] = new TestCase( SECTION, "!('0')", false, !("0") ); - testcases[tc++] = new TestCase( SECTION, "!('string')", false, !("string") ); - testcases[tc++] = new TestCase( SECTION, "!(new String(''))", false, !(new String("")) ); - testcases[tc++] = new TestCase( SECTION, "!(new String('string'))", false, !(new String("string")) ); - testcases[tc++] = new TestCase( SECTION, "!(new String())", false, !(new String()) ); - testcases[tc++] = new TestCase( SECTION, "!(new Boolean(true))", false, !(new Boolean(true)) ); - testcases[tc++] = new TestCase( SECTION, "!(new Boolean(false))", false, !(new Boolean(false)) ); - testcases[tc++] = new TestCase( SECTION, "!(new Array())", false, !(new Array()) ); - testcases[tc++] = new TestCase( SECTION, "!(new Array(1,2,3)", false, !(new Array(1,2,3)) ); - testcases[tc++] = new TestCase( SECTION, "!(new Number())", false, !(new Number()) ); - testcases[tc++] = new TestCase( SECTION, "!(new Number(0))", false, !(new Number(0)) ); - testcases[tc++] = new TestCase( SECTION, "!(new Number(NaN))", false, !(new Number(Number.NaN)) ); - testcases[tc++] = new TestCase( SECTION, "!(new Number(Infinity))", false, !(new Number(Number.POSITIVE_INFINITY)) ); +new TestCase( SECTION, "!(false)", true, !(false) ); +new TestCase( SECTION, "!(true)", false, !(true) ); +new TestCase( SECTION, "!()", true, !(eval()) ); +new TestCase( SECTION, "!(0)", true, !(0) ); +new TestCase( SECTION, "!(-0)", true, !(-0) ); +new TestCase( SECTION, "!(NaN)", true, !(Number.NaN) ); +new TestCase( SECTION, "!(Infinity)", false, !(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "!(-Infinity)", false, !(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "!(Math.PI)", false, !(Math.PI) ); +new TestCase( SECTION, "!(1)", false, !(1) ); +new TestCase( SECTION, "!(-1)", false, !(-1) ); +new TestCase( SECTION, "!('')", true, !("") ); +new TestCase( SECTION, "!('\t')", false, !("\t") ); +new TestCase( SECTION, "!('0')", false, !("0") ); +new TestCase( SECTION, "!('string')", false, !("string") ); +new TestCase( SECTION, "!(new String(''))", false, !(new String("")) ); +new TestCase( SECTION, "!(new String('string'))", false, !(new String("string")) ); +new TestCase( SECTION, "!(new String())", false, !(new String()) ); +new TestCase( SECTION, "!(new Boolean(true))", false, !(new Boolean(true)) ); +new TestCase( SECTION, "!(new Boolean(false))", false, !(new Boolean(false)) ); +new TestCase( SECTION, "!(new Array())", false, !(new Array()) ); +new TestCase( SECTION, "!(new Array(1,2,3)", false, !(new Array(1,2,3)) ); +new TestCase( SECTION, "!(new Number())", false, !(new Number()) ); +new TestCase( SECTION, "!(new Number(0))", false, !(new Number(0)) ); +new TestCase( SECTION, "!(new Number(NaN))", false, !(new Number(Number.NaN)) ); +new TestCase( SECTION, "!(new Number(Infinity))", false, !(new Number(Number.POSITIVE_INFINITY)) ); - test(); +test(); -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - - // all tests must return a boolean value - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.5.1.js b/mozilla/js/tests/ecma/Expressions/11.5.1.js index 6441721b018..abdd3e4ccf2 100644 --- a/mozilla/js/tests/ecma/Expressions/11.5.1.js +++ b/mozilla/js/tests/ecma/Expressions/11.5.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,97 +35,79 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.5.1.js - ECMA Section: 11.5.1 Applying the * operator - Description: + File Name: 11.5.1.js + ECMA Section: 11.5.1 Applying the * operator + Description: - 11.5.1 Applying the * operator + 11.5.1 Applying the * operator - The * operator performs multiplication, producing the product of its - operands. Multiplication is commutative. Multiplication is not always - associative in ECMAScript, because of finite precision. + The * operator performs multiplication, producing the product of its + operands. Multiplication is commutative. Multiplication is not always + associative in ECMAScript, because of finite precision. - The result of a floating-point multiplication is governed by the rules - of IEEE 754 double-precision arithmetic: + The result of a floating-point multiplication is governed by the rules + of IEEE 754 double-precision arithmetic: - If either operand is NaN, the result is NaN. - The sign of the result is positive if both operands have the same sign, - negative if the operands have different signs. - Multiplication of an infinity by a zero results in NaN. - Multiplication of an infinity by an infinity results in an infinity. - The sign is determined by the rule already stated above. - Multiplication of an infinity by a finite non-zero value results in a - signed infinity. The sign is determined by the rule already stated above. - In the remaining cases, where neither an infinity or NaN is involved, the - product is computed and rounded to the nearest representable value using IEEE - 754 round-to-nearest mode. If the magnitude is too large to represent, - the result is then an infinity of appropriate sign. If the magnitude is - oo small to represent, the result is then a zero - of appropriate sign. The ECMAScript language requires support of gradual - underflow as defined by IEEE 754. + If either operand is NaN, the result is NaN. + The sign of the result is positive if both operands have the same sign, + negative if the operands have different signs. + Multiplication of an infinity by a zero results in NaN. + Multiplication of an infinity by an infinity results in an infinity. + The sign is determined by the rule already stated above. + Multiplication of an infinity by a finite non-zero value results in a + signed infinity. The sign is determined by the rule already stated above. + In the remaining cases, where neither an infinity or NaN is involved, the + product is computed and rounded to the nearest representable value using IEEE + 754 round-to-nearest mode. If the magnitude is too large to represent, + the result is then an infinity of appropriate sign. If the magnitude is + oo small to represent, the result is then a zero + of appropriate sign. The ECMAScript language requires support of gradual + underflow as defined by IEEE 754. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.5.1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.5.1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Applying the * operator"); - test(); +writeHeaderToLog( SECTION + " Applying the * operator"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "Number.NaN * Number.NaN", Number.NaN, Number.NaN * Number.NaN ); +new TestCase( SECTION, "Number.NaN * 1", Number.NaN, Number.NaN * 1 ); +new TestCase( SECTION, "1 * Number.NaN", Number.NaN, 1 * Number.NaN ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Number.POSITIVE_INFINITY * 0", Number.NaN, Number.POSITIVE_INFINITY * 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 0", Number.NaN, Number.NEGATIVE_INFINITY * 0 ); +new TestCase( SECTION, "0 * Number.POSITIVE_INFINITY", Number.NaN, 0 * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 * Number.NEGATIVE_INFINITY", Number.NaN, 0 * Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NaN * Number.NaN", Number.NaN, Number.NaN * Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NaN * 1", Number.NaN, Number.NaN * 1 ); - array[item++] = new TestCase( SECTION, "1 * Number.NaN", Number.NaN, 1 * Number.NaN ); +new TestCase( SECTION, "-0 * Number.POSITIVE_INFINITY", Number.NaN, -0 * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-0 * Number.NEGATIVE_INFINITY", Number.NaN, -0 * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * -0", Number.NaN, Number.POSITIVE_INFINITY * -0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -0", Number.NaN, Number.NEGATIVE_INFINITY * -0 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * 0", Number.NaN, Number.POSITIVE_INFINITY * 0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 0", Number.NaN, Number.NEGATIVE_INFINITY * 0 ); - array[item++] = new TestCase( SECTION, "0 * Number.POSITIVE_INFINITY", Number.NaN, 0 * Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 * Number.NEGATIVE_INFINITY", Number.NaN, 0 * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "0 * -0", -0, 0 * -0 ); +new TestCase( SECTION, "-0 * 0", -0, -0 * 0 ); +new TestCase( SECTION, "-0 * -0", 0, -0 * -0 ); +new TestCase( SECTION, "0 * 0", 0, 0 * 0 ); - array[item++] = new TestCase( SECTION, "-0 * Number.POSITIVE_INFINITY", Number.NaN, -0 * Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-0 * Number.NEGATIVE_INFINITY", Number.NaN, -0 * Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * -0", Number.NaN, Number.POSITIVE_INFINITY * -0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -0", Number.NaN, Number.NEGATIVE_INFINITY * -0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 * -0", -0, 0 * -0 ); - array[item++] = new TestCase( SECTION, "-0 * 0", -0, -0 * 0 ); - array[item++] = new TestCase( SECTION, "-0 * -0", 0, -0 * -0 ); - array[item++] = new TestCase( SECTION, "0 * 0", 0, 0 * 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * 1 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * -1 ); +new TestCase( SECTION, "1 * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, 1 * Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-1 * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, -1 * Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * 1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY * -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * -1 ); +new TestCase( SECTION, "1 * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, 1 * Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, -1 * Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * 1 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * -1 ); - array[item++] = new TestCase( SECTION, "1 * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, 1 * Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-1 * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, -1 * Number.NEGATIVE_INFINITY ); +test(); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * 1 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY * -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * -1 ); - array[item++] = new TestCase( SECTION, "1 * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, 1 * Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-1 * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, -1 * Number.POSITIVE_INFINITY ); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.5.2.js b/mozilla/js/tests/ecma/Expressions/11.5.2.js index 28e5f684da0..8cce29a215f 100644 --- a/mozilla/js/tests/ecma/Expressions/11.5.2.js +++ b/mozilla/js/tests/ecma/Expressions/11.5.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 11.5.2.js ECMA Section: 11.5.2 Applying the / operator @@ -69,101 +71,82 @@ var SECTION = "11.5.2"; var VERSION = "ECMA_1"; startTest(); - var testcases = getTestCases(); var BUGNUMBER="111202"; writeHeaderToLog( SECTION + " Applying the / operator"); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; // if either operand is NaN, the result is NaN. - array[item++] = new TestCase( SECTION, "Number.NaN / Number.NaN", Number.NaN, Number.NaN / Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NaN / 1", Number.NaN, Number.NaN / 1 ); - array[item++] = new TestCase( SECTION, "1 / Number.NaN", Number.NaN, 1 / Number.NaN ); +new TestCase( SECTION, "Number.NaN / Number.NaN", Number.NaN, Number.NaN / Number.NaN ); +new TestCase( SECTION, "Number.NaN / 1", Number.NaN, Number.NaN / 1 ); +new TestCase( SECTION, "1 / Number.NaN", Number.NaN, 1 / Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NaN", Number.NaN, Number.POSITIVE_INFINITY / Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY / Number.NaN ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NaN", Number.NaN, Number.POSITIVE_INFINITY / Number.NaN ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY / Number.NaN ); // Division of an infinity by an infinity results in NaN. - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY ); // Division of an infinity by a zero results in an infinity. - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / 0", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 0", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 0 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -0", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -0", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / 0", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 0", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / -0", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -0", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -0 ); // Division of an infinity by a non-zero finite value results in a signed infinity. - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 1 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -1 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 1 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -1 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 1 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -1 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY / -Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -Number.MAX_VALUE ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / Number.MAX_VALUE ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / Number.MAX_VALUE ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / Number.MAX_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY / -Number.MAX_VALUE ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY / -Number.MAX_VALUE ); // Division of a finite value by an infinity results in zero. - array[item++] = new TestCase( SECTION, "1 / Number.NEGATIVE_INFINITY", -0, 1 / Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "1 / Number.POSITIVE_INFINITY", 0, 1 / Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-1 / Number.POSITIVE_INFINITY", -0, -1 / Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-1 / Number.NEGATIVE_INFINITY", 0, -1 / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "1 / Number.NEGATIVE_INFINITY", -0, 1 / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "1 / Number.POSITIVE_INFINITY", 0, 1 / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 / Number.POSITIVE_INFINITY", -0, -1 / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 / Number.NEGATIVE_INFINITY", 0, -1 / Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE / Number.NEGATIVE_INFINITY", -0, Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE / Number.POSITIVE_INFINITY", 0, Number.MAX_VALUE / Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE / Number.POSITIVE_INFINITY", -0, -Number.MAX_VALUE / Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE / Number.NEGATIVE_INFINITY", 0, -Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE / Number.NEGATIVE_INFINITY", -0, Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE / Number.POSITIVE_INFINITY", 0, Number.MAX_VALUE / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Number.MAX_VALUE / Number.POSITIVE_INFINITY", -0, -Number.MAX_VALUE / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Number.MAX_VALUE / Number.NEGATIVE_INFINITY", 0, -Number.MAX_VALUE / Number.NEGATIVE_INFINITY ); // Division of a zero by a zero results in NaN - array[item++] = new TestCase( SECTION, "0 / -0", Number.NaN, 0 / -0 ); - array[item++] = new TestCase( SECTION, "-0 / 0", Number.NaN, -0 / 0 ); - array[item++] = new TestCase( SECTION, "-0 / -0", Number.NaN, -0 / -0 ); - array[item++] = new TestCase( SECTION, "0 / 0", Number.NaN, 0 / 0 ); +new TestCase( SECTION, "0 / -0", Number.NaN, 0 / -0 ); +new TestCase( SECTION, "-0 / 0", Number.NaN, -0 / 0 ); +new TestCase( SECTION, "-0 / -0", Number.NaN, -0 / -0 ); +new TestCase( SECTION, "0 / 0", Number.NaN, 0 / 0 ); // division of zero by any other finite value results in zero - array[item++] = new TestCase( SECTION, "0 / 1", 0, 0 / 1 ); - array[item++] = new TestCase( SECTION, "0 / -1", -0, 0 / -1 ); - array[item++] = new TestCase( SECTION, "-0 / 1", -0, -0 / 1 ); - array[item++] = new TestCase( SECTION, "-0 / -1", 0, -0 / -1 ); +new TestCase( SECTION, "0 / 1", 0, 0 / 1 ); +new TestCase( SECTION, "0 / -1", -0, 0 / -1 ); +new TestCase( SECTION, "-0 / 1", -0, -0 / 1 ); +new TestCase( SECTION, "-0 / -1", 0, -0 / -1 ); // Division of a non-zero finite value by a zero results in a signed infinity. - array[item++] = new TestCase( SECTION, "1 / 0", Number.POSITIVE_INFINITY, 1/0 ); - array[item++] = new TestCase( SECTION, "1 / -0", Number.NEGATIVE_INFINITY, 1/-0 ); - array[item++] = new TestCase( SECTION, "-1 / 0", Number.NEGATIVE_INFINITY, -1/0 ); - array[item++] = new TestCase( SECTION, "-1 / -0", Number.POSITIVE_INFINITY, -1/-0 ); +new TestCase( SECTION, "1 / 0", Number.POSITIVE_INFINITY, 1/0 ); +new TestCase( SECTION, "1 / -0", Number.NEGATIVE_INFINITY, 1/-0 ); +new TestCase( SECTION, "-1 / 0", Number.NEGATIVE_INFINITY, -1/0 ); +new TestCase( SECTION, "-1 / -0", Number.POSITIVE_INFINITY, -1/-0 ); - array[item++] = new TestCase( SECTION, "0 / Number.POSITIVE_INFINITY", 0, 0 / Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 / Number.NEGATIVE_INFINITY", -0, 0 / Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-0 / Number.POSITIVE_INFINITY", -0, -0 / Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-0 / Number.NEGATIVE_INFINITY", 0, -0 / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "0 / Number.POSITIVE_INFINITY", 0, 0 / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 / Number.NEGATIVE_INFINITY", -0, 0 / Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-0 / Number.POSITIVE_INFINITY", -0, -0 / Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-0 / Number.NEGATIVE_INFINITY", 0, -0 / Number.NEGATIVE_INFINITY ); + +test(); - return ( array ); -} diff --git a/mozilla/js/tests/ecma/Expressions/11.5.3.js b/mozilla/js/tests/ecma/Expressions/11.5.3.js index b3c77bed7f7..111fee90e70 100644 --- a/mozilla/js/tests/ecma/Expressions/11.5.3.js +++ b/mozilla/js/tests/ecma/Expressions/11.5.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 11.5.3.js ECMA Section: 11.5.3 Applying the % operator @@ -71,105 +73,87 @@ var SECTION = "11.5.3"; var VERSION = "ECMA_1"; startTest(); - var testcases = getTestCases(); + var BUGNUMBER="111202"; writeHeaderToLog( SECTION + " Applying the % operator"); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; // if either operand is NaN, the result is NaN. - array[item++] = new TestCase( SECTION, "Number.NaN % Number.NaN", Number.NaN, Number.NaN % Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NaN % 1", Number.NaN, Number.NaN % 1 ); - array[item++] = new TestCase( SECTION, "1 % Number.NaN", Number.NaN, 1 % Number.NaN ); +new TestCase( SECTION, "Number.NaN % Number.NaN", Number.NaN, Number.NaN % Number.NaN ); +new TestCase( SECTION, "Number.NaN % 1", Number.NaN, Number.NaN % 1 ); +new TestCase( SECTION, "1 % Number.NaN", Number.NaN, 1 % Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NaN", Number.NaN, Number.POSITIVE_INFINITY % Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY % Number.NaN ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NaN", Number.NaN, Number.POSITIVE_INFINITY % Number.NaN ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NaN", Number.NaN, Number.NEGATIVE_INFINITY % Number.NaN ); // If the dividend is an infinity, or the divisor is a zero, or both, the result is NaN. // dividend is an infinity - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY % Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % 0", Number.NaN, Number.POSITIVE_INFINITY % 0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 0", Number.NaN, Number.NEGATIVE_INFINITY % 0 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -0", Number.NaN, Number.POSITIVE_INFINITY % -0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -0", Number.NaN, Number.NEGATIVE_INFINITY % -0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % 0", Number.NaN, Number.POSITIVE_INFINITY % 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 0", Number.NaN, Number.NEGATIVE_INFINITY % 0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % -0", Number.NaN, Number.POSITIVE_INFINITY % -0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -0", Number.NaN, Number.NEGATIVE_INFINITY % -0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 1 ", Number.NaN, Number.NEGATIVE_INFINITY % 1 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -1 ", Number.NaN, Number.NEGATIVE_INFINITY % -1 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % 1 ", Number.NaN, Number.POSITIVE_INFINITY % 1 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -1 ", Number.NaN, Number.POSITIVE_INFINITY % -1 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % 1 ", Number.NaN, Number.NEGATIVE_INFINITY % 1 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -1 ", Number.NaN, Number.NEGATIVE_INFINITY % -1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % 1 ", Number.NaN, Number.POSITIVE_INFINITY % 1 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % -1 ", Number.NaN, Number.POSITIVE_INFINITY % -1 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % -Number.MAX_VALUE ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % Number.MAX_VALUE ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.NEGATIVE_INFINITY % -Number.MAX_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % Number.MAX_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY % -Number.MAX_VALUE ", Number.NaN, Number.POSITIVE_INFINITY % -Number.MAX_VALUE ); // divisor is 0 - array[item++] = new TestCase( SECTION, "0 % -0", Number.NaN, 0 % -0 ); - array[item++] = new TestCase( SECTION, "-0 % 0", Number.NaN, -0 % 0 ); - array[item++] = new TestCase( SECTION, "-0 % -0", Number.NaN, -0 % -0 ); - array[item++] = new TestCase( SECTION, "0 % 0", Number.NaN, 0 % 0 ); +new TestCase( SECTION, "0 % -0", Number.NaN, 0 % -0 ); +new TestCase( SECTION, "-0 % 0", Number.NaN, -0 % 0 ); +new TestCase( SECTION, "-0 % -0", Number.NaN, -0 % -0 ); +new TestCase( SECTION, "0 % 0", Number.NaN, 0 % 0 ); - array[item++] = new TestCase( SECTION, "1 % 0", Number.NaN, 1%0 ); - array[item++] = new TestCase( SECTION, "1 % -0", Number.NaN, 1%-0 ); - array[item++] = new TestCase( SECTION, "-1 % 0", Number.NaN, -1%0 ); - array[item++] = new TestCase( SECTION, "-1 % -0", Number.NaN, -1%-0 ); +new TestCase( SECTION, "1 % 0", Number.NaN, 1%0 ); +new TestCase( SECTION, "1 % -0", Number.NaN, 1%-0 ); +new TestCase( SECTION, "-1 % 0", Number.NaN, -1%0 ); +new TestCase( SECTION, "-1 % -0", Number.NaN, -1%-0 ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % 0", Number.NaN, Number.MAX_VALUE%0 ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % -0", Number.NaN, Number.MAX_VALUE%-0 ); - array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % 0", Number.NaN, -Number.MAX_VALUE%0 ); - array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % -0", Number.NaN, -Number.MAX_VALUE%-0 ); +new TestCase( SECTION, "Number.MAX_VALUE % 0", Number.NaN, Number.MAX_VALUE%0 ); +new TestCase( SECTION, "Number.MAX_VALUE % -0", Number.NaN, Number.MAX_VALUE%-0 ); +new TestCase( SECTION, "-Number.MAX_VALUE % 0", Number.NaN, -Number.MAX_VALUE%0 ); +new TestCase( SECTION, "-Number.MAX_VALUE % -0", Number.NaN, -Number.MAX_VALUE%-0 ); // If the dividend is finite and the divisor is an infinity, the result equals the dividend. - array[item++] = new TestCase( SECTION, "1 % Number.NEGATIVE_INFINITY", 1, 1 % Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "1 % Number.POSITIVE_INFINITY", 1, 1 % Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-1 % Number.POSITIVE_INFINITY", -1, -1 % Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-1 % Number.NEGATIVE_INFINITY", -1, -1 % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "1 % Number.NEGATIVE_INFINITY", 1, 1 % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "1 % Number.POSITIVE_INFINITY", 1, 1 % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 % Number.POSITIVE_INFINITY", -1, -1 % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-1 % Number.NEGATIVE_INFINITY", -1, -1 % Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % Number.NEGATIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE % Number.POSITIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % Number.POSITIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-Number.MAX_VALUE % Number.NEGATIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE % Number.NEGATIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE % Number.POSITIVE_INFINITY", Number.MAX_VALUE, Number.MAX_VALUE % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Number.MAX_VALUE % Number.POSITIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Number.MAX_VALUE % Number.NEGATIVE_INFINITY", -Number.MAX_VALUE, -Number.MAX_VALUE % Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 % Number.POSITIVE_INFINITY", 0, 0 % Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 % Number.NEGATIVE_INFINITY", 0, 0 % Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-0 % Number.POSITIVE_INFINITY", -0, -0 % Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-0 % Number.NEGATIVE_INFINITY", -0, -0 % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "0 % Number.POSITIVE_INFINITY", 0, 0 % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 % Number.NEGATIVE_INFINITY", 0, 0 % Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-0 % Number.POSITIVE_INFINITY", -0, -0 % Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-0 % Number.NEGATIVE_INFINITY", -0, -0 % Number.NEGATIVE_INFINITY ); // If the dividend is a zero and the divisor is finite, the result is the same as the dividend. - array[item++] = new TestCase( SECTION, "0 % 1", 0, 0 % 1 ); - array[item++] = new TestCase( SECTION, "0 % -1", -0, 0 % -1 ); - array[item++] = new TestCase( SECTION, "-0 % 1", -0, -0 % 1 ); - array[item++] = new TestCase( SECTION, "-0 % -1", 0, -0 % -1 ); +new TestCase( SECTION, "0 % 1", 0, 0 % 1 ); +new TestCase( SECTION, "0 % -1", -0, 0 % -1 ); +new TestCase( SECTION, "-0 % 1", -0, -0 % 1 ); +new TestCase( SECTION, "-0 % -1", 0, -0 % -1 ); // In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the floating-point remainder r // from a dividend n and a divisor d is defined by the mathematical relation r = n (d * q) where q is an integer that // is negative only if n/d is negative and positive only if n/d is positive, and whose magnitude is as large as // possible without exceeding the magnitude of the true mathematical quotient of n and d. - return ( array ); -} +test(); + diff --git a/mozilla/js/tests/ecma/Expressions/11.6.1-1.js b/mozilla/js/tests/ecma/Expressions/11.6.1-1.js index 2a3f496e7e9..3cad0fea6aa 100644 --- a/mozilla/js/tests/ecma/Expressions/11.6.1-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.6.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 11.6.1-1.js ECMA Section: 11.6.1 The addition operator ( + ) @@ -79,69 +81,48 @@ var VERSION = "ECMA_1"; startTest(); - var testcases = getTestCases(); - writeHeaderToLog( SECTION + " The Addition operator ( + )"); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function getTestCases() { - var array = new Array(); - var item = 0; // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is // set in the object's prototype, not the object itself. - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2", 1, eval("var EXP_1 = true; var EXP_2 = false; EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2", 1, eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2", 1, eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", 1, eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2", 1, eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", "[object Object][object Object]", eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", 1, eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", "truefalse", eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); @@ -150,55 +131,53 @@ function getTestCases() { // a number primitive and a number object, and "MyValuelessObject", where the value is // set in the object's prototype, not the object itself. - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2", 99, eval("var EXP_1 = 100; var EXP_2 = -1; EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2", 99, eval("var EXP_1 = new Number(100); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2", 99, eval("var EXP_1 = new Object(100); var EXP_2 = new Object(-1); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", 99, eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2", 99, eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(-1); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", "[object Object][object Object]", eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2", 99, eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(-1); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", "100-1", eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, +new TestCase( SECTION, "var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1", "truetrue", eval("var EXP_1 = new MyValuelessObject( new MyValuelessObject( new Boolean(true) ) ); EXP_1 + EXP_1") ); - return ( array ); -} - +test(); function MyProtoValuelessObject() { this.valueOf = new Function ( "" ); diff --git a/mozilla/js/tests/ecma/Expressions/11.6.1-2.js b/mozilla/js/tests/ecma/Expressions/11.6.1-2.js index d03085ec301..448b5172f8e 100644 --- a/mozilla/js/tests/ecma/Expressions/11.6.1-2.js +++ b/mozilla/js/tests/ecma/Expressions/11.6.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,185 +35,167 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.6.1-2.js - ECMA Section: 11.6.1 The addition operator ( + ) - Description: + File Name: 11.6.1-2.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: - The addition operator either performs string concatenation or numeric - addition. + The addition operator either performs string concatenation or numeric + addition. - The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression - is evaluated as follows: + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: - 1. Evaluate AdditiveExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate MultiplicativeExpression. - 4. Call GetValue(Result(3)). - 5. Call ToPrimitive(Result(2)). - 6. Call ToPrimitive(Result(4)). - 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. - (Note that this step differs from step 3 in the algorithm for comparison - for the relational operators in using or instead of and.) - 8. Call ToNumber(Result(5)). - 9. Call ToNumber(Result(6)). - 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). - 11. Return Result(10). - 12. Call ToString(Result(5)). - 13. Call ToString(Result(6)). - 14. Concatenate Result(12) followed by Result(13). - 15. Return Result(14). + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). - Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. - All native ECMAScript objects except Date objects handle the absence of a - hint as if the hint Number were given; Date objects handle the absence of a - hint as if the hint String were given. Host objects may handle the absence - of a hint in some other manner. + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. - This test does only covers cases where the Additive or Mulplicative expression - ToPrimitive is a string. + This test does only covers cases where the Additive or Mulplicative expression + ToPrimitive is a string. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.6.1-2"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "11.6.1-2"; +var VERSION = "ECMA_1"; +startTest(); - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " The Addition operator ( + )"); - writeHeaderToLog( SECTION + " The Addition operator ( + )"); - test(); +// tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is +// a boolean primitive and a boolean object, and "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2") ); - // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is - // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is - // set in the object's prototype, not the object itself. +new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2", - "stringfalse", - eval("var EXP_1 = 'string'; var EXP_2 = false; EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2", - "truestring", - eval("var EXP_1 = true; var EXP_2 = 'string'; EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2", - "truestring", - eval("var EXP_1 = new Boolean(true); var EXP_2 = new String('string'); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", + "truestring", + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2", - "truestring", - eval("var EXP_1 = new Object(true); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2", - "stringfalse", - eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Boolean(false)); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", - "truestring", - eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", + "stringfalse", + eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2", - "[object Object][object Object]", - eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 + EXP_2") ); +// tests for number primitive, number object, Object object, a "MyObject" whose value is +// a number primitive and a number object, and "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2", - "stringfalse", - eval("var EXP_1 = new MyValuelessObject('string'); var EXP_2 = new MyValuelessObject(false); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2", - "stringfalse", - eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); - // tests for number primitive, number object, Object object, a "MyObject" whose value is - // a number primitive and a number object, and "MyValuelessObject", where the value is - // set in the object's prototype, not the object itself. +new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2", - "100string", - eval("var EXP_1 = 100; var EXP_2 = 'string'; EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2", - "string-1", - eval("var EXP_1 = new String('string'); var EXP_2 = new Number(-1); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2", - "100string", - eval("var EXP_1 = new Object(100); var EXP_2 = new Object('string'); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", + "[object Object][object Object]", + eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2", - "string-1", - eval("var EXP_1 = new Object(new String('string')); var EXP_2 = new Object(new Number(-1)); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2", + "100string", + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2", - "100string", - eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject('string'); EXP_1 + EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", + "string-1", + eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2", - "[object Object][object Object]", - eval("var EXP_1 = new MyObject(new String('string')); var EXP_2 = new MyObject(new Number(-1)); EXP_1 + EXP_2") ); +test(); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2", - "100string", - eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject('string'); EXP_1 + EXP_2") ); - - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2", - "string-1", - eval("var EXP_1 = new MyValuelessObject(new String('string')); var EXP_2 = new MyValuelessObject(new Number(-1)); EXP_1 + EXP_2") ); - return ( array ); -} function MyProtoValuelessObject() { - this.valueOf = new Function ( "" ); - this.__proto__ = null; + this.valueOf = new Function ( "" ); + this.__proto__ = null; } function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; } function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); + this.__proto__ = new MyPrototypeObject(value); } function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; } function MyObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.value = value; + this.valueOf = new Function( "return this.value" ); + this.value = value; } diff --git a/mozilla/js/tests/ecma/Expressions/11.6.1-3.js b/mozilla/js/tests/ecma/Expressions/11.6.1-3.js index df33979ee72..ac3d205e6b1 100644 --- a/mozilla/js/tests/ecma/Expressions/11.6.1-3.js +++ b/mozilla/js/tests/ecma/Expressions/11.6.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,163 +35,145 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.6.1-3.js - ECMA Section: 11.6.1 The addition operator ( + ) - Description: + File Name: 11.6.1-3.js + ECMA Section: 11.6.1 The addition operator ( + ) + Description: - The addition operator either performs string concatenation or numeric - addition. + The addition operator either performs string concatenation or numeric + addition. - The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression - is evaluated as follows: + The production AdditiveExpression : AdditiveExpression + MultiplicativeExpression + is evaluated as follows: - 1. Evaluate AdditiveExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate MultiplicativeExpression. - 4. Call GetValue(Result(3)). - 5. Call ToPrimitive(Result(2)). - 6. Call ToPrimitive(Result(4)). - 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. - (Note that this step differs from step 3 in the algorithm for comparison - for the relational operators in using or instead of and.) - 8. Call ToNumber(Result(5)). - 9. Call ToNumber(Result(6)). - 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). - 11. Return Result(10). - 12. Call ToString(Result(5)). - 13. Call ToString(Result(6)). - 14. Concatenate Result(12) followed by Result(13). - 15. Return Result(14). + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToPrimitive(Result(2)). + 6. Call ToPrimitive(Result(4)). + 7. If Type(Result(5)) is String or Type(Result(6)) is String, go to step 12. + (Note that this step differs from step 3 in the algorithm for comparison + for the relational operators in using or instead of and.) + 8. Call ToNumber(Result(5)). + 9. Call ToNumber(Result(6)). + 10. Apply the addition operation to Result(8) and Result(9). See the discussion below (11.6.3). + 11. Return Result(10). + 12. Call ToString(Result(5)). + 13. Call ToString(Result(6)). + 14. Concatenate Result(12) followed by Result(13). + 15. Return Result(14). - Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. - All native ECMAScript objects except Date objects handle the absence of a - hint as if the hint Number were given; Date objects handle the absence of a - hint as if the hint String were given. Host objects may handle the absence - of a hint in some other manner. + Note that no hint is provided in the calls to ToPrimitive in steps 5 and 6. + All native ECMAScript objects except Date objects handle the absence of a + hint as if the hint Number were given; Date objects handle the absence of a + hint as if the hint String were given. Host objects may handle the absence + of a hint in some other manner. - This test does only covers cases where the Additive or Mulplicative expression - is a Date. + This test does only covers cases where the Additive or Mulplicative expression + is a Date. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.6.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.6.1-3"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The Addition operator ( + )"); - test(); +writeHeaderToLog( SECTION + " The Addition operator ( + )"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is +// a boolean primitive and a boolean object, and "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +var DATE1 = new Date(); - // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is - // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is - // set in the object's prototype, not the object itself. +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + DATE1", + DATE1.toString() + DATE1.toString(), + DATE1 + DATE1 ); - var DATE1 = new Date(); +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + 0", + DATE1.toString() + 0, + DATE1 + 0 ); - array[item++] = new TestCase( SECTION, - "var DATE1 = new Date(); DATE1 + DATE1", - DATE1.toString() + DATE1.toString(), - DATE1 + DATE1 ); +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Number(0)", + DATE1.toString() + 0, + DATE1 + new Number(0) ); - array[item++] = new TestCase( SECTION, - "var DATE1 = new Date(); DATE1 + 0", - DATE1.toString() + 0, - DATE1 + 0 ); +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + true", + DATE1.toString() + "true", + DATE1 + true ); - array[item++] = new TestCase( SECTION, - "var DATE1 = new Date(); DATE1 + new Number(0)", - DATE1.toString() + 0, - DATE1 + new Number(0) ); +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Boolean(true)", + DATE1.toString() + "true", + DATE1 + new Boolean(true) ); - array[item++] = new TestCase( SECTION, - "var DATE1 = new Date(); DATE1 + true", - DATE1.toString() + "true", - DATE1 + true ); +new TestCase( SECTION, + "var DATE1 = new Date(); DATE1 + new Boolean(true)", + DATE1.toString() + "true", + DATE1 + new Boolean(true) ); - array[item++] = new TestCase( SECTION, - "var DATE1 = new Date(); DATE1 + new Boolean(true)", - DATE1.toString() + "true", - DATE1 + new Boolean(true) ); +var MYOB1 = new MyObject( DATE1 ); +var MYOB2 = new MyValuelessObject( DATE1 ); +var MYOB3 = new MyProtolessObject( DATE1 ); +var MYOB4 = new MyProtoValuelessObject( DATE1 ); - array[item++] = new TestCase( SECTION, - "var DATE1 = new Date(); DATE1 + new Boolean(true)", - DATE1.toString() + "true", - DATE1 + new Boolean(true) ); +new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + new Number(1)", + "[object Object]1", + MYOB1 + new Number(1) ); - var MYOB1 = new MyObject( DATE1 ); - var MYOB2 = new MyValuelessObject( DATE1 ); - var MYOB3 = new MyProtolessObject( DATE1 ); - var MYOB4 = new MyProtoValuelessObject( DATE1 ); +new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + 1", + "[object Object]1", + MYOB1 + 1 ); - array[item++] = new TestCase( SECTION, - "MYOB1 = new MyObject(DATE1); MYOB1 + new Number(1)", - "[object Object]1", - MYOB1 + new Number(1) ); +new TestCase( SECTION, + "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + 'string'", + DATE1.toString() + "string", + MYOB2 + 'string' ); - array[item++] = new TestCase( SECTION, - "MYOB1 = new MyObject(DATE1); MYOB1 + 1", - "[object Object]1", - MYOB1 + 1 ); - - array[item++] = new TestCase( SECTION, - "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + 'string'", - DATE1.toString() + "string", - MYOB2 + 'string' ); - - array[item++] = new TestCase( SECTION, - "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + new String('string')", - DATE1.toString() + "string", - MYOB2 + new String('string') ); +new TestCase( SECTION, + "MYOB2 = new MyValuelessObject(DATE1); MYOB3 + new String('string')", + DATE1.toString() + "string", + MYOB2 + new String('string') ); /* - array[item++] = new TestCase( SECTION, - "MYOB3 = new MyProtolessObject(DATE1); MYOB3 + new Boolean(true)", - DATE1.toString() + "true", - MYOB3 + new Boolean(true) ); + new TestCase( SECTION, + "MYOB3 = new MyProtolessObject(DATE1); MYOB3 + new Boolean(true)", + DATE1.toString() + "true", + MYOB3 + new Boolean(true) ); */ - array[item++] = new TestCase( SECTION, - "MYOB1 = new MyObject(DATE1); MYOB1 + true", - "[object Object]true", - MYOB1 + true ); +new TestCase( SECTION, + "MYOB1 = new MyObject(DATE1); MYOB1 + true", + "[object Object]true", + MYOB1 + true ); + +test(); - return ( array ); -} function MyProtoValuelessObject() { - this.valueOf = new Function ( "" ); - this.__proto__ = null; + this.valueOf = new Function ( "" ); + this.__proto__ = null; } function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; } function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); + this.__proto__ = new MyPrototypeObject(value); } function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; } function MyObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.value = value; + this.valueOf = new Function( "return this.value" ); + this.value = value; } diff --git a/mozilla/js/tests/ecma/Expressions/11.6.2-1.js b/mozilla/js/tests/ecma/Expressions/11.6.2-1.js index 00a149d088c..a2b6180fb9d 100644 --- a/mozilla/js/tests/ecma/Expressions/11.6.2-1.js +++ b/mozilla/js/tests/ecma/Expressions/11.6.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,181 +35,163 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.6.2-1.js - ECMA Section: 11.6.2 The Subtraction operator ( - ) - Description: + File Name: 11.6.2-1.js + ECMA Section: 11.6.2 The Subtraction operator ( - ) + Description: - The production AdditiveExpression : AdditiveExpression - - MultiplicativeExpression is evaluated as follows: + The production AdditiveExpression : AdditiveExpression - + MultiplicativeExpression is evaluated as follows: - 1. Evaluate AdditiveExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate MultiplicativeExpression. - 4. Call GetValue(Result(3)). - 5. Call ToNumber(Result(2)). - 6. Call ToNumber(Result(4)). - 7. Apply the subtraction operation to Result(5) and Result(6). See the - discussion below (11.6.3). - 8. Return Result(7). + 1. Evaluate AdditiveExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate MultiplicativeExpression. + 4. Call GetValue(Result(3)). + 5. Call ToNumber(Result(2)). + 6. Call ToNumber(Result(4)). + 7. Apply the subtraction operation to Result(5) and Result(6). See the + discussion below (11.6.3). + 8. Return Result(7). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.6.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.6.2-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The subtraction operator ( - )"); - test(); +writeHeaderToLog( SECTION + " The subtraction operator ( - )"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is +// a boolean primitive and a boolean object, and "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2", + 1, + eval("var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2") ); - // tests for boolean primitive, boolean object, Object object, a "MyObject" whose value is - // a boolean primitive and a boolean object, and "MyValuelessObject", where the value is - // set in the object's prototype, not the object itself. +new TestCase( SECTION, + "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2", - 1, - eval("var EXP_1 = true; var EXP_2 = false; EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2", - 1, - eval("var EXP_1 = new Boolean(true); var EXP_2 = new Boolean(false); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2", - 1, - eval("var EXP_1 = new Object(true); var EXP_2 = new Object(false); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2", - 1, - eval("var EXP_1 = new Object(new Boolean(true)); var EXP_2 = new Object(new Boolean(false)); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2", - 1, - eval("var EXP_1 = new MyObject(true); var EXP_2 = new MyObject(false); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2", - Number.NaN, - eval("var EXP_1 = new MyObject(new Boolean(true)); var EXP_2 = new MyObject(new Boolean(false)); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2", + 1, + eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2", - Number.NaN, - eval("var EXP_1 = new MyOtherObject(new Boolean(true)); var EXP_2 = new MyOtherObject(new Boolean(false)); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2", - 1, - eval("var EXP_1 = new MyValuelessObject(true); var EXP_2 = new MyValuelessObject(false); EXP_1 - EXP_2") ); +// tests for number primitive, number object, Object object, a "MyObject" whose value is +// a number primitive and a number object, and "MyValuelessObject", where the value is +// set in the object's prototype, not the object itself. - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2", - Number.NaN, - eval("var EXP_1 = new MyValuelessObject(new Boolean(true)); var EXP_2 = new MyValuelessObject(new Boolean(false)); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2", + 99, + eval("var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2") ); - // tests for number primitive, number object, Object object, a "MyObject" whose value is - // a number primitive and a number object, and "MyValuelessObject", where the value is - // set in the object's prototype, not the object itself. +new TestCase( SECTION, + "var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2", - 99, - eval("var EXP_1 = 100; var EXP_2 = 1; EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2", - 99, - eval("var EXP_1 = new Number(100); var EXP_2 = new Number(1); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2", - 99, - eval("var EXP_1 = new Object(100); var EXP_2 = new Object(1); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2", - 99, - eval("var EXP_1 = new Object(new Number(100)); var EXP_2 = new Object(new Number(1)); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2", - 99, - eval("var EXP_1 = new MyObject(100); var EXP_2 = new MyObject(1); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2") ); - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2", - Number.NaN, - eval("var EXP_1 = new MyObject(new Number(100)); var EXP_2 = new MyObject(new Number(1)); EXP_1 - EXP_2") ); - - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2", - 99, - eval("var EXP_1 = new MyOtherObject(new Number(100)); var EXP_2 = new MyOtherObject(new Number(1)); EXP_1 - EXP_2") ); - - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2", - 99, - eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2") ); +new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2", + 99, + eval("var EXP_1 = new MyValuelessObject(100); var EXP_2 = new MyValuelessObject(1); EXP_1 - EXP_2") ); /* - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2", - Number.NaN, - eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2") ); + new TestCase( SECTION, + "var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2", + Number.NaN, + eval("var EXP_1 = new MyValuelessObject(new Number(100)); var EXP_2 = new MyValuelessObject(new Number(1)); EXP_1 - EXP_2") ); */ - // same thing with string! - array[item++] = new TestCase( SECTION, - "var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1'); EXP_1 - EXP_2", - 254, - eval("var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1')); EXP_1 - EXP_2") ); +// same thing with string! +new TestCase( SECTION, + "var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1'); EXP_1 - EXP_2", + 254, + eval("var EXP_1 = new MyOtherObject(new String('0xff')); var EXP_2 = new MyOtherObject(new String('1')); EXP_1 - EXP_2") ); + +test(); - return ( array ); -} function MyProtoValuelessObject() { - this.valueOf = new Function ( "" ); - this.__proto__ = null; + this.valueOf = new Function ( "" ); + this.__proto__ = null; } function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; } function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); + this.__proto__ = new MyPrototypeObject(value); } function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; } function MyObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.value = value; + this.valueOf = new Function( "return this.value" ); + this.value = value; } function MyOtherObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.toString = new Function ( "return this.value + ''" ); - this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function ( "return this.value + ''" ); + this.value = value; } diff --git a/mozilla/js/tests/ecma/Expressions/11.6.3.js b/mozilla/js/tests/ecma/Expressions/11.6.3.js index 3cb1b2e8369..d46423ab4ec 100644 --- a/mozilla/js/tests/ecma/Expressions/11.6.3.js +++ b/mozilla/js/tests/ecma/Expressions/11.6.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,98 +35,79 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.6.3.js - ECMA Section: 11.6.3 Applying the additive operators - (+, -) to numbers - Description: - The + operator performs addition when applied to two operands of numeric - type, producing the sum of the operands. The - operator performs - subtraction, producing the difference of two numeric operands. + File Name: 11.6.3.js + ECMA Section: 11.6.3 Applying the additive operators + (+, -) to numbers + Description: + The + operator performs addition when applied to two operands of numeric + type, producing the sum of the operands. The - operator performs + subtraction, producing the difference of two numeric operands. - Addition is a commutative operation, but not always associative. + Addition is a commutative operation, but not always associative. - The result of an addition is determined using the rules of IEEE 754 - double-precision arithmetic: + The result of an addition is determined using the rules of IEEE 754 + double-precision arithmetic: - If either operand is NaN, the result is NaN. - The sum of two infinities of opposite sign is NaN. - The sum of two infinities of the same sign is the infinity of that sign. - The sum of an infinity and a finite value is equal to the infinite operand. - The sum of two negative zeros is 0. The sum of two positive zeros, or of - two zeros of opposite sign, is +0. - The sum of a zero and a nonzero finite value is equal to the nonzero - operand. - The sum of two nonzero finite values of the same magnitude and opposite - sign is +0. - In the remaining cases, where neither an infinity, nor a zero, nor NaN is - involved, and the operands have the same sign or have different - magnitudes, the sum is computed and rounded to the nearest - representable value using IEEE 754 round-to-nearest mode. If the - magnitude is too large to represent, the operation overflows and - the result is then an infinity of appropriate sign. The ECMAScript - language requires support of gradual underflow as defined by IEEE 754. + If either operand is NaN, the result is NaN. + The sum of two infinities of opposite sign is NaN. + The sum of two infinities of the same sign is the infinity of that sign. + The sum of an infinity and a finite value is equal to the infinite operand. + The sum of two negative zeros is 0. The sum of two positive zeros, or of + two zeros of opposite sign, is +0. + The sum of a zero and a nonzero finite value is equal to the nonzero + operand. + The sum of two nonzero finite values of the same magnitude and opposite + sign is +0. + In the remaining cases, where neither an infinity, nor a zero, nor NaN is + involved, and the operands have the same sign or have different + magnitudes, the sum is computed and rounded to the nearest + representable value using IEEE 754 round-to-nearest mode. If the + magnitude is too large to represent, the operation overflows and + the result is then an infinity of appropriate sign. The ECMAScript + language requires support of gradual underflow as defined by IEEE 754. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.6.3"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.6.3"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Applying the additive operators (+,-) to numbers"); - test(); +writeHeaderToLog( SECTION + " Applying the additive operators (+,-) to numbers"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "Number.NaN + 1", Number.NaN, Number.NaN + 1 ); +new TestCase( SECTION, "1 + Number.NaN", Number.NaN, 1 + Number.NaN ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Number.NaN - 1", Number.NaN, Number.NaN - 1 ); +new TestCase( SECTION, "1 - Number.NaN", Number.NaN, 1 - Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NaN + 1", Number.NaN, Number.NaN + 1 ); - array[item++] = new TestCase( SECTION, "1 + Number.NaN", Number.NaN, 1 + Number.NaN ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY); - array[item++] = new TestCase( SECTION, "Number.NaN - 1", Number.NaN, Number.NaN - 1 ); - array[item++] = new TestCase( SECTION, "1 - Number.NaN", Number.NaN, 1 - Number.NaN ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY); +new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY + Number.POSITIVE_INFINITY); +new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NaN, Number.POSITIVE_INFINITY - Number.POSITIVE_INFINITY); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.NaN, Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY); +new TestCase( SECTION, "-0 + -0", -0, -0 + -0 ); +new TestCase( SECTION, "-0 - 0", -0, -0 - 0 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY); +new TestCase( SECTION, "0 + 0", 0, 0 + 0 ); +new TestCase( SECTION, "0 + -0", 0, 0 + -0 ); +new TestCase( SECTION, "0 - -0", 0, 0 - -0 ); +new TestCase( SECTION, "0 - 0", 0, 0 - 0 ); +new TestCase( SECTION, "-0 - -0", 0, -0 - -0 ); +new TestCase( SECTION, "-0 + 0", 0, -0 + 0 ); - array[item++] = new TestCase( SECTION, "-0 + -0", -0, -0 + -0 ); - array[item++] = new TestCase( SECTION, "-0 - 0", -0, -0 - 0 ); +new TestCase( SECTION, "Number.MAX_VALUE - Number.MAX_VALUE", 0, Number.MAX_VALUE - Number.MAX_VALUE ); +new TestCase( SECTION, "1/Number.MAX_VALUE - 1/Number.MAX_VALUE", 0, 1/Number.MAX_VALUE - 1/Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "0 + 0", 0, 0 + 0 ); - array[item++] = new TestCase( SECTION, "0 + -0", 0, 0 + -0 ); - array[item++] = new TestCase( SECTION, "0 - -0", 0, 0 - -0 ); - array[item++] = new TestCase( SECTION, "0 - 0", 0, 0 - 0 ); - array[item++] = new TestCase( SECTION, "-0 - -0", 0, -0 - -0 ); - array[item++] = new TestCase( SECTION, "-0 + 0", 0, -0 + 0 ); +new TestCase( SECTION, "Number.MIN_VALUE - Number.MIN_VALUE", 0, Number.MIN_VALUE - Number.MIN_VALUE ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE - Number.MAX_VALUE", 0, Number.MAX_VALUE - Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "1/Number.MAX_VALUE - 1/Number.MAX_VALUE", 0, 1/Number.MAX_VALUE - 1/Number.MAX_VALUE ); - - array[item++] = new TestCase( SECTION, "Number.MIN_VALUE - Number.MIN_VALUE", 0, Number.MIN_VALUE - Number.MIN_VALUE ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/Expressions/11.7.1.js b/mozilla/js/tests/ecma/Expressions/11.7.1.js index 49c6b6c6e66..6fc511edbec 100644 --- a/mozilla/js/tests/ecma/Expressions/11.7.1.js +++ b/mozilla/js/tests/ecma/Expressions/11.7.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 11.7.1.js ECMA Section: 11.7.1 The Left Shift Operator ( << ) @@ -63,41 +65,21 @@ var VERSION = "ECMA_1"; startTest(); - var testcases = getTestCases(); - writeHeaderToLog( SECTION + " The left shift operator ( << )"); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; for ( power = 0; power < 33; power++ ) { shiftexp = Math.pow( 2, power ); for ( addexp = 0; addexp < 33; addexp++ ) { - array[item++] = new TestCase( SECTION, - shiftexp + " << " + addexp, - LeftShift( shiftexp, addexp ), - shiftexp << addexp ); + new TestCase( SECTION, + shiftexp + " << " + addexp, + LeftShift( shiftexp, addexp ), + shiftexp << addexp ); } } - return ( array ); -} +test(); + function ToInteger( n ) { n = Number( n ); var sign = ( n < 0 ) ? -1 : 1; diff --git a/mozilla/js/tests/ecma/Expressions/11.7.2.js b/mozilla/js/tests/ecma/Expressions/11.7.2.js index d00dc8fa6d2..4503643197c 100644 --- a/mozilla/js/tests/ecma/Expressions/11.7.2.js +++ b/mozilla/js/tests/ecma/Expressions/11.7.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 11.7.2.js ECMA Section: 11.7.2 The signed right shift operator ( >> ) @@ -63,27 +65,9 @@ var SECTION = "11.7.2"; var VERSION = "ECMA_1"; startTest(); - var testcases = getTestCases(); writeHeaderToLog( SECTION + " The signed right shift operator ( >> )"); - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; var power = 0; var addexp = 0; @@ -91,10 +75,10 @@ function getTestCases() { shiftexp = Math.pow( 2, power ); for ( addexp = 0; addexp <= 32; addexp++ ) { - array[item++] = new TestCase( SECTION, - shiftexp + " >> " + addexp, - SignedRightShift( shiftexp, addexp ), - shiftexp >> addexp ); + new TestCase( SECTION, + shiftexp + " >> " + addexp, + SignedRightShift( shiftexp, addexp ), + shiftexp >> addexp ); } } @@ -102,15 +86,14 @@ function getTestCases() { shiftexp = -Math.pow( 2, power ); for ( addexp = 0; addexp <= 32; addexp++ ) { - array[item++] = new TestCase( SECTION, - shiftexp + " >> " + addexp, - SignedRightShift( shiftexp, addexp ), - shiftexp >> addexp ); + new TestCase( SECTION, + shiftexp + " >> " + addexp, + SignedRightShift( shiftexp, addexp ), + shiftexp >> addexp ); } } - return ( array ); -} +test(); function ToInteger( n ) { n = Number( n ); @@ -258,4 +241,4 @@ function SignedRShift( s, a ) { return ToInt32(ToInt32Decimal(s)); -} \ No newline at end of file +} diff --git a/mozilla/js/tests/ecma/Expressions/11.7.3.js b/mozilla/js/tests/ecma/Expressions/11.7.3.js index 98276151a3e..75d52b0754c 100644 --- a/mozilla/js/tests/ecma/Expressions/11.7.3.js +++ b/mozilla/js/tests/ecma/Expressions/11.7.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,212 +35,194 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.7.3.js - ECMA Section: 11.7.3 The unsigned right shift operator ( >>> ) - Description: - 11.7.3 The unsigned right shift operator ( >>> ) - Performs a zero-filling bitwise right shift operation on the left argument - by the amount specified by the right argument. + File Name: 11.7.3.js + ECMA Section: 11.7.3 The unsigned right shift operator ( >>> ) + Description: + 11.7.3 The unsigned right shift operator ( >>> ) + Performs a zero-filling bitwise right shift operation on the left argument + by the amount specified by the right argument. - The production ShiftExpression : ShiftExpression >>> AdditiveExpression is - evaluated as follows: + The production ShiftExpression : ShiftExpression >>> AdditiveExpression is + evaluated as follows: - 1. Evaluate ShiftExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate AdditiveExpression. - 4. Call GetValue(Result(3)). - 5. Call ToUint32(Result(2)). - 6. Call ToUint32(Result(4)). - 7. Mask out all but the least significant 5 bits of Result(6), that is, - compute Result(6) & 0x1F. - 8. Perform zero-filling right shift of Result(5) by Result(7) bits. - Vacated bits are filled with zero. The result is an unsigned 32 bit - integer. - 9. Return Result(8). + 1. Evaluate ShiftExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate AdditiveExpression. + 4. Call GetValue(Result(3)). + 5. Call ToUint32(Result(2)). + 6. Call ToUint32(Result(4)). + 7. Mask out all but the least significant 5 bits of Result(6), that is, + compute Result(6) & 0x1F. + 8. Perform zero-filling right shift of Result(5) by Result(7) bits. + Vacated bits are filled with zero. The result is an unsigned 32 bit + integer. + 9. Return Result(8). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.7.3"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.7.3"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The unsigned right shift operator ( >>> )"); - test(); +writeHeaderToLog( SECTION + " The unsigned right shift operator ( >>> )"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var addexp = 0; +var power = 0; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( power = 0; power <= 32; power++ ) { + shiftexp = Math.pow( 2, power ); + + for ( addexp = 0; addexp <= 32; addexp++ ) { + new TestCase( SECTION, + shiftexp + " >>> " + addexp, + UnsignedRightShift( shiftexp, addexp ), + shiftexp >>> addexp ); + } } -function getTestCases() { - var array = new Array(); - var item = 0; - var addexp = 0; - var power = 0; +test(); - for ( power = 0; power <= 32; power++ ) { - shiftexp = Math.pow( 2, power ); - - for ( addexp = 0; addexp <= 32; addexp++ ) { - array[item++] = new TestCase( SECTION, - shiftexp + " >>> " + addexp, - UnsignedRightShift( shiftexp, addexp ), - shiftexp >>> addexp ); - } - } - - return ( array ); -} function ToInteger( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( n != n ) { - return 0; - } - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { - return n; - } - return ( sign * Math.floor(Math.abs(n)) ); + if ( n != n ) { + return 0; + } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY ) { + return n; + } + return ( sign * Math.floor(Math.abs(n)) ); } function ToInt32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); - n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; - return ( n ); + return ( n ); } function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); + return ( n ); } function ToUint16( n ) { - var sign = ( n < 0 ) ? -1 : 1; + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); + n = ( sign * Math.floor( Math.abs(n) ) ) % Math.pow(2,16); - if (n <0) { - n += Math.pow(2,16); - } + if (n <0) { + n += Math.pow(2,16); + } - return ( n ); + return ( n ); } function Mask( b, n ) { - b = ToUint32BitString( b ); - b = b.substring( b.length - n ); - b = ToUint32Decimal( b ); - return ( b ); + b = ToUint32BitString( b ); + b = b.substring( b.length - n ); + b = ToUint32Decimal( b ); + return ( b ); } function ToUint32BitString( n ) { - var b = ""; - for ( p = 31; p >=0; p-- ) { - if ( n >= Math.pow(2,p) ) { - b += "1"; - n -= Math.pow(2,p); - } else { - b += "0"; - } + var b = ""; + for ( p = 31; p >=0; p-- ) { + if ( n >= Math.pow(2,p) ) { + b += "1"; + n -= Math.pow(2,p); + } else { + b += "0"; } - return b; + } + return b; } function ToInt32BitString( n ) { - var b = ""; - var sign = ( n < 0 ) ? -1 : 1; + var b = ""; + var sign = ( n < 0 ) ? -1 : 1; - b += ( sign == 1 ) ? "0" : "1"; + b += ( sign == 1 ) ? "0" : "1"; - for ( p = 30; p >=0; p-- ) { - if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { - b += ( sign == 1 ) ? "1" : "0"; - n -= sign * Math.pow( 2, p ); - } else { - b += ( sign == 1 ) ? "0" : "1"; - } + for ( p = 30; p >=0; p-- ) { + if ( (sign == 1 ) ? sign * n >= Math.pow(2,p) : sign * n > Math.pow(2,p) ) { + b += ( sign == 1 ) ? "1" : "0"; + n -= sign * Math.pow( 2, p ); + } else { + b += ( sign == 1 ) ? "0" : "1"; } + } - return b; + return b; } function ToInt32Decimal( bin ) { - var r = 0; - var sign; + var r = 0; + var sign; - if ( Number(bin.charAt(0)) == 0 ) { - sign = 1; - r = 0; - } else { - sign = -1; - r = -(Math.pow(2,31)); - } + if ( Number(bin.charAt(0)) == 0 ) { + sign = 1; + r = 0; + } else { + sign = -1; + r = -(Math.pow(2,31)); + } - for ( var j = 0; j < 31; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + for ( var j = 0; j < 31; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + } - return r; + return r; } function ToUint32Decimal( bin ) { - var r = 0; + var r = 0; - for ( l = bin.length; l < 32; l++ ) { - bin = "0" + bin; - } + for ( l = bin.length; l < 32; l++ ) { + bin = "0" + bin; + } - for ( j = 0; j < 32; j++ ) { - r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); + for ( j = 0; j < 32; j++ ) { + r += Math.pow( 2, j ) * Number(bin.charAt(31-j)); - } + } - return r; + return r; } function RShift( s, a ) { - s = ToUint32BitString( s ); - for ( z = 0; z < a; z++ ) { - s = "0" + s; - } - s = s.substring( 0, s.length - a ); + s = ToUint32BitString( s ); + for ( z = 0; z < a; z++ ) { + s = "0" + s; + } + s = s.substring( 0, s.length - a ); - return ToUint32Decimal(s); + return ToUint32Decimal(s); } function UnsignedRightShift( s, a ) { - s = ToUint32( s ); - a = ToUint32( a ); - a = Mask( a, 5 ); - return ( RShift( s, a ) ); + s = ToUint32( s ); + a = ToUint32( a ); + a = Mask( a, 5 ); + return ( RShift( s, a ) ); } diff --git a/mozilla/js/tests/ecma/Expressions/11.8.1.js b/mozilla/js/tests/ecma/Expressions/11.8.1.js index 3750463c5b1..e5ab8edb0cf 100644 --- a/mozilla/js/tests/ecma/Expressions/11.8.1.js +++ b/mozilla/js/tests/ecma/Expressions/11.8.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,103 +35,85 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.8.1.js - ECMA Section: 11.8.1 The less-than operator ( < ) - Description: + File Name: 11.8.1.js + ECMA Section: 11.8.1 The less-than operator ( < ) + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.8.1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.8.1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The less-than operator ( < )"); - test(); +writeHeaderToLog( SECTION + " The less-than operator ( < )"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "true < false", false, true < false ); +new TestCase( SECTION, "false < true", true, false < true ); +new TestCase( SECTION, "false < false", false, false < false ); +new TestCase( SECTION, "true < true", false, true < true ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "new Boolean(true) < new Boolean(true)", false, new Boolean(true) < new Boolean(true) ); +new TestCase( SECTION, "new Boolean(true) < new Boolean(false)", false, new Boolean(true) < new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) < new Boolean(true)", true, new Boolean(false) < new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) < new Boolean(false)", false, new Boolean(false) < new Boolean(false) ); - array[item++] = new TestCase( SECTION, "true < false", false, true < false ); - array[item++] = new TestCase( SECTION, "false < true", true, false < true ); - array[item++] = new TestCase( SECTION, "false < false", false, false < false ); - array[item++] = new TestCase( SECTION, "true < true", false, true < true ); +new TestCase( SECTION, "new MyObject(Infinity) < new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) < new Boolean(true)", false, new Boolean(true) < new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) < new Boolean(false)", false, new Boolean(true) < new Boolean(false) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) < new Boolean(true)", true, new Boolean(false) < new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) < new Boolean(false)", false, new Boolean(false) < new Boolean(false) ); +new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(true)", true, new MyValueObject(false) < new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(true) < new MyValueObject(true)", false, new MyValueObject(true) < new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(false)", false, new MyValueObject(false) < new MyValueObject(false) ); - array[item++] = new TestCase( SECTION, "new MyObject(Infinity) < new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) < new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) < new MyObject( Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(true)", true, new MyStringObject(false) < new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(true) < new MyStringObject(true)", false, new MyStringObject(true) < new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(false)", false, new MyStringObject(false) < new MyStringObject(false) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(true)", true, new MyValueObject(false) < new MyValueObject(true) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(true) < new MyValueObject(true)", false, new MyValueObject(true) < new MyValueObject(true) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(false) < new MyValueObject(false)", false, new MyValueObject(false) < new MyValueObject(false) ); +new TestCase( SECTION, "Number.NaN < Number.NaN", false, Number.NaN < Number.NaN ); +new TestCase( SECTION, "0 < Number.NaN", false, 0 < Number.NaN ); +new TestCase( SECTION, "Number.NaN < 0", false, Number.NaN < 0 ); - array[item++] = new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(true)", true, new MyStringObject(false) < new MyStringObject(true) ); - array[item++] = new TestCase( SECTION, "new MyStringObject(true) < new MyStringObject(true)", false, new MyStringObject(true) < new MyStringObject(true) ); - array[item++] = new TestCase( SECTION, "new MyStringObject(false) < new MyStringObject(false)", false, new MyStringObject(false) < new MyStringObject(false) ); +new TestCase( SECTION, "0 < -0", false, 0 < -0 ); +new TestCase( SECTION, "-0 < 0", false, -0 < 0 ); - array[item++] = new TestCase( SECTION, "Number.NaN < Number.NaN", false, Number.NaN < Number.NaN ); - array[item++] = new TestCase( SECTION, "0 < Number.NaN", false, 0 < Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NaN < 0", false, Number.NaN < 0 ); +new TestCase( SECTION, "Infinity < 0", false, Number.POSITIVE_INFINITY < 0 ); +new TestCase( SECTION, "Infinity < Number.MAX_VALUE", false, Number.POSITIVE_INFINITY < Number.MAX_VALUE ); +new TestCase( SECTION, "Infinity < Infinity", false, Number.POSITIVE_INFINITY < Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 < -0", false, 0 < -0 ); - array[item++] = new TestCase( SECTION, "-0 < 0", false, -0 < 0 ); +new TestCase( SECTION, "0 < Infinity", true, 0 < Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE < Infinity", true, Number.MAX_VALUE < Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Infinity < 0", false, Number.POSITIVE_INFINITY < 0 ); - array[item++] = new TestCase( SECTION, "Infinity < Number.MAX_VALUE", false, Number.POSITIVE_INFINITY < Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Infinity < Infinity", false, Number.POSITIVE_INFINITY < Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 < -Infinity", false, 0 < Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE < -Infinity", false, Number.MAX_VALUE < Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-Infinity < -Infinity", false, Number.NEGATIVE_INFINITY < Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 < Infinity", true, 0 < Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE < Infinity", true, Number.MAX_VALUE < Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Infinity < 0", true, Number.NEGATIVE_INFINITY < 0 ); +new TestCase( SECTION, "-Infinity < -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY < -Number.MAX_VALUE ); +new TestCase( SECTION, "-Infinity < Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY < Number.MIN_VALUE ); - array[item++] = new TestCase( SECTION, "0 < -Infinity", false, 0 < Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE < -Infinity", false, Number.MAX_VALUE < Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-Infinity < -Infinity", false, Number.NEGATIVE_INFINITY < Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "'string' < 'string'", false, 'string' < 'string' ); +new TestCase( SECTION, "'astring' < 'string'", true, 'astring' < 'string' ); +new TestCase( SECTION, "'strings' < 'stringy'", true, 'strings' < 'stringy' ); +new TestCase( SECTION, "'strings' < 'stringier'", false, 'strings' < 'stringier' ); +new TestCase( SECTION, "'string' < 'astring'", false, 'string' < 'astring' ); +new TestCase( SECTION, "'string' < 'strings'", true, 'string' < 'strings' ); - array[item++] = new TestCase( SECTION, "-Infinity < 0", true, Number.NEGATIVE_INFINITY < 0 ); - array[item++] = new TestCase( SECTION, "-Infinity < -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY < -Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "-Infinity < Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY < Number.MIN_VALUE ); +test(); - array[item++] = new TestCase( SECTION, "'string' < 'string'", false, 'string' < 'string' ); - array[item++] = new TestCase( SECTION, "'astring' < 'string'", true, 'astring' < 'string' ); - array[item++] = new TestCase( SECTION, "'strings' < 'stringy'", true, 'strings' < 'stringy' ); - array[item++] = new TestCase( SECTION, "'strings' < 'stringier'", false, 'strings' < 'stringier' ); - array[item++] = new TestCase( SECTION, "'string' < 'astring'", false, 'string' < 'astring' ); - array[item++] = new TestCase( SECTION, "'string' < 'strings'", true, 'string' < 'strings' ); - - return ( array ); -} function MyObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - this.toString = new Function( "return this.value +''" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); } function MyValueObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); } function MyStringObject(value) { - this.value = value; - this.toString = new Function( "return this.value +''" ); -} \ No newline at end of file + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/mozilla/js/tests/ecma/Expressions/11.8.2.js b/mozilla/js/tests/ecma/Expressions/11.8.2.js index 3e9909cb615..fc44dca5f88 100644 --- a/mozilla/js/tests/ecma/Expressions/11.8.2.js +++ b/mozilla/js/tests/ecma/Expressions/11.8.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,104 +35,85 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.8.2.js - ECMA Section: 11.8.2 The greater-than operator ( > ) - Description: + File Name: 11.8.2.js + ECMA Section: 11.8.2 The greater-than operator ( > ) + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.8.2"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.8.2"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The greater-than operator ( > )"); - test(); +writeHeaderToLog( SECTION + " The greater-than operator ( > )"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "true > false", true, true > false ); +new TestCase( SECTION, "false > true", false, false > true ); +new TestCase( SECTION, "false > false", false, false > false ); +new TestCase( SECTION, "true > true", false, true > true ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "new Boolean(true) > new Boolean(true)", false, new Boolean(true) > new Boolean(true) ); +new TestCase( SECTION, "new Boolean(true) > new Boolean(false)", true, new Boolean(true) > new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) > new Boolean(true)", false, new Boolean(false) > new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) > new Boolean(false)", false, new Boolean(false) > new Boolean(false) ); - array[item++] = new TestCase( SECTION, "true > false", true, true > false ); - array[item++] = new TestCase( SECTION, "false > true", false, false > true ); - array[item++] = new TestCase( SECTION, "false > false", false, false > false ); - array[item++] = new TestCase( SECTION, "true > true", false, true > true ); +new TestCase( SECTION, "new MyObject(Infinity) > new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) > new Boolean(true)", false, new Boolean(true) > new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) > new Boolean(false)", true, new Boolean(true) > new Boolean(false) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) > new Boolean(true)", false, new Boolean(false) > new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) > new Boolean(false)", false, new Boolean(false) > new Boolean(false) ); +new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(true)", false, new MyValueObject(false) > new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(true) > new MyValueObject(true)", false, new MyValueObject(true) > new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(false)", false, new MyValueObject(false) > new MyValueObject(false) ); - array[item++] = new TestCase( SECTION, "new MyObject(Infinity) > new MyObject(Infinity)", false, new MyObject( Number.POSITIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) > new MyObject(-Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) > new MyObject( Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(true)", false, new MyStringObject(false) > new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(true) > new MyStringObject(true)", false, new MyStringObject(true) > new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(false)", false, new MyStringObject(false) > new MyStringObject(false) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(true)", false, new MyValueObject(false) > new MyValueObject(true) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(true) > new MyValueObject(true)", false, new MyValueObject(true) > new MyValueObject(true) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(false) > new MyValueObject(false)", false, new MyValueObject(false) > new MyValueObject(false) ); +new TestCase( SECTION, "Number.NaN > Number.NaN", false, Number.NaN > Number.NaN ); +new TestCase( SECTION, "0 > Number.NaN", false, 0 > Number.NaN ); +new TestCase( SECTION, "Number.NaN > 0", false, Number.NaN > 0 ); - array[item++] = new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(true)", false, new MyStringObject(false) > new MyStringObject(true) ); - array[item++] = new TestCase( SECTION, "new MyStringObject(true) > new MyStringObject(true)", false, new MyStringObject(true) > new MyStringObject(true) ); - array[item++] = new TestCase( SECTION, "new MyStringObject(false) > new MyStringObject(false)", false, new MyStringObject(false) > new MyStringObject(false) ); +new TestCase( SECTION, "0 > -0", false, 0 > -0 ); +new TestCase( SECTION, "-0 > 0", false, -0 > 0 ); - array[item++] = new TestCase( SECTION, "Number.NaN > Number.NaN", false, Number.NaN > Number.NaN ); - array[item++] = new TestCase( SECTION, "0 > Number.NaN", false, 0 > Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NaN > 0", false, Number.NaN > 0 ); +new TestCase( SECTION, "Infinity > 0", true, Number.POSITIVE_INFINITY > 0 ); +new TestCase( SECTION, "Infinity > Number.MAX_VALUE", true, Number.POSITIVE_INFINITY > Number.MAX_VALUE ); +new TestCase( SECTION, "Infinity > Infinity", false, Number.POSITIVE_INFINITY > Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 > -0", false, 0 > -0 ); - array[item++] = new TestCase( SECTION, "-0 > 0", false, -0 > 0 ); +new TestCase( SECTION, "0 > Infinity", false, 0 > Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE > Infinity", false, Number.MAX_VALUE > Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Infinity > 0", true, Number.POSITIVE_INFINITY > 0 ); - array[item++] = new TestCase( SECTION, "Infinity > Number.MAX_VALUE", true, Number.POSITIVE_INFINITY > Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Infinity > Infinity", false, Number.POSITIVE_INFINITY > Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 > -Infinity", true, 0 > Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE > -Infinity", true, Number.MAX_VALUE > Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-Infinity > -Infinity", false, Number.NEGATIVE_INFINITY > Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 > Infinity", false, 0 > Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE > Infinity", false, Number.MAX_VALUE > Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Infinity > 0", false, Number.NEGATIVE_INFINITY > 0 ); +new TestCase( SECTION, "-Infinity > -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY > -Number.MAX_VALUE ); +new TestCase( SECTION, "-Infinity > Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY > Number.MIN_VALUE ); - array[item++] = new TestCase( SECTION, "0 > -Infinity", true, 0 > Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE > -Infinity", true, Number.MAX_VALUE > Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-Infinity > -Infinity", false, Number.NEGATIVE_INFINITY > Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); +new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); +new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); +new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); +new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); +new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); - array[item++] = new TestCase( SECTION, "-Infinity > 0", false, Number.NEGATIVE_INFINITY > 0 ); - array[item++] = new TestCase( SECTION, "-Infinity > -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY > -Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "-Infinity > Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY > Number.MIN_VALUE ); +test(); - array[item++] = new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); - array[item++] = new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); - array[item++] = new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); - array[item++] = new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); - array[item++] = new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); - array[item++] = new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); - - - return ( array ); -} function MyObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - this.toString = new Function( "return this.value +''" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); } function MyValueObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); } function MyStringObject(value) { - this.value = value; - this.toString = new Function( "return this.value +''" ); -} \ No newline at end of file + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/mozilla/js/tests/ecma/Expressions/11.8.3.js b/mozilla/js/tests/ecma/Expressions/11.8.3.js index 761f2587065..bebfc9e0be4 100644 --- a/mozilla/js/tests/ecma/Expressions/11.8.3.js +++ b/mozilla/js/tests/ecma/Expressions/11.8.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,102 +35,84 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.8.3.js - ECMA Section: 11.8.3 The less-than-or-equal operator ( <= ) - Description: + File Name: 11.8.3.js + ECMA Section: 11.8.3 The less-than-or-equal operator ( <= ) + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.8.1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.8.1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The less-than-or-equal operator ( <= )"); - test(); +writeHeaderToLog( SECTION + " The less-than-or-equal operator ( <= )"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "true <= false", false, true <= false ); +new TestCase( SECTION, "false <= true", true, false <= true ); +new TestCase( SECTION, "false <= false", true, false <= false ); +new TestCase( SECTION, "true <= true", true, true <= true ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "new Boolean(true) <= new Boolean(true)", true, new Boolean(true) <= new Boolean(true) ); +new TestCase( SECTION, "new Boolean(true) <= new Boolean(false)", false, new Boolean(true) <= new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) <= new Boolean(true)", true, new Boolean(false) <= new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) <= new Boolean(false)", true, new Boolean(false) <= new Boolean(false) ); - array[item++] = new TestCase( SECTION, "true <= false", false, true <= false ); - array[item++] = new TestCase( SECTION, "false <= true", true, false <= true ); - array[item++] = new TestCase( SECTION, "false <= false", true, false <= false ); - array[item++] = new TestCase( SECTION, "true <= true", true, true <= true ); +new TestCase( SECTION, "new MyObject(Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) <= new Boolean(true)", true, new Boolean(true) <= new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) <= new Boolean(false)", false, new Boolean(true) <= new Boolean(false) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) <= new Boolean(true)", true, new Boolean(false) <= new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) <= new Boolean(false)", true, new Boolean(false) <= new Boolean(false) ); +new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(true)", true, new MyValueObject(false) <= new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(true) <= new MyValueObject(true)", true, new MyValueObject(true) <= new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(false)", true, new MyValueObject(false) <= new MyValueObject(false) ); - array[item++] = new TestCase( SECTION, "new MyObject(Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) <= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) <= new MyObject( Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(true)", true, new MyStringObject(false) <= new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(true) <= new MyStringObject(true)", true, new MyStringObject(true) <= new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(false)", true, new MyStringObject(false) <= new MyStringObject(false) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(true)", true, new MyValueObject(false) <= new MyValueObject(true) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(true) <= new MyValueObject(true)", true, new MyValueObject(true) <= new MyValueObject(true) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(false) <= new MyValueObject(false)", true, new MyValueObject(false) <= new MyValueObject(false) ); +new TestCase( SECTION, "Number.NaN <= Number.NaN", false, Number.NaN <= Number.NaN ); +new TestCase( SECTION, "0 <= Number.NaN", false, 0 <= Number.NaN ); +new TestCase( SECTION, "Number.NaN <= 0", false, Number.NaN <= 0 ); - array[item++] = new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(true)", true, new MyStringObject(false) <= new MyStringObject(true) ); - array[item++] = new TestCase( SECTION, "new MyStringObject(true) <= new MyStringObject(true)", true, new MyStringObject(true) <= new MyStringObject(true) ); - array[item++] = new TestCase( SECTION, "new MyStringObject(false) <= new MyStringObject(false)", true, new MyStringObject(false) <= new MyStringObject(false) ); +new TestCase( SECTION, "0 <= -0", true, 0 <= -0 ); +new TestCase( SECTION, "-0 <= 0", true, -0 <= 0 ); - array[item++] = new TestCase( SECTION, "Number.NaN <= Number.NaN", false, Number.NaN <= Number.NaN ); - array[item++] = new TestCase( SECTION, "0 <= Number.NaN", false, 0 <= Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NaN <= 0", false, Number.NaN <= 0 ); +new TestCase( SECTION, "Infinity <= 0", false, Number.POSITIVE_INFINITY <= 0 ); +new TestCase( SECTION, "Infinity <= Number.MAX_VALUE", false, Number.POSITIVE_INFINITY <= Number.MAX_VALUE ); +new TestCase( SECTION, "Infinity <= Infinity", true, Number.POSITIVE_INFINITY <= Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 <= -0", true, 0 <= -0 ); - array[item++] = new TestCase( SECTION, "-0 <= 0", true, -0 <= 0 ); +new TestCase( SECTION, "0 <= Infinity", true, 0 <= Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE <= Infinity", true, Number.MAX_VALUE <= Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Infinity <= 0", false, Number.POSITIVE_INFINITY <= 0 ); - array[item++] = new TestCase( SECTION, "Infinity <= Number.MAX_VALUE", false, Number.POSITIVE_INFINITY <= Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Infinity <= Infinity", true, Number.POSITIVE_INFINITY <= Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 <= -Infinity", false, 0 <= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE <= -Infinity", false, Number.MAX_VALUE <= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-Infinity <= -Infinity", true, Number.NEGATIVE_INFINITY <= Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 <= Infinity", true, 0 <= Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE <= Infinity", true, Number.MAX_VALUE <= Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Infinity <= 0", true, Number.NEGATIVE_INFINITY <= 0 ); +new TestCase( SECTION, "-Infinity <= -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY <= -Number.MAX_VALUE ); +new TestCase( SECTION, "-Infinity <= Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY <= Number.MIN_VALUE ); - array[item++] = new TestCase( SECTION, "0 <= -Infinity", false, 0 <= Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE <= -Infinity", false, Number.MAX_VALUE <= Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-Infinity <= -Infinity", true, Number.NEGATIVE_INFINITY <= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "'string' <= 'string'", true, 'string' <= 'string' ); +new TestCase( SECTION, "'astring' <= 'string'", true, 'astring' <= 'string' ); +new TestCase( SECTION, "'strings' <= 'stringy'", true, 'strings' <= 'stringy' ); +new TestCase( SECTION, "'strings' <= 'stringier'", false, 'strings' <= 'stringier' ); +new TestCase( SECTION, "'string' <= 'astring'", false, 'string' <= 'astring' ); +new TestCase( SECTION, "'string' <= 'strings'", true, 'string' <= 'strings' ); - array[item++] = new TestCase( SECTION, "-Infinity <= 0", true, Number.NEGATIVE_INFINITY <= 0 ); - array[item++] = new TestCase( SECTION, "-Infinity <= -Number.MAX_VALUE", true, Number.NEGATIVE_INFINITY <= -Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "-Infinity <= Number.MIN_VALUE", true, Number.NEGATIVE_INFINITY <= Number.MIN_VALUE ); +test(); - array[item++] = new TestCase( SECTION, "'string' <= 'string'", true, 'string' <= 'string' ); - array[item++] = new TestCase( SECTION, "'astring' <= 'string'", true, 'astring' <= 'string' ); - array[item++] = new TestCase( SECTION, "'strings' <= 'stringy'", true, 'strings' <= 'stringy' ); - array[item++] = new TestCase( SECTION, "'strings' <= 'stringier'", false, 'strings' <= 'stringier' ); - array[item++] = new TestCase( SECTION, "'string' <= 'astring'", false, 'string' <= 'astring' ); - array[item++] = new TestCase( SECTION, "'string' <= 'strings'", true, 'string' <= 'strings' ); - - return ( array ); -} function MyObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - this.toString = new Function( "return this.value +''" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); } function MyValueObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); } function MyStringObject(value) { - this.value = value; - this.toString = new Function( "return this.value +''" ); + this.value = value; + this.toString = new Function( "return this.value +''" ); } diff --git a/mozilla/js/tests/ecma/Expressions/11.8.4.js b/mozilla/js/tests/ecma/Expressions/11.8.4.js index f8aa977d624..59b3673b514 100644 --- a/mozilla/js/tests/ecma/Expressions/11.8.4.js +++ b/mozilla/js/tests/ecma/Expressions/11.8.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,104 +35,85 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.8.4.js - ECMA Section: 11.8.4 The greater-than-or-equal operator ( >= ) - Description: + File Name: 11.8.4.js + ECMA Section: 11.8.4 The greater-than-or-equal operator ( >= ) + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.8.4"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "11.8.4"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The greater-than-or-equal operator ( >= )"); - test(); +writeHeaderToLog( SECTION + " The greater-than-or-equal operator ( >= )"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "true >= false", true, true >= false ); +new TestCase( SECTION, "false >= true", false, false >= true ); +new TestCase( SECTION, "false >= false", true, false >= false ); +new TestCase( SECTION, "true >= true", true, true >= true ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "new Boolean(true) >= new Boolean(true)", true, new Boolean(true) >= new Boolean(true) ); +new TestCase( SECTION, "new Boolean(true) >= new Boolean(false)", true, new Boolean(true) >= new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) >= new Boolean(true)", false, new Boolean(false) >= new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) >= new Boolean(false)", true, new Boolean(false) >= new Boolean(false) ); - array[item++] = new TestCase( SECTION, "true >= false", true, true >= false ); - array[item++] = new TestCase( SECTION, "false >= true", false, false >= true ); - array[item++] = new TestCase( SECTION, "false >= false", true, false >= false ); - array[item++] = new TestCase( SECTION, "true >= true", true, true >= true ); +new TestCase( SECTION, "new MyObject(Infinity) >= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) >= new Boolean(true)", true, new Boolean(true) >= new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) >= new Boolean(false)", true, new Boolean(true) >= new Boolean(false) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) >= new Boolean(true)", false, new Boolean(false) >= new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) >= new Boolean(false)", true, new Boolean(false) >= new Boolean(false) ); +new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(true)", false, new MyValueObject(false) >= new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(true) >= new MyValueObject(true)", true, new MyValueObject(true) >= new MyValueObject(true) ); +new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(false)", true, new MyValueObject(false) >= new MyValueObject(false) ); - array[item++] = new TestCase( SECTION, "new MyObject(Infinity) >= new MyObject(Infinity)", true, new MyObject( Number.POSITIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(Infinity)", false, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "new MyObject(-Infinity) >= new MyObject(-Infinity)", true, new MyObject( Number.NEGATIVE_INFINITY ) >= new MyObject( Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(true)", false, new MyStringObject(false) >= new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(true) >= new MyStringObject(true)", true, new MyStringObject(true) >= new MyStringObject(true) ); +new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(false)", true, new MyStringObject(false) >= new MyStringObject(false) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(true)", false, new MyValueObject(false) >= new MyValueObject(true) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(true) >= new MyValueObject(true)", true, new MyValueObject(true) >= new MyValueObject(true) ); - array[item++] = new TestCase( SECTION, "new MyValueObject(false) >= new MyValueObject(false)", true, new MyValueObject(false) >= new MyValueObject(false) ); +new TestCase( SECTION, "Number.NaN >= Number.NaN", false, Number.NaN >= Number.NaN ); +new TestCase( SECTION, "0 >= Number.NaN", false, 0 >= Number.NaN ); +new TestCase( SECTION, "Number.NaN >= 0", false, Number.NaN >= 0 ); - array[item++] = new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(true)", false, new MyStringObject(false) >= new MyStringObject(true) ); - array[item++] = new TestCase( SECTION, "new MyStringObject(true) >= new MyStringObject(true)", true, new MyStringObject(true) >= new MyStringObject(true) ); - array[item++] = new TestCase( SECTION, "new MyStringObject(false) >= new MyStringObject(false)", true, new MyStringObject(false) >= new MyStringObject(false) ); +new TestCase( SECTION, "0 >= -0", true, 0 >= -0 ); +new TestCase( SECTION, "-0 >= 0", true, -0 >= 0 ); - array[item++] = new TestCase( SECTION, "Number.NaN >= Number.NaN", false, Number.NaN >= Number.NaN ); - array[item++] = new TestCase( SECTION, "0 >= Number.NaN", false, 0 >= Number.NaN ); - array[item++] = new TestCase( SECTION, "Number.NaN >= 0", false, Number.NaN >= 0 ); +new TestCase( SECTION, "Infinity >= 0", true, Number.POSITIVE_INFINITY >= 0 ); +new TestCase( SECTION, "Infinity >= Number.MAX_VALUE", true, Number.POSITIVE_INFINITY >= Number.MAX_VALUE ); +new TestCase( SECTION, "Infinity >= Infinity", true, Number.POSITIVE_INFINITY >= Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 >= -0", true, 0 >= -0 ); - array[item++] = new TestCase( SECTION, "-0 >= 0", true, -0 >= 0 ); +new TestCase( SECTION, "0 >= Infinity", false, 0 >= Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE >= Infinity", false, Number.MAX_VALUE >= Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Infinity >= 0", true, Number.POSITIVE_INFINITY >= 0 ); - array[item++] = new TestCase( SECTION, "Infinity >= Number.MAX_VALUE", true, Number.POSITIVE_INFINITY >= Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Infinity >= Infinity", true, Number.POSITIVE_INFINITY >= Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "0 >= -Infinity", true, 0 >= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "Number.MAX_VALUE >= -Infinity", true, Number.MAX_VALUE >= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "-Infinity >= -Infinity", true, Number.NEGATIVE_INFINITY >= Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "0 >= Infinity", false, 0 >= Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE >= Infinity", false, Number.MAX_VALUE >= Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "-Infinity >= 0", false, Number.NEGATIVE_INFINITY >= 0 ); +new TestCase( SECTION, "-Infinity >= -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY >= -Number.MAX_VALUE ); +new TestCase( SECTION, "-Infinity >= Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY >= Number.MIN_VALUE ); - array[item++] = new TestCase( SECTION, "0 >= -Infinity", true, 0 >= Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE >= -Infinity", true, Number.MAX_VALUE >= Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "-Infinity >= -Infinity", true, Number.NEGATIVE_INFINITY >= Number.NEGATIVE_INFINITY ); +new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); +new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); +new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); +new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); +new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); +new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); - array[item++] = new TestCase( SECTION, "-Infinity >= 0", false, Number.NEGATIVE_INFINITY >= 0 ); - array[item++] = new TestCase( SECTION, "-Infinity >= -Number.MAX_VALUE", false, Number.NEGATIVE_INFINITY >= -Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "-Infinity >= Number.MIN_VALUE", false, Number.NEGATIVE_INFINITY >= Number.MIN_VALUE ); +test(); - array[item++] = new TestCase( SECTION, "'string' > 'string'", false, 'string' > 'string' ); - array[item++] = new TestCase( SECTION, "'astring' > 'string'", false, 'astring' > 'string' ); - array[item++] = new TestCase( SECTION, "'strings' > 'stringy'", false, 'strings' > 'stringy' ); - array[item++] = new TestCase( SECTION, "'strings' > 'stringier'", true, 'strings' > 'stringier' ); - array[item++] = new TestCase( SECTION, "'string' > 'astring'", true, 'string' > 'astring' ); - array[item++] = new TestCase( SECTION, "'string' > 'strings'", false, 'string' > 'strings' ); - - - return ( array ); -} function MyObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - this.toString = new Function( "return this.value +''" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = new Function( "return this.value +''" ); } function MyValueObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); } function MyStringObject(value) { - this.value = value; - this.toString = new Function( "return this.value +''" ); -} \ No newline at end of file + this.value = value; + this.toString = new Function( "return this.value +''" ); +} diff --git a/mozilla/js/tests/ecma/Expressions/11.9.1.js b/mozilla/js/tests/ecma/Expressions/11.9.1.js index 07b04635e3c..759cc796a04 100644 --- a/mozilla/js/tests/ecma/Expressions/11.9.1.js +++ b/mozilla/js/tests/ecma/Expressions/11.9.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,144 +35,123 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.9.1.js - ECMA Section: 11.9.1 The equals operator ( == ) - Description: + File Name: 11.9.1.js + ECMA Section: 11.9.1 The equals operator ( == ) + Description: - The production EqualityExpression: - EqualityExpression == RelationalExpression is evaluated as follows: + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: - 1. Evaluate EqualityExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate RelationalExpression. - 4. Call GetValue(Result(3)). - 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) - 6. Return Result(5). - Author: christine@netscape.com - Date: 12 november 1997 + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.9.1"; - var VERSION = "ECMA_1"; - startTest(); - var BUGNUMBER="77391"; +var SECTION = "11.9.1"; +var VERSION = "ECMA_1"; +startTest(); +var BUGNUMBER="77391"; + +writeHeaderToLog( SECTION + " The equals operator ( == )"); + +// type x and type y are the same. if type x is undefined or null, return true + +new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); +new TestCase( SECTION, "null == null", true, null == null ); + +// if x is NaN, return false. if y is NaN, return false. + +new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); +new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); +new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); +new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); + +// if x is the same number value as y, return true. + +new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); +new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); + +// if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. + +new TestCase( SECTION, "0 == 0", true, 0 == 0 ); +new TestCase( SECTION, "0 == -0", true, 0 == -0 ); +new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); +new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); + +// return false. + +new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); +new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); +new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); +new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); + +// type x and type y are the same type, but not numbers. - var testcases = getTestCases(); +// x and y are strings. return true if x and y are exactly the same sequence of characters. +// otherwise, return false. - writeHeaderToLog( SECTION + " The equals operator ( == )"); - test(); +new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// x and y are booleans. return true if both are true or both are false. - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "true == true", true, true == true ); +new TestCase( SECTION, "false == false", true, false == false ); +new TestCase( SECTION, "true == false", false, true == false ); +new TestCase( SECTION, "false == true", false, false == true ); - // type x and type y are the same. if type x is undefined or null, return true +// return true if x and y refer to the same object. otherwise return false. - array[item++] = new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); - array[item++] = new TestCase( SECTION, "null == null", true, null == null ); - - // if x is NaN, return false. if y is NaN, return false. - - array[item++] = new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); - array[item++] = new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); - array[item++] = new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); - array[item++] = new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); - - // if x is the same number value as y, return true. - - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); - - // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. - - array[item++] = new TestCase( SECTION, "0 == 0", true, 0 == 0 ); - array[item++] = new TestCase( SECTION, "0 == -0", true, 0 == -0 ); - array[item++] = new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); - array[item++] = new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); - - // return false. - - array[item++] = new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); - array[item++] = new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); - array[item++] = new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); - array[item++] = new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); - - // type x and type y are the same type, but not numbers. +new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); +new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); - // x and y are strings. return true if x and y are exactly the same sequence of characters. - // otherwise, return false. +new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); - array[item++] = new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); +new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); - // x and y are booleans. return true if both are true or both are false. +// if x is null and y is undefined, return true. if x is undefined and y is null return true. - array[item++] = new TestCase( SECTION, "true == true", true, true == true ); - array[item++] = new TestCase( SECTION, "false == false", true, false == false ); - array[item++] = new TestCase( SECTION, "true == false", false, true == false ); - array[item++] = new TestCase( SECTION, "false == true", false, false == true ); +new TestCase( SECTION, "null == void 0", true, null == void 0 ); +new TestCase( SECTION, "void 0 == null", true, void 0 == null ); - // return true if x and y refer to the same object. otherwise return false. +// if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). - array[item++] = new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); +new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); +new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); +new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); +new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); - array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); - array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); +new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); +new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); +new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); +new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); - // if x is null and y is undefined, return true. if x is undefined and y is null return true. +new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); +new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); - array[item++] = new TestCase( SECTION, "null == void 0", true, null == void 0 ); - array[item++] = new TestCase( SECTION, "void 0 == null", true, void 0 == null ); +new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); +new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); - // if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). - - array[item++] = new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); - array[item++] = new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); - array[item++] = new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); - array[item++] = new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); - - - array[item++] = new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); - - array[item++] = new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); - array[item++] = new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); - - array[item++] = new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); - array[item++] = new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); - - array[item++] = new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); - array[item++] = new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); - - return ( array ); -} +test(); function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); -} \ No newline at end of file + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/mozilla/js/tests/ecma/Expressions/11.9.2.js b/mozilla/js/tests/ecma/Expressions/11.9.2.js index 36ddbd1399e..482d1518421 100644 --- a/mozilla/js/tests/ecma/Expressions/11.9.2.js +++ b/mozilla/js/tests/ecma/Expressions/11.9.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,143 +35,123 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.9.2.js - ECMA Section: 11.9.2 The equals operator ( == ) - Description: + File Name: 11.9.2.js + ECMA Section: 11.9.2 The equals operator ( == ) + Description: - The production EqualityExpression: - EqualityExpression == RelationalExpression is evaluated as follows: + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: - 1. Evaluate EqualityExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate RelationalExpression. - 4. Call GetValue(Result(3)). - 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) - 6. Return Result(5). - Author: christine@netscape.com - Date: 12 november 1997 + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.9.2"; - var VERSION = "ECMA_1"; - startTest(); - var BUGNUMBER="77391"; +var SECTION = "11.9.2"; +var VERSION = "ECMA_1"; +startTest(); +var BUGNUMBER="77391"; - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " The equals operator ( == )"); - writeHeaderToLog( SECTION + " The equals operator ( == )"); - test(); +// type x and type y are the same. if type x is undefined or null, return true -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "void 0 == void 0", false, void 0 != void 0 ); +new TestCase( SECTION, "null == null", false, null != null ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +// if x is NaN, return false. if y is NaN, return false. - // type x and type y are the same. if type x is undefined or null, return true +new TestCase( SECTION, "NaN != NaN", true, Number.NaN != Number.NaN ); +new TestCase( SECTION, "NaN != 0", true, Number.NaN != 0 ); +new TestCase( SECTION, "0 != NaN", true, 0 != Number.NaN ); +new TestCase( SECTION, "NaN != Infinity", true, Number.NaN != Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Infinity != NaN", true, Number.POSITIVE_INFINITY != Number.NaN ); - array[item++] = new TestCase( SECTION, "void 0 == void 0", false, void 0 != void 0 ); - array[item++] = new TestCase( SECTION, "null == null", false, null != null ); +// if x is the same number value as y, return true. - // if x is NaN, return false. if y is NaN, return false. +new TestCase( SECTION, "Number.MAX_VALUE != Number.MAX_VALUE", false, Number.MAX_VALUE != Number.MAX_VALUE ); +new TestCase( SECTION, "Number.MIN_VALUE != Number.MIN_VALUE", false, Number.MIN_VALUE != Number.MIN_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY", false, Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY", false, Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "NaN != NaN", true, Number.NaN != Number.NaN ); - array[item++] = new TestCase( SECTION, "NaN != 0", true, Number.NaN != 0 ); - array[item++] = new TestCase( SECTION, "0 != NaN", true, 0 != Number.NaN ); - array[item++] = new TestCase( SECTION, "NaN != Infinity", true, Number.NaN != Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Infinity != NaN", true, Number.POSITIVE_INFINITY != Number.NaN ); +// if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. - // if x is the same number value as y, return true. +new TestCase( SECTION, "0 != 0", false, 0 != 0 ); +new TestCase( SECTION, "0 != -0", false, 0 != -0 ); +new TestCase( SECTION, "-0 != 0", false, -0 != 0 ); +new TestCase( SECTION, "-0 != -0", false, -0 != -0 ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE != Number.MAX_VALUE", false, Number.MAX_VALUE != Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.MIN_VALUE != Number.MIN_VALUE", false, Number.MIN_VALUE != Number.MIN_VALUE ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY", false, Number.POSITIVE_INFINITY != Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY", false, Number.NEGATIVE_INFINITY != Number.NEGATIVE_INFINITY ); +// return false. - // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. +new TestCase( SECTION, "0.9 != 1", true, 0.9 != 1 ); +new TestCase( SECTION, "0.999999 != 1", true, 0.999999 != 1 ); +new TestCase( SECTION, "0.9999999999 != 1", true, 0.9999999999 != 1 ); +new TestCase( SECTION, "0.9999999999999 != 1", true, 0.9999999999999 != 1 ); - array[item++] = new TestCase( SECTION, "0 != 0", false, 0 != 0 ); - array[item++] = new TestCase( SECTION, "0 != -0", false, 0 != -0 ); - array[item++] = new TestCase( SECTION, "-0 != 0", false, -0 != 0 ); - array[item++] = new TestCase( SECTION, "-0 != -0", false, -0 != -0 ); - - // return false. - - array[item++] = new TestCase( SECTION, "0.9 != 1", true, 0.9 != 1 ); - array[item++] = new TestCase( SECTION, "0.999999 != 1", true, 0.999999 != 1 ); - array[item++] = new TestCase( SECTION, "0.9999999999 != 1", true, 0.9999999999 != 1 ); - array[item++] = new TestCase( SECTION, "0.9999999999999 != 1", true, 0.9999999999999 != 1 ); - - // type x and type y are the same type, but not numbers. +// type x and type y are the same type, but not numbers. - // x and y are strings. return true if x and y are exactly the same sequence of characters. - // otherwise, return false. +// x and y are strings. return true if x and y are exactly the same sequence of characters. +// otherwise, return false. - array[item++] = new TestCase( SECTION, "'hello' != 'hello'", false, "hello" != "hello" ); +new TestCase( SECTION, "'hello' != 'hello'", false, "hello" != "hello" ); - // x and y are booleans. return true if both are true or both are false. +// x and y are booleans. return true if both are true or both are false. - array[item++] = new TestCase( SECTION, "true != true", false, true != true ); - array[item++] = new TestCase( SECTION, "false != false", false, false != false ); - array[item++] = new TestCase( SECTION, "true != false", true, true != false ); - array[item++] = new TestCase( SECTION, "false != true", true, false != true ); +new TestCase( SECTION, "true != true", false, true != true ); +new TestCase( SECTION, "false != false", false, false != false ); +new TestCase( SECTION, "true != false", true, true != false ); +new TestCase( SECTION, "false != true", true, false != true ); - // return true if x and y refer to the same object. otherwise return false. +// return true if x and y refer to the same object. otherwise return false. - array[item++] = new TestCase( SECTION, "new MyObject(true) != new MyObject(true)", true, new MyObject(true) != new MyObject(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); +new TestCase( SECTION, "new MyObject(true) != new MyObject(true)", true, new MyObject(true) != new MyObject(true) ); +new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); - array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z != y", false, eval("x = new MyObject(true); y = x; z = x; z != y") ); - array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z != y", false, eval("x = new MyObject(false); y = x; z = x; z != y") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z != y", false, eval("x = new Boolean(true); y = x; z = x; z != y") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z != y", false, eval("x = new Boolean(false); y = x; z = x; z != y") ); +new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z != y", false, eval("x = new MyObject(true); y = x; z = x; z != y") ); +new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z != y", false, eval("x = new MyObject(false); y = x; z = x; z != y") ); +new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z != y", false, eval("x = new Boolean(true); y = x; z = x; z != y") ); +new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z != y", false, eval("x = new Boolean(false); y = x; z = x; z != y") ); - array[item++] = new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); +new TestCase( SECTION, "new Boolean(true) != new Boolean(true)", true, new Boolean(true) != new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) != new Boolean(false)", true, new Boolean(false) != new Boolean(false) ); - // if x is null and y is undefined, return true. if x is undefined and y is null return true. +// if x is null and y is undefined, return true. if x is undefined and y is null return true. - array[item++] = new TestCase( SECTION, "null != void 0", false, null != void 0 ); - array[item++] = new TestCase( SECTION, "void 0 != null", false, void 0 != null ); +new TestCase( SECTION, "null != void 0", false, null != void 0 ); +new TestCase( SECTION, "void 0 != null", false, void 0 != null ); - // if type(x) is Number and type(y) is string, return the result of the comparison x != ToNumber(y). +// if type(x) is Number and type(y) is string, return the result of the comparison x != ToNumber(y). - array[item++] = new TestCase( SECTION, "1 != '1'", false, 1 != '1' ); - array[item++] = new TestCase( SECTION, "255 != '0xff'", false, 255 != '0xff' ); - array[item++] = new TestCase( SECTION, "0 != '\r'", false, 0 != "\r" ); - array[item++] = new TestCase( SECTION, "1e19 != '1e19'", false, 1e19 != "1e19" ); +new TestCase( SECTION, "1 != '1'", false, 1 != '1' ); +new TestCase( SECTION, "255 != '0xff'", false, 255 != '0xff' ); +new TestCase( SECTION, "0 != '\r'", false, 0 != "\r" ); +new TestCase( SECTION, "1e19 != '1e19'", false, 1e19 != "1e19" ); - array[item++] = new TestCase( SECTION, "new Boolean(true) != true", false, true != new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new MyObject(true) != true", false, true != new MyObject(true) ); +new TestCase( SECTION, "new Boolean(true) != true", false, true != new Boolean(true) ); +new TestCase( SECTION, "new MyObject(true) != true", false, true != new MyObject(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) != false", false, new Boolean(false) != false ); - array[item++] = new TestCase( SECTION, "new MyObject(false) != false", false, new MyObject(false) != false ); +new TestCase( SECTION, "new Boolean(false) != false", false, new Boolean(false) != false ); +new TestCase( SECTION, "new MyObject(false) != false", false, new MyObject(false) != false ); - array[item++] = new TestCase( SECTION, "true != new Boolean(true)", false, true != new Boolean(true) ); - array[item++] = new TestCase( SECTION, "true != new MyObject(true)", false, true != new MyObject(true) ); +new TestCase( SECTION, "true != new Boolean(true)", false, true != new Boolean(true) ); +new TestCase( SECTION, "true != new MyObject(true)", false, true != new MyObject(true) ); - array[item++] = new TestCase( SECTION, "false != new Boolean(false)", false, false != new Boolean(false) ); - array[item++] = new TestCase( SECTION, "false != new MyObject(false)", false, false != new MyObject(false) ); +new TestCase( SECTION, "false != new Boolean(false)", false, false != new Boolean(false) ); +new TestCase( SECTION, "false != new MyObject(false)", false, false != new MyObject(false) ); - return ( array ); -} +test(); function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); -} \ No newline at end of file + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/mozilla/js/tests/ecma/Expressions/11.9.3.js b/mozilla/js/tests/ecma/Expressions/11.9.3.js index 2d3ef9ad8eb..35751d71c2a 100644 --- a/mozilla/js/tests/ecma/Expressions/11.9.3.js +++ b/mozilla/js/tests/ecma/Expressions/11.9.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,143 +35,123 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 11.9.3.js - ECMA Section: 11.9.3 The equals operator ( == ) - Description: + File Name: 11.9.3.js + ECMA Section: 11.9.3 The equals operator ( == ) + Description: - The production EqualityExpression: - EqualityExpression == RelationalExpression is evaluated as follows: + The production EqualityExpression: + EqualityExpression == RelationalExpression is evaluated as follows: - 1. Evaluate EqualityExpression. - 2. Call GetValue(Result(1)). - 3. Evaluate RelationalExpression. - 4. Call GetValue(Result(3)). - 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) - 6. Return Result(5). - Author: christine@netscape.com - Date: 12 november 1997 + 1. Evaluate EqualityExpression. + 2. Call GetValue(Result(1)). + 3. Evaluate RelationalExpression. + 4. Call GetValue(Result(3)). + 5. Perform the comparison Result(4) == Result(2). (See section 11.9.3) + 6. Return Result(5). + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "11.9.3"; - var VERSION = "ECMA_1"; - startTest(); - var BUGNUMBER="77391"; +var SECTION = "11.9.3"; +var VERSION = "ECMA_1"; +startTest(); +var BUGNUMBER="77391"; - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " The equals operator ( == )"); - writeHeaderToLog( SECTION + " The equals operator ( == )"); - test(); +// type x and type y are the same. if type x is undefined or null, return true -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); +new TestCase( SECTION, "null == null", true, null == null ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +// if x is NaN, return false. if y is NaN, return false. - // type x and type y are the same. if type x is undefined or null, return true +new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); +new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); +new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); +new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); - array[item++] = new TestCase( SECTION, "void 0 = void 0", true, void 0 == void 0 ); - array[item++] = new TestCase( SECTION, "null == null", true, null == null ); +// if x is the same number value as y, return true. - // if x is NaN, return false. if y is NaN, return false. +new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); +new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "NaN == NaN", false, Number.NaN == Number.NaN ); - array[item++] = new TestCase( SECTION, "NaN == 0", false, Number.NaN == 0 ); - array[item++] = new TestCase( SECTION, "0 == NaN", false, 0 == Number.NaN ); - array[item++] = new TestCase( SECTION, "NaN == Infinity", false, Number.NaN == Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Infinity == NaN", false, Number.POSITIVE_INFINITY == Number.NaN ); +// if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. - // if x is the same number value as y, return true. +new TestCase( SECTION, "0 == 0", true, 0 == 0 ); +new TestCase( SECTION, "0 == -0", true, 0 == -0 ); +new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); +new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE == Number.MAX_VALUE", true, Number.MAX_VALUE == Number.MAX_VALUE ); - array[item++] = new TestCase( SECTION, "Number.MIN_VALUE == Number.MIN_VALUE", true, Number.MIN_VALUE == Number.MIN_VALUE ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY", true, Number.POSITIVE_INFINITY == Number.POSITIVE_INFINITY ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY", true, Number.NEGATIVE_INFINITY == Number.NEGATIVE_INFINITY ); +// return false. - // if xis 0 and y is -0, return true. if x is -0 and y is 0, return true. +new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); +new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); +new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); +new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); - array[item++] = new TestCase( SECTION, "0 == 0", true, 0 == 0 ); - array[item++] = new TestCase( SECTION, "0 == -0", true, 0 == -0 ); - array[item++] = new TestCase( SECTION, "-0 == 0", true, -0 == 0 ); - array[item++] = new TestCase( SECTION, "-0 == -0", true, -0 == -0 ); - - // return false. - - array[item++] = new TestCase( SECTION, "0.9 == 1", false, 0.9 == 1 ); - array[item++] = new TestCase( SECTION, "0.999999 == 1", false, 0.999999 == 1 ); - array[item++] = new TestCase( SECTION, "0.9999999999 == 1", false, 0.9999999999 == 1 ); - array[item++] = new TestCase( SECTION, "0.9999999999999 == 1", false, 0.9999999999999 == 1 ); - - // type x and type y are the same type, but not numbers. +// type x and type y are the same type, but not numbers. - // x and y are strings. return true if x and y are exactly the same sequence of characters. - // otherwise, return false. +// x and y are strings. return true if x and y are exactly the same sequence of characters. +// otherwise, return false. - array[item++] = new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); +new TestCase( SECTION, "'hello' == 'hello'", true, "hello" == "hello" ); - // x and y are booleans. return true if both are true or both are false. +// x and y are booleans. return true if both are true or both are false. - array[item++] = new TestCase( SECTION, "true == true", true, true == true ); - array[item++] = new TestCase( SECTION, "false == false", true, false == false ); - array[item++] = new TestCase( SECTION, "true == false", false, true == false ); - array[item++] = new TestCase( SECTION, "false == true", false, false == true ); +new TestCase( SECTION, "true == true", true, true == true ); +new TestCase( SECTION, "false == false", true, false == false ); +new TestCase( SECTION, "true == false", false, true == false ); +new TestCase( SECTION, "false == true", false, false == true ); - // return true if x and y refer to the same object. otherwise return false. +// return true if x and y refer to the same object. otherwise return false. - array[item++] = new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); +new TestCase( SECTION, "new MyObject(true) == new MyObject(true)", false, new MyObject(true) == new MyObject(true) ); +new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); - array[item++] = new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); - array[item++] = new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new MyObject(true); y = x; z = x; z == y", true, eval("x = new MyObject(true); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new MyObject(false); y = x; z = x; z == y", true, eval("x = new MyObject(false); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new Boolean(true); y = x; z = x; z == y", true, eval("x = new Boolean(true); y = x; z = x; z == y") ); +new TestCase( SECTION, "x = new Boolean(false); y = x; z = x; z == y", true, eval("x = new Boolean(false); y = x; z = x; z == y") ); - array[item++] = new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); +new TestCase( SECTION, "new Boolean(true) == new Boolean(true)", false, new Boolean(true) == new Boolean(true) ); +new TestCase( SECTION, "new Boolean(false) == new Boolean(false)", false, new Boolean(false) == new Boolean(false) ); - // if x is null and y is undefined, return true. if x is undefined and y is null return true. +// if x is null and y is undefined, return true. if x is undefined and y is null return true. - array[item++] = new TestCase( SECTION, "null == void 0", true, null == void 0 ); - array[item++] = new TestCase( SECTION, "void 0 == null", true, void 0 == null ); +new TestCase( SECTION, "null == void 0", true, null == void 0 ); +new TestCase( SECTION, "void 0 == null", true, void 0 == null ); - // if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). +// if type(x) is Number and type(y) is string, return the result of the comparison x == ToNumber(y). - array[item++] = new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); - array[item++] = new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); - array[item++] = new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); - array[item++] = new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); +new TestCase( SECTION, "1 == '1'", true, 1 == '1' ); +new TestCase( SECTION, "255 == '0xff'", true, 255 == '0xff' ); +new TestCase( SECTION, "0 == '\r'", true, 0 == "\r" ); +new TestCase( SECTION, "1e19 == '1e19'", true, 1e19 == "1e19" ); - array[item++] = new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); - array[item++] = new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); +new TestCase( SECTION, "new Boolean(true) == true", true, true == new Boolean(true) ); +new TestCase( SECTION, "new MyObject(true) == true", true, true == new MyObject(true) ); - array[item++] = new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); - array[item++] = new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); +new TestCase( SECTION, "new Boolean(false) == false", true, new Boolean(false) == false ); +new TestCase( SECTION, "new MyObject(false) == false", true, new MyObject(false) == false ); - array[item++] = new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); - array[item++] = new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); +new TestCase( SECTION, "true == new Boolean(true)", true, true == new Boolean(true) ); +new TestCase( SECTION, "true == new MyObject(true)", true, true == new MyObject(true) ); - array[item++] = new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); - array[item++] = new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); +new TestCase( SECTION, "false == new Boolean(false)", true, false == new Boolean(false) ); +new TestCase( SECTION, "false == new MyObject(false)", true, false == new MyObject(false) ); - return ( array ); -} +test(); function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); -} \ No newline at end of file + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/mozilla/js/tests/ecma/Expressions/browser.js b/mozilla/js/tests/ecma/Expressions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Expressions/shell.js b/mozilla/js/tests/ecma/Expressions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-1.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-1.js index d8ce56085aa..4f5ab9872cf 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-1.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,105 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.1.1.js - ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + File Name: 15.3.1.1.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function - Description: - When the Function function is called with some arguments p1, p2, . . . , pn, body - (where n might be 0, that is, there are no "p" arguments, and where body might - also not be provided), the following steps are taken: + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, body + (where n might be 0, that is, there are no "p" arguments, and where body might + also not be provided), the following steps are taken: - 1. Create and return a new Function object exactly if the function constructor had - been called with the same arguments (15.3.2.1). + 1. Create and return a new Function object exactly if the function constructor had + been called with the same arguments (15.3.2.1). - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.1.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Function Constructor Called as a Function"; +var SECTION = "15.3.1.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" ); +var MyObject = Function( "value", "this.value = value; this.valueOf = Function( 'return this.value' ); this.toString = Function( 'return String(this.value);' )" ); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - - var myfunc = Function(); - myfunc.toString = Object.prototype.toString; +var myfunc = Function(); +myfunc.toString = Object.prototype.toString; // not going to test toString here since it is implementation dependent. -// array[item++] = new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); +// new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + +myfunc.toString = Object.prototype.toString; +new TestCase( SECTION, + "myfunc = Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + +new TestCase( SECTION, + "myfunc.length", + 0, + myfunc.length ); + +new TestCase( SECTION, + "myfunc.prototype.toString()", + "[object Object]", + myfunc.prototype.toString() ); + +new TestCase( SECTION, + "myfunc.prototype.constructor", + myfunc, + myfunc.prototype.constructor ); + +new TestCase( SECTION, + "myfunc.arguments", + null, + myfunc.arguments ); + +new TestCase( SECTION, + "var OBJ = new MyObject(true); OBJ.valueOf()", + true, + eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + +new TestCase( SECTION, + "OBJ.toString()", + "true", + OBJ.toString() ); + +new TestCase( SECTION, + "OBJ.toString = Object.prototype.toString; OBJ.toString()", + "[object Object]", + eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + +new TestCase( SECTION, + "MyObject.toString = Object.prototype.toString; MyObject.toString()", + "[object Function]", + eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + +new TestCase( SECTION, + "MyObject.__proto__ == Function.prototype", + true, + MyObject.__proto__ == Function.prototype ); + +new TestCase( SECTION, + "MyObject.length", + 1, + MyObject.length ); + +new TestCase( SECTION, + "MyObject.prototype.constructor", + MyObject, + MyObject.prototype.constructor ); + +new TestCase( SECTION, + "MyObject.arguments", + null, + MyObject.arguments ); + +test(); - myfunc.toString = Object.prototype.toString; - array[item++] = new TestCase( SECTION, - "myfunc = Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - myfunc.toString() ); - array[item++] = new TestCase( SECTION, "myfunc.length", 0, myfunc.length ); - array[item++] = new TestCase( SECTION, "myfunc.prototype.toString()", "[object Object]", myfunc.prototype.toString() ); - array[item++] = new TestCase( SECTION, "myfunc.prototype.constructor", myfunc, myfunc.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc.arguments", null, myfunc.arguments ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); - array[item++] = new TestCase( SECTION, "OBJ.toString()", "true", OBJ.toString() ); - array[item++] = new TestCase( SECTION, "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); - array[item++] = new TestCase( SECTION, "MyObject.toString = Object.prototype.toString; MyObject.toString()", "[object Function]", eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); - array[item++] = new TestCase( SECTION, "MyObject.__proto__ == Function.prototype", true, MyObject.__proto__ == Function.prototype ); - array[item++] = new TestCase( SECTION, "MyObject.length", 1, MyObject.length ); - array[item++] = new TestCase( SECTION, "MyObject.prototype.constructor", MyObject, MyObject.prototype.constructor ); - array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-2.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-2.js index 635128b5c68..79664559538 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-2.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,100 +35,157 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.1.1-2.js - ECMA Section: 15.3.1.1 The Function Constructor Called as a Function - Function(p1, p2, ..., pn, body ) + File Name: 15.3.1.1-2.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + Function(p1, p2, ..., pn, body ) - Description: - When the Function function is called with some arguments p1, p2, . . . , pn, - body (where n might be 0, that is, there are no "p" arguments, and where body - might also not be provided), the following steps are taken: + Description: + When the Function function is called with some arguments p1, p2, . . . , pn, + body (where n might be 0, that is, there are no "p" arguments, and where body + might also not be provided), the following steps are taken: - 1. Create and return a new Function object exactly if the function constructor - had been called with the same arguments (15.3.2.1). + 1. Create and return a new Function object exactly if the function constructor + had been called with the same arguments (15.3.2.1). - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.1.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Function Constructor Called as a Function"; +var SECTION = "15.3.1.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var myfunc1 = Function("a","b","c", "return a+b+c" ); +var myfunc2 = Function("a, b, c", "return a+b+c" ); +var myfunc3 = Function("a,b", "c", "return a+b+c" ); +myfunc1.toString = Object.prototype.toString; +myfunc2.toString = Object.prototype.toString; +myfunc3.toString = Object.prototype.toString; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "myfunc1 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); - var myfunc1 = Function("a","b","c", "return a+b+c" ); - var myfunc2 = Function("a, b, c", "return a+b+c" ); - var myfunc3 = Function("a,b", "c", "return a+b+c" ); +new TestCase( SECTION, + "myfunc1.length", + 3, + myfunc1.length ); - myfunc1.toString = Object.prototype.toString; - myfunc2.toString = Object.prototype.toString; - myfunc3.toString = Object.prototype.toString; +new TestCase( SECTION, + "myfunc1.prototype.toString()", + "[object Object]", + myfunc1.prototype.toString() ); - array[item++] = new TestCase( SECTION, "myfunc1 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - myfunc1.toString() ); +new TestCase( SECTION, + "myfunc1.prototype.constructor", + myfunc1, + myfunc1.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); - array[item++] = new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); +new TestCase( SECTION, + "myfunc1.arguments", + null, + myfunc1.arguments ); - array[item++] = new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); - array[item++] = new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); - array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", - "", - eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); +new TestCase( SECTION, + "myfunc1(1,2,3)", + 6, + myfunc1(1,2,3) ); - array[item++] = new TestCase( SECTION, "myfunc2 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - myfunc2.toString() ); - array[item++] = new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); - array[item++] = new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); - array[item++] = new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); - array[item++] = new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); - array[item++] = new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); - array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", - "", - eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); +new TestCase( SECTION, + "myfunc2 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); - array[item++] = new TestCase( SECTION, "myfunc3 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - myfunc3.toString() ); - array[item++] = new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); - array[item++] = new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); - array[item++] = new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); - array[item++] = new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); - array[item++] = new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); - array[item++] = new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); +new TestCase( SECTION, + "myfunc2.__proto__", + Function.prototype, + myfunc2.__proto__ ); - array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", - "", - eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); +new TestCase( SECTION, + "myfunc2.length", + 3, + myfunc2.length ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase( SECTION, + "myfunc2.prototype.toString()", + "[object Object]", + myfunc2.prototype.toString() ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "myfunc2.prototype.constructor", + myfunc2, + myfunc2.prototype.constructor ); + +new TestCase( SECTION, + "myfunc2.arguments", + null, + myfunc2.arguments ); + +new TestCase( SECTION, + "myfunc2( 1000, 200, 30 )", + 1230, + myfunc2(1000,200,30) ); + +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, + "myfunc3 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); + +new TestCase( SECTION, + "myfunc3.__proto__", + Function.prototype, + myfunc3.__proto__ ); + +new TestCase( SECTION, + "myfunc3.length", + 3, + myfunc3.length ); + +new TestCase( SECTION, + "myfunc3.prototype.toString()", + "[object Object]", + myfunc3.prototype.toString() ); + +new TestCase( SECTION, + "myfunc3.prototype.valueOf() +''", + "[object Object]", + myfunc3.prototype.valueOf() +'' ); + +new TestCase( SECTION, + "myfunc3.prototype.constructor", + myfunc3, + myfunc3.prototype.constructor ); + +new TestCase( SECTION, + "myfunc3.arguments", + null, + myfunc3.arguments ); + +new TestCase( SECTION, + "myfunc3(-100,100,NaN)", + Number.NaN, + myfunc3(-100,100,NaN) ); + +new TestCase( SECTION, + "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-3.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-3.js index ca5bcf22da1..a15dce471a0 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-3.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.1.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,63 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.1.1-3.js - ECMA Section: 15.3.1.1 The Function Constructor Called as a Function + File Name: 15.3.1.1-3.js + ECMA Section: 15.3.1.1 The Function Constructor Called as a Function - new Function(p1, p2, ..., pn, body ) + new Function(p1, p2, ..., pn, body ) - Description: The last argument specifies the body (executable code) - of a function; any preceeding arguments sepcify formal - parameters. + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. - See the text for description of this section. + See the text for description of this section. - This test examples from the specification. + This test examples from the specification. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.1.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Function Constructor Called as a Function"; +var SECTION = "15.3.1.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor Called as a Function"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); +var args = ""; - var testcases = new Array(); - - var args = ""; - - for ( var i = 0; i < 2000; i++ ) { - args += "arg"+i; - if ( i != 1999 ) { - args += ","; - } - } - - var s = ""; - - for ( var i = 0; i < 2000; i++ ) { - s += ".0005"; - if ( i != 1999 ) { - s += ","; - } - } - - MyFunc = Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); - MyObject = Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); - - var MY_OB = eval( "MyFunc("+ s +")" ); - - testcases[testcases.length] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); - testcases[testcases.length] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, MY_OB ); - testcases[testcases.length] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); - - testcases[testcases.length] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); - - testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); - testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); - testcases[testcases.length] = new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } } + +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } +} + +MyFunc = Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + +var MY_OB = eval( "MyFunc("+ s +")" ); + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, MY_OB ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-1.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-1.js index cca0e680679..05ee86912f5 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-1.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,76 +35,100 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.3.2.1.js - ECMA Section: 15.3.2.1 The Function Constructor - new Function(p1, p2, ..., pn, body ) - - Description: The last argument specifies the body (executable code) - of a function; any preceeding arguments sepcify formal - parameters. - - See the text for description of this section. - - This test examples from the specification. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - var SECTION = "15.3.2.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Function Constructor"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var MyObject = new Function( "value", "this.value = value; this.valueOf = new Function( 'return this.value' ); this.toString = new Function( 'return String(this.value);' )" ); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - var myfunc = new Function(); - -// not going to test toString here since it is implementation dependent. -// array[item++] = new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); - - myfunc.toString = Object.prototype.toString; - - array[item++] = new TestCase( SECTION, "myfunc = new Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - myfunc.toString() ); - array[item++] = new TestCase( SECTION, "myfunc.length", 0, myfunc.length ); - array[item++] = new TestCase( SECTION, "myfunc.prototype.toString()", "[object Object]", myfunc.prototype.toString() ); - - array[item++] = new TestCase( SECTION, "myfunc.prototype.constructor", myfunc, myfunc.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc.arguments", null, myfunc.arguments ); - - array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); - array[item++] = new TestCase( SECTION, "OBJ.toString()", "true", OBJ.toString() ); - array[item++] = new TestCase( SECTION, "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); - array[item++] = new TestCase( SECTION, "MyObject.toString = Object.prototype.toString; MyObject.toString()", "[object Function]", eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); - - array[item++] = new TestCase( SECTION, "MyObject.__proto__ == Function.prototype", true, MyObject.__proto__ == Function.prototype ); - array[item++] = new TestCase( SECTION, "MyObject.length", 1, MyObject.length ); - array[item++] = new TestCase( SECTION, "MyObject.prototype.constructor", MyObject, MyObject.prototype.constructor ); - array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. + + See the text for description of this section. + + This test examples from the specification. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MyObject = new Function( "value", "this.value = value; this.valueOf = new Function( 'return this.value' ); this.toString = new Function( 'return String(this.value);' )" ); + +var myfunc = new Function(); + +// not going to test toString here since it is implementation dependent. +// new TestCase( SECTION, "myfunc.toString()", "function anonymous() { }", myfunc.toString() ); + +myfunc.toString = Object.prototype.toString; + +new TestCase( SECTION, "myfunc = new Function(); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc.toString() ); + +new TestCase( SECTION, + "myfunc.length", + 0, + myfunc.length ); + +new TestCase( SECTION, + "myfunc.prototype.toString()", + "[object Object]", + myfunc.prototype.toString() ); + +new TestCase( SECTION, + "myfunc.prototype.constructor", + myfunc, + myfunc.prototype.constructor ); + +new TestCase( SECTION, + "myfunc.arguments", + null, + myfunc.arguments ); + +new TestCase( SECTION, + "var OBJ = new MyObject(true); OBJ.valueOf()", + true, + eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); + +new TestCase( SECTION, + "OBJ.toString()", + "true", + OBJ.toString() ); + +new TestCase( SECTION, + "OBJ.toString = Object.prototype.toString; OBJ.toString()", "[object Object]", + eval("OBJ.toString = Object.prototype.toString; OBJ.toString()") ); + +new TestCase( SECTION, + "MyObject.toString = Object.prototype.toString; MyObject.toString()", + "[object Function]", + eval("MyObject.toString = Object.prototype.toString; MyObject.toString()") ); + +new TestCase( SECTION, + "MyObject.__proto__ == Function.prototype", + true, + MyObject.__proto__ == Function.prototype ); + +new TestCase( SECTION, + "MyObject.length", + 1, + MyObject.length ); + +new TestCase( SECTION, + "MyObject.prototype.constructor", + MyObject, + MyObject.prototype.constructor ); + +new TestCase( SECTION, + "MyObject.arguments", + null, + MyObject.arguments ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-2.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-2.js index d5d2990ee58..ab78b0135f9 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-2.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,72 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.3.2.1.js - ECMA Section: 15.3.2.1 The Function Constructor - new Function(p1, p2, ..., pn, body ) - - Description: - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - var SECTION = "15.3.2.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Function Constructor"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - - var myfunc1 = new Function("a","b","c", "return a+b+c" ); - var myfunc2 = new Function("a, b, c", "return a+b+c" ); - var myfunc3 = new Function("a,b", "c", "return a+b+c" ); - - myfunc1.toString = Object.prototype.toString; - myfunc2.toString = Object.prototype.toString; - myfunc3.toString = Object.prototype.toString; - - array[item++] = new TestCase( SECTION, "myfunc1 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - myfunc1.toString() ); - - array[item++] = new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); - array[item++] = new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); - - array[item++] = new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); - array[item++] = new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); - array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", - "", - eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); - - array[item++] = new TestCase( SECTION, "myfunc2 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - myfunc2.toString() ); - array[item++] = new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); - array[item++] = new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); - array[item++] = new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); - - array[item++] = new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); - array[item++] = new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); - array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", - "", - eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); - - array[item++] = new TestCase( SECTION, "myfunc3 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - myfunc3.toString() ); - array[item++] = new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); - array[item++] = new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); - array[item++] = new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); - array[item++] = new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); - array[item++] = new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); - array[item++] = new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); - array[item++] = new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); - - array[item++] = new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", - "", - eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.3.2.1.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +var myfunc1 = new Function("a","b","c", "return a+b+c" ); +var myfunc2 = new Function("a, b, c", "return a+b+c" ); +var myfunc3 = new Function("a,b", "c", "return a+b+c" ); + +myfunc1.toString = Object.prototype.toString; +myfunc2.toString = Object.prototype.toString; +myfunc3.toString = Object.prototype.toString; + +new TestCase( SECTION, "myfunc1 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc1.toString() ); + +new TestCase( SECTION, "myfunc1.length", 3, myfunc1.length ); +new TestCase( SECTION, "myfunc1.prototype.toString()", "[object Object]", myfunc1.prototype.toString() ); + +new TestCase( SECTION, "myfunc1.prototype.constructor", myfunc1, myfunc1.prototype.constructor ); +new TestCase( SECTION, "myfunc1.arguments", null, myfunc1.arguments ); +new TestCase( SECTION, "myfunc1(1,2,3)", 6, myfunc1(1,2,3) ); +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, "myfunc2 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc2.toString() ); +new TestCase( SECTION, "myfunc2.__proto__", Function.prototype, myfunc2.__proto__ ); +new TestCase( SECTION, "myfunc2.length", 3, myfunc2.length ); +new TestCase( SECTION, "myfunc2.prototype.toString()", "[object Object]", myfunc2.prototype.toString() ); + +new TestCase( SECTION, "myfunc2.prototype.constructor", myfunc2, myfunc2.prototype.constructor ); +new TestCase( SECTION, "myfunc2.arguments", null, myfunc2.arguments ); +new TestCase( SECTION, "myfunc2( 1000, 200, 30 )", 1230, myfunc2(1000,200,30) ); +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") ); + +new TestCase( SECTION, "myfunc3 = new Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + myfunc3.toString() ); +new TestCase( SECTION, "myfunc3.__proto__", Function.prototype, myfunc3.__proto__ ); +new TestCase( SECTION, "myfunc3.length", 3, myfunc3.length ); +new TestCase( SECTION, "myfunc3.prototype.toString()", "[object Object]", myfunc3.prototype.toString() ); +new TestCase( SECTION, "myfunc3.prototype.valueOf() +''", "[object Object]", myfunc3.prototype.valueOf() +'' ); +new TestCase( SECTION, "myfunc3.prototype.constructor", myfunc3, myfunc3.prototype.constructor ); +new TestCase( SECTION, "myfunc3.arguments", null, myfunc3.arguments ); +new TestCase( SECTION, "myfunc3(-100,100,NaN)", Number.NaN, myfunc3(-100,100,NaN) ); + +new TestCase( SECTION, "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS", + "", + eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") ); +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-3.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-3.js index ffcb14c149d..565a578becd 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-3.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.2.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,59 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.2.1-3.js - ECMA Section: 15.3.2.1 The Function Constructor - new Function(p1, p2, ..., pn, body ) + File Name: 15.3.2.1-3.js + ECMA Section: 15.3.2.1 The Function Constructor + new Function(p1, p2, ..., pn, body ) - Description: The last argument specifies the body (executable code) - of a function; any preceeding arguments sepcify formal - parameters. + Description: The last argument specifies the body (executable code) + of a function; any preceeding arguments sepcify formal + parameters. - See the text for description of this section. + See the text for description of this section. - This test examples from the specification. + This test examples from the specification. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.2.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Function Constructor"; +var SECTION = "15.3.2.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Function Constructor"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var args = ""; -function getTestCases() { - var array = new Array(); - var item = 0; - - var args = ""; - - for ( var i = 0; i < 2000; i++ ) { - args += "arg"+i; - if ( i != 1999 ) { - args += ","; - } - } - - var s = ""; - - for ( var i = 0; i < 2000; i++ ) { - s += ".0005"; - if ( i != 1999 ) { - s += ","; - } - } - - MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); - MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); - - array[item++] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); - array[item++] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); - - array[item++] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); - - array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); - array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); - array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); - - return ( array ); +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } } + +MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-1.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-1.js index a0c979ed861..63ab250bda8 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-1.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,44 +35,31 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.3.1-1.js - ECMA Section: 15.3.3.1 Properties of the Function Constructor - Function.prototype + File Name: 15.3.3.1-1.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype - Description: The initial value of Function.prototype is the built-in - Function prototype object. + Description: The initial value of Function.prototype is the built-in + Function prototype object. - This property shall have the attributes [DontEnum | - DontDelete | ReadOnly] + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] - This test the value of Function.prototype. + This test the value of Function.prototype. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.3.1-1"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "Function.prototype"; +var SECTION = "15.3.3.1-1"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Function.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - testcases[tc++] = new TestCase( SECTION, "Function.prototype == Function.proto", true, Function.__proto__ == Function.prototype ); +new TestCase( SECTION, "Function.prototype == Function.proto", true, Function.__proto__ == Function.prototype ); - test(); - -function test() { - for (tc=0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-2.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-2.js index aa84745d9b4..9b10b1accc1 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-2.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.3.1-2.js - ECMA Section: 15.3.3.1 Properties of the Function Constructor - Function.prototype + File Name: 15.3.3.1-2.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype - Description: The initial value of Function.prototype is the built-in - Function prototype object. + Description: The initial value of Function.prototype is the built-in + Function prototype object. - This property shall have the attributes [DontEnum | - DontDelete | ReadOnly] + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] - This test the DontEnum property of Function.prototype. + This test the DontEnum property of Function.prototype. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.3.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function.prototype"; +var SECTION = "15.3.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "var str='';for (prop in Function ) str += prop; str;", - "", - eval("var str='';for (prop in Function) str += prop; str;") - ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "var str='';for (prop in Function ) str += prop; str;", + "", + eval("var str='';for (prop in Function) str += prop; str;") + ); +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-3.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-3.js index ca3c50fe825..8aa836ef635 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-3.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,43 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.3.1-3.js - ECMA Section: 15.3.3.1 Properties of the Function Constructor - Function.prototype + File Name: 15.3.3.1-3.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype - Description: The initial value of Function.prototype is the built-in - Function prototype object. + Description: The initial value of Function.prototype is the built-in + Function prototype object. - This property shall have the attributes [DontEnum | - DontDelete | ReadOnly] + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] - This test the DontDelete property of Function.prototype. + This test the DontDelete property of Function.prototype. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.3.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function.prototype"; +var SECTION = "15.3.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +var FUN_PROTO = Function.prototype; - var FUN_PROTO = Function.prototype; +new TestCase( SECTION, + "delete Function.prototype", + false, + delete Function.prototype + ); - array[item++] = new TestCase( SECTION, - "delete Function.prototype", - false, - delete Function.prototype - ); - - array[item++] = new TestCase( SECTION, - "delete Function.prototype; Function.prototype", - FUN_PROTO, - eval("delete Function.prototype; Function.prototype") - ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "delete Function.prototype; Function.prototype", + FUN_PROTO, + eval("delete Function.prototype; Function.prototype") + ); +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-4.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-4.js index 70c5cc5830d..f10538bd68d 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-4.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.1-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.3.1-4.js - ECMA Section: 15.3.3.1 Properties of the Function Constructor - Function.prototype + File Name: 15.3.3.1-4.js + ECMA Section: 15.3.3.1 Properties of the Function Constructor + Function.prototype - Description: The initial value of Function.prototype is the built-in - Function prototype object. + Description: The initial value of Function.prototype is the built-in + Function prototype object. - This property shall have the attributes [DontEnum | - DontDelete | ReadOnly] + This property shall have the attributes [DontEnum | + DontDelete | ReadOnly] - This test the ReadOnly property of Function.prototype. + This test the ReadOnly property of Function.prototype. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.3.1-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function.prototype"; +var SECTION = "15.3.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "Function.prototype = null; Function.prototype", - Function.prototype, - eval("Function.prototype = null; Function.prototype") - ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Function.prototype = null; Function.prototype", + Function.prototype, + eval("Function.prototype = null; Function.prototype") + ); +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.2.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.2.js index 210c82a19a2..854b344d6b6 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.3.2.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.3.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,42 +35,25 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.3.3.2.js - ECMA Section: 15.3.3.2 Properties of the Function Constructor - Function.length - - Description: The length property is 1. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - - var SECTION = "15.3.3.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function.length"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Function.length", 1, Function.length ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.3.3.2.js + ECMA Section: 15.3.3.2 Properties of the Function Constructor + Function.length + + Description: The length property is 1. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.3.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.length"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Function.length", 1, Function.length ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.4-1.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.4-1.js index 7b983cf49b6..885f4c081e3 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.4-1.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,57 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.3.4-1.js - ECMA Section: 15.3.4 Properties of the Function Prototype Object - - Description: The Function prototype object is itself a Function - object ( its [[Class]] is "Function") that, when - invoked, accepts any arguments and returns undefined. - - The value of the internal [[Prototype]] property - object is the Object prototype object. - - It is a function with an "empty body"; if it is - invoked, it merely returns undefined. - - The Function prototype object does not have a valueOf - property of its own; however it inherits the valueOf - property from the Object prototype Object. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - - var SECTION = "15.3.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the Function Prototype Object"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); - - -// array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); - array[item++] = new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); - array[item++] = new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.3.4-1.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Function Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + +new TestCase( SECTION, + "Function.prototype.valueOf", + Object.prototype.valueOf, + Function.prototype.valueOf ); + +new TestCase( SECTION, + "Function.prototype()", + (void 0), + Function.prototype() ); + +new TestCase( SECTION, + "Function.prototype(1,true,false,'string', new Date(),null)", + (void 0), + Function.prototype(1,true,false,'string', new Date(),null) ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.4.1.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.4.1.js index c2e10e2624b..252a768c323 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.4.1.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.4.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,44 +35,24 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.3.4.1.js - ECMA Section: 15.3.4.1 Function.prototype.constructor - - Description: The initial value of Function.prototype.constructor - is the built-in Function constructor. - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - - var SECTION = "15.3.4.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function.prototype.constructor"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "Function.prototype.constructor", Function, Function.prototype.constructor ); - - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.3.4.1.js + ECMA Section: 15.3.4.1 Function.prototype.constructor + + Description: The initial value of Function.prototype.constructor + is the built-in Function constructor. + Author: christine@netscape.com + Date: 28 october 1997 + +*/ + +var SECTION = "15.3.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "Function.prototype.constructor", Function, Function.prototype.constructor ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.4.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.4.js index 80c99415931..c7fc147e556 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.4.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,44 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.3.4.js - ECMA Section: 15.3.4 Properties of the Function Prototype Object - - Description: The Function prototype object is itself a Function - object ( its [[Class]] is "Function") that, when - invoked, accepts any arguments and returns undefined. - - The value of the internal [[Prototype]] property - object is the Object prototype object. - - It is a function with an "empty body"; if it is - invoked, it merely returns undefined. - - The Function prototype object does not have a valueOf - property of its own; however it inherits the valueOf - property from the Object prototype Object. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - var SECTION = "15.3.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the Function Prototype Object"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", - "[object Function]", - eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); - - -// array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); - array[item++] = new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); - array[item++] = new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.3.4.js + ECMA Section: 15.3.4 Properties of the Function Prototype Object + + Description: The Function prototype object is itself a Function + object ( its [[Class]] is "Function") that, when + invoked, accepts any arguments and returns undefined. + + The value of the internal [[Prototype]] property + object is the Object prototype object. + + It is a function with an "empty body"; if it is + invoked, it merely returns undefined. + + The Function prototype object does not have a valueOf + property of its own; however it inherits the valueOf + property from the Object prototype Object. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.3.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Function Prototype Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()", + "[object Function]", + eval("var myfunc = Function.prototype; myfunc.toString = Object.prototype.toString; myfunc.toString()")); + + +// new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); +new TestCase( SECTION, "Function.prototype.valueOf", Object.prototype.valueOf, Function.prototype.valueOf ); +new TestCase( SECTION, "Function.prototype()", (void 0), Function.prototype() ); +new TestCase( SECTION, "Function.prototype(1,true,false,'string', new Date(),null)", (void 0), Function.prototype(1,true,false,'string', new Date(),null) ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.5-1.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.5-1.js index 3540c083361..0b1ad0689f2 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.5-1.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,100 +35,81 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.5-1.js - ECMA Section: 15.3.5 Properties of Function Instances - new Function(p1, p2, ..., pn, body ) + File Name: 15.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) - Description: + Description: - 15.3.5.1 length + 15.3.5.1 length - The value of the length property is usually an integer that indicates - the "typical" number of arguments expected by the function. However, - the language permits the function to be invoked with some other number - of arguments. The behavior of a function when invoked on a number of - arguments other than the number specified by its length property depends - on the function. + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. - 15.3.5.2 prototype - The value of the prototype property is used to initialize the internal [[ - Prototype]] property of a newly created object before the Function object - is invoked as a constructor for that newly created object. + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. - 15.3.5.3 arguments + 15.3.5.3 arguments - The value of the arguments property is normally null if there is no - outstanding invocation of the function in progress (that is, the function has been called - but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its - arguments property is "dynamically bound" to a newly created object that contains the - arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this - property is discouraged; it is provided principally for compatibility with existing old code. + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.5-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of Function Instances"; +var SECTION = "15.3.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of Function Instances"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test(); +var args = ""; -function getTestCases() { - var array = new Array(); - var item = 0; - - var args = ""; - - for ( var i = 0; i < 2000; i++ ) { - args += "arg"+i; - if ( i != 1999 ) { - args += ","; - } - } - - var s = ""; - - for ( var i = 0; i < 2000; i++ ) { - s += ".0005"; - if ( i != 1999 ) { - s += ","; - } - } - - MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); - MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); - - - array[item++] = new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); - array[item++] = new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); - array[item++] = new TestCase( SECTION, "MyFunc.prototype.toString()", "[object Object]", MyFunc.prototype.toString() ); - array[item++] = new TestCase( SECTION, "typeof MyFunc.prototype", "object", typeof MyFunc.prototype ); - - - array[item++] = new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); - - array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); - array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); - array[item++] = new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); - - return ( array ); +for ( var i = 0; i < 2000; i++ ) { + args += "arg"+i; + if ( i != 1999 ) { + args += ","; + } } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +var s = ""; + +for ( var i = 0; i < 2000; i++ ) { + s += ".0005"; + if ( i != 1999 ) { + s += ","; + } } + +MyFunc = new Function( args, "var r=0; for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; else r += eval('arg'+i); }; return r"); +MyObject = new Function( args, "for (var i = 0; i < MyFunc.length; i++ ) { if ( eval('arg'+i) == void 0) break; eval('this.arg'+i +'=arg'+i); };"); + + +new TestCase( SECTION, "MyFunc.length", 2000, MyFunc.length ); +new TestCase( SECTION, "var MY_OB = eval('MyFunc(s)')", 1, eval("var MY_OB = MyFunc("+s+"); MY_OB") ); +new TestCase( SECTION, "MyFunc.prototype.toString()", "[object Object]", MyFunc.prototype.toString() ); +new TestCase( SECTION, "typeof MyFunc.prototype", "object", typeof MyFunc.prototype ); + + +new TestCase( SECTION, "MyObject.length", 2000, MyObject.length ); + +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1.length") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1()") ); +new TestCase( SECTION, "FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)", 3, eval("FUN1 = new Function( 'a','b','c', 'return FUN1.length' ); FUN1(1,2,3,4,5)") ); + +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.5-2.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.5-2.js index 2b219cf87c9..f0da85a183f 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.5-2.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,74 +35,54 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.5-1.js - ECMA Section: 15.3.5 Properties of Function Instances - new Function(p1, p2, ..., pn, body ) + File Name: 15.3.5-1.js + ECMA Section: 15.3.5 Properties of Function Instances + new Function(p1, p2, ..., pn, body ) - Description: + Description: - 15.3.5.1 length + 15.3.5.1 length - The value of the length property is usually an integer that indicates - the "typical" number of arguments expected by the function. However, - the language permits the function to be invoked with some other number - of arguments. The behavior of a function when invoked on a number of - arguments other than the number specified by its length property depends - on the function. + The value of the length property is usually an integer that indicates + the "typical" number of arguments expected by the function. However, + the language permits the function to be invoked with some other number + of arguments. The behavior of a function when invoked on a number of + arguments other than the number specified by its length property depends + on the function. - 15.3.5.2 prototype - The value of the prototype property is used to initialize the internal [[ - Prototype]] property of a newly created object before the Function object - is invoked as a constructor for that newly created object. + 15.3.5.2 prototype + The value of the prototype property is used to initialize the internal [[ + Prototype]] property of a newly created object before the Function object + is invoked as a constructor for that newly created object. - 15.3.5.3 arguments + 15.3.5.3 arguments - The value of the arguments property is normally null if there is no - outstanding invocation of the function in progress (that is, the function has been called - but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its - arguments property is "dynamically bound" to a newly created object that contains the - arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this - property is discouraged; it is provided principally for compatibility with existing old code. + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the function has been called + but has not yet returned). When a non-internal Function object (15.3.2.1) is invoked, its + arguments property is "dynamically bound" to a newly created object that contains the + arguments on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility with existing old code. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.3.5-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of Function Instances"; +var SECTION = "15.3.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of Function Instances"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test(); +var MyObject = new Function( 'a', 'b', 'c', 'this.a = a; this.b = b; this.c = c; this.value = a+b+c; this.valueOf = new Function( "return this.value" )' ); -function getTestCases() { - var array = new Array(); - var item = 0; - - var MyObject = new Function( 'a', 'b', 'c', 'this.a = a; this.b = b; this.c = c; this.value = a+b+c; this.valueOf = new Function( "return this.value" )' ); - - array[item++] = new TestCase( SECTION, "MyObject.length", 3, MyObject.length ); - array[item++] = new TestCase( SECTION, "typeof MyObject.prototype", "object", typeof MyObject.prototype ); - array[item++] = new TestCase( SECTION, "typeof MyObject.prototype.constructor", "function", typeof MyObject.prototype.constructor ); - array[item++] = new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, "MyObject.length", 3, MyObject.length ); +new TestCase( SECTION, "typeof MyObject.prototype", "object", typeof MyObject.prototype ); +new TestCase( SECTION, "typeof MyObject.prototype.constructor", "function", typeof MyObject.prototype.constructor ); +new TestCase( SECTION, "MyObject.arguments", null, MyObject.arguments ); +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.5.1.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.5.1.js index 9245d24ac7c..e51ddd29708 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.5.1.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.5.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.5.1.js - ECMA Section: Function.length - Description: + File Name: 15.3.5.1.js + ECMA Section: Function.length + Description: - The value of the length property is usually an integer that indicates the - "typical" number of arguments expected by the function. However, the - language permits the function to be invoked with some other number of - arguments. The behavior of a function when invoked on a number of arguments - other than the number specified by its length property depends on the function. + The value of the length property is usually an integer that indicates the + "typical" number of arguments expected by the function. However, the + language permits the function to be invoked with some other number of + arguments. The behavior of a function when invoked on a number of arguments + other than the number specified by its length property depends on the function. - this test needs a 1.2 version check. + this test needs a 1.2 version check. - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.3.5.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function.length"; - var BUGNUMBER="104204"; +var SECTION = "15.3.5.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.length"; +var BUGNUMBER="104204"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var f = new Function( "a","b", "c", "return f.length"); - var f = new Function( "a","b", "c", "return f.length"); - - testcases[tc++] = new TestCase( SECTION, - 'var f = new Function( "a","b", "c", "return f.length"); f()', - 3, - f() ); +new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 3, + f() ); - testcases[tc++] = new TestCase( SECTION, - 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', - 3, - f(1,2,3,4,5) ); +new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 3, + f(1,2,3,4,5) ); +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/FunctionObjects/15.3.5.3.js b/mozilla/js/tests/ecma/FunctionObjects/15.3.5.3.js index 235a64a5fe6..9cf95b1c664 100644 --- a/mozilla/js/tests/ecma/FunctionObjects/15.3.5.3.js +++ b/mozilla/js/tests/ecma/FunctionObjects/15.3.5.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.5.3.js - ECMA Section: Function.arguments - Description: + File Name: 15.3.5.3.js + ECMA Section: Function.arguments + Description: - The value of the arguments property is normally null if there is no - outstanding invocation of the function in progress (that is, the - function has been called but has not yet returned). When a non-internal - Function object (15.3.2.1) is invoked, its arguments property is - "dynamically bound" to a newly created object that contains the arguments - on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this - property is discouraged; it is provided principally for compatibility - with existing old code. + The value of the arguments property is normally null if there is no + outstanding invocation of the function in progress (that is, the + function has been called but has not yet returned). When a non-internal + Function object (15.3.2.1) is invoked, its arguments property is + "dynamically bound" to a newly created object that contains the arguments + on which it was invoked (see 10.1.6 and 10.1.8). Note that the use of this + property is discouraged; it is provided principally for compatibility + with existing old code. - See sections 10.1.6 and 10.1.8 for more extensive tests. + See sections 10.1.6 and 10.1.8 for more extensive tests. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.3.5.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function.arguments"; +var SECTION = "15.3.5.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.arguments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var MYFUNCTION = new Function( "return this.arguments" ); -function getTestCases() { - var array =new Array(); - var item = 0; +new TestCase( SECTION, "var MYFUNCTION = new Function( 'return this.arguments' ); MYFUNCTION.arguments", null, MYFUNCTION.arguments ); - var MYFUNCTION = new Function( "return this.arguments" ); - - - array[item++] = new TestCase( SECTION, "var MYFUNCTION = new Function( 'return this.arguments' ); MYFUNCTION.arguments", null, MYFUNCTION.arguments ); - - return array; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/FunctionObjects/browser.js b/mozilla/js/tests/ecma/FunctionObjects/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/FunctionObjects/shell.js b/mozilla/js/tests/ecma/FunctionObjects/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1-1-n.js b/mozilla/js/tests/ecma/GlobalObject/15.1-1-n.js index ddc1ab992e1..ab7aa79ea9f 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1-1-n.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1-1-n.js - ECMA Section: The global object - Description: + File Name: 15.1-1-n.js + ECMA Section: The global object + Description: - The global object does not have a [[Construct]] property; it is not - possible to use the global object as a constructor with the new operator. + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.1-1-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Global Object"; +var SECTION = "15.1-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Global Object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +DESCRIPTION = "var MY_GLOBAL = new this()"; +EXPECTED = "error"; - testcases[tc] = new TestCase( SECTION, - "var MY_GLOBAL = new this()", - "error", - "var MY_GLOBAL = new this()" ); +new TestCase( SECTION, + "var MY_GLOBAL = new this()", + "error", + eval("var MY_GLOBAL = new this()") ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval(testcases[tc].actual); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1-2-n.js b/mozilla/js/tests/ecma/GlobalObject/15.1-2-n.js index f2654cc71e1..55641988a1a 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1-2-n.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.1-2-n.js - ECMA Section: The global object - Description: - - The global object does not have a [[Call]] property; it is not possible - to invoke the global object as a function. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ - - var SECTION = "15.1-2-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Global Object"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); - - testcases[tc] = new TestCase( SECTION, - "var MY_GLOBAL = this()", - "error", - "var MY_GLOBAL = this()" ); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval(testcases[tc].actual); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.1-2-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Call]] property; it is not possible + to invoke the global object as a function. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.1-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Global Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var MY_GLOBAL = this()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "var MY_GLOBAL = this()", + "error", + eval("var MY_GLOBAL = this()") ); +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.1.1.js b/mozilla/js/tests/ecma/GlobalObject/15.1.1.1.js index c0287f8f08d..f20c2ae41fa 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.1.1.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.1.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.1.1.js - ECMA Section: 15.1.1.1 NaN + File Name: 15.1.1.1.js + ECMA Section: 15.1.1.1 NaN - Description: The initial value of NaN is NaN. + Description: The initial value of NaN is NaN. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.1.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "NaN"; +var SECTION = "15.1.1.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "NaN"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[array.length] = new TestCase( SECTION, "NaN", Number.NaN, NaN ); - array[array.length] = new TestCase( SECTION, "this.NaN", Number.NaN, this.NaN ); - array[array.length] = new TestCase( SECTION, "typeof NaN", "number", typeof NaN ); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, "NaN", Number.NaN, NaN ); +new TestCase( SECTION, "this.NaN", Number.NaN, this.NaN ); +new TestCase( SECTION, "typeof NaN", "number", typeof NaN ); +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.1.2.js b/mozilla/js/tests/ecma/GlobalObject/15.1.1.2.js index b3a1d252d30..6416d65c02c 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.1.2.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.1.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,26 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.1.2.js - ECMA Section: 15.1.1.2 Infinity + File Name: 15.1.1.2.js + ECMA Section: 15.1.1.2 Infinity - Description: The initial value of Infinity is +Infinity. + Description: The initial value of Infinity is +Infinity. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.1.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Infinity"; +var SECTION = "15.1.1.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Infinity"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "Infinity", Number.POSITIVE_INFINITY, Infinity ); +new TestCase( SECTION, "this.Infinity", Number.POSITIVE_INFINITY, this.Infinity ); +new TestCase( SECTION, "typeof Infinity", "number", typeof Infinity ); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "Infinity", Number.POSITIVE_INFINITY, Infinity ); - array[item++] = new TestCase( SECTION, "this.Infinity", Number.POSITIVE_INFINITY, this.Infinity ); - array[item++] = new TestCase( SECTION, "typeof Infinity", "number", typeof Infinity ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - - } - - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.1-1.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.1-1.js index 4e86b501df3..41e92f995bd 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.1-1.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,73 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.2.1-1.js - ECMA Section: 15.1.2.1 eval(x) +File Name: 15.1.2.1-1.js +ECMA Section: 15.1.2.1 eval(x) - if x is not a string object, return x. - Description: - Author: christine@netscape.com - Date: 16 september 1997 +if x is not a string object, return x. +Description: +Author: christine@netscape.com +Date: 16 september 1997 */ - var SECTION = "15.1.2.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "eval(x)"; +var SECTION = "15.1.2.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "eval(x)"; - var BUGNUMBER = "111199"; +var BUGNUMBER = "111199"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "eval.length", 1, eval.length ); +new TestCase( SECTION, "delete eval.length", false, delete eval.length ); +new TestCase( SECTION, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", "", eval("var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS") ); +new TestCase( SECTION, "eval.length = null; eval.length", 1, eval( "eval.length = null; eval.length") ); +// new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); - test(); +// test cases where argument is not a string. should return the argument. -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "eval()", void 0, eval() ); +new TestCase( SECTION, "eval(void 0)", void 0, eval( void 0) ); +new TestCase( SECTION, "eval(null)", null, eval( null ) ); +new TestCase( SECTION, "eval(true)", true, eval( true ) ); +new TestCase( SECTION, "eval(false)", false, eval( false ) ); - array[item++] = new TestCase( SECTION, "eval.length", 1, eval.length ); - array[item++] = new TestCase( SECTION, "delete eval.length", false, delete eval.length ); - array[item++] = new TestCase( SECTION, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", "", eval("var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS") ); - array[item++] = new TestCase( SECTION, "eval.length = null; eval.length", 1, eval( "eval.length = null; eval.length") ); -// array[item++] = new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); +new TestCase( SECTION, "typeof eval(new String('Infinity/-0')", "object", typeof eval(new String('Infinity/-0')) ); - // test cases where argument is not a string. should return the argument. +new TestCase( SECTION, "eval([1,2,3,4,5,6])", "1,2,3,4,5,6", ""+eval([1,2,3,4,5,6]) ); +new TestCase( SECTION, "eval(new Array(0,1,2,3)", "1,2,3", ""+ eval(new Array(1,2,3)) ); +new TestCase( SECTION, "eval(1)", 1, eval(1) ); +new TestCase( SECTION, "eval(0)", 0, eval(0) ); +new TestCase( SECTION, "eval(-1)", -1, eval(-1) ); +new TestCase( SECTION, "eval(Number.NaN)", Number.NaN, eval(Number.NaN) ); +new TestCase( SECTION, "eval(Number.MIN_VALUE)", 5e-308, eval(Number.MIN_VALUE) ); +new TestCase( SECTION, "eval(-Number.MIN_VALUE)", -5e-308, eval(-Number.MIN_VALUE) ); +new TestCase( SECTION, "eval(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, eval(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "eval(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, eval(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "eval( 4294967296 )", 4294967296, eval(4294967296) ); +new TestCase( SECTION, "eval( 2147483648 )", 2147483648, eval(2147483648) ); - array[item++] = new TestCase( SECTION, "eval()", void 0, eval() ); - array[item++] = new TestCase( SECTION, "eval(void 0)", void 0, eval( void 0) ); - array[item++] = new TestCase( SECTION, "eval(null)", null, eval( null ) ); - array[item++] = new TestCase( SECTION, "eval(true)", true, eval( true ) ); - array[item++] = new TestCase( SECTION, "eval(false)", false, eval( false ) ); - - array[item++] = new TestCase( SECTION, "typeof eval(new String('Infinity/-0')", "object", typeof eval(new String('Infinity/-0')) ); - - array[item++] = new TestCase( SECTION, "eval([1,2,3,4,5,6])", "1,2,3,4,5,6", ""+eval([1,2,3,4,5,6]) ); - array[item++] = new TestCase( SECTION, "eval(new Array(0,1,2,3)", "1,2,3", ""+ eval(new Array(1,2,3)) ); - array[item++] = new TestCase( SECTION, "eval(1)", 1, eval(1) ); - array[item++] = new TestCase( SECTION, "eval(0)", 0, eval(0) ); - array[item++] = new TestCase( SECTION, "eval(-1)", -1, eval(-1) ); - array[item++] = new TestCase( SECTION, "eval(Number.NaN)", Number.NaN, eval(Number.NaN) ); - array[item++] = new TestCase( SECTION, "eval(Number.MIN_VALUE)", 5e-308, eval(Number.MIN_VALUE) ); - array[item++] = new TestCase( SECTION, "eval(-Number.MIN_VALUE)", -5e-308, eval(-Number.MIN_VALUE) ); - array[item++] = new TestCase( SECTION, "eval(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, eval(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "eval(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, eval(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "eval( 4294967296 )", 4294967296, eval(4294967296) ); - array[item++] = new TestCase( SECTION, "eval( 2147483648 )", 2147483648, eval(2147483648) ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.1-2.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.1-2.js index 247410db8ac..4e570403e45 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.1-2.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.2.1-2.js - ECMA Section: 15.1.2.1 eval(x) + File Name: 15.1.2.1-2.js + ECMA Section: 15.1.2.1 eval(x) - Parse x as an ECMAScript Program. If the parse fails, - generate a runtime error. Evaluate the program. If - result is "Normal completion after value V", return - the value V. Else, return undefined. - Description: - Author: christine@netscape.com - Date: 16 september 1997 + Parse x as an ECMAScript Program. If the parse fails, + generate a runtime error. Evaluate the program. If + result is "Normal completion after value V", return + the value V. Else, return undefined. + Description: + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.1.2.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "eval(x)"; +var SECTION = "15.1.2.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "eval(x)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, + "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x", + "0/1/1970", + eval( "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x" )); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[0] = new TestCase( SECTION, - "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x", - "0/1/1970", - eval( "d = new Date(0); with (d) { x = getUTCMonth() +'/'+ getUTCDate() +'/'+ getUTCFullYear(); } x" ) - ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.2-1.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.2-1.js index 6751015742b..fcd9f385c7c 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.2-1.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,272 +36,371 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.1.2.2-1.js - ECMA Section: 15.1.2.2 Function properties of the global object - parseInt( string, radix ) + File Name: 15.1.2.2-1.js + ECMA Section: 15.1.2.2 Function properties of the global object + parseInt( string, radix ) - Description: + Description: - The parseInt function produces an integer value dictated by intepretation - of the contents of the string argument according to the specified radix. + The parseInt function produces an integer value dictated by intepretation + of the contents of the string argument according to the specified radix. - When the parseInt function is called, the following steps are taken: + When the parseInt function is called, the following steps are taken: 1. Call ToString(string). 2. Compute a substring of Result(1) consisting of the leftmost character - that is not a StrWhiteSpaceChar and all characters to the right of - that character. (In other words, remove leading whitespace.) + that is not a StrWhiteSpaceChar and all characters to the right of + that character. (In other words, remove leading whitespace.) 3. Let sign be 1. 4. If Result(2) is not empty and the first character of Result(2) is a - minus sign -, let sign be -1. + minus sign -, let sign be -1. 5. If Result(2) is not empty and the first character of Result(2) is a - plus sign + or a minus sign -, then Result(5) is the substring of - Result(2) produced by removing the first character; otherwise, Result(5) - is Result(2). + plus sign + or a minus sign -, then Result(5) is the substring of + Result(2) produced by removing the first character; otherwise, Result(5) + is Result(2). 6. If the radix argument is not supplied, go to step 12. 7. Call ToInt32(radix). 8. If Result(7) is zero, go to step 12; otherwise, if Result(7) < 2 or - Result(7) > 36, return NaN. + Result(7) > 36, return NaN. 9. Let R be Result(7). - 10. If R = 16 and the length of Result(5) is at least 2 and the first two - characters of Result(5) are either "0x" or "0X", let S be the substring - of Result(5) consisting of all but the first two characters; otherwise, - let S be Result(5). - 11. Go to step 22. - 12. If Result(5) is empty or the first character of Result(5) is not 0, - go to step 20. - 13. If the length of Result(5) is at least 2 and the second character of - Result(5) is x or X, go to step 17. - 14. Let R be 8. - 15. Let S be Result(5). - 16. Go to step 22. - 17. Let R be 16. - 18. Let S be the substring of Result(5) consisting of all but the first - two characters. - 19. Go to step 22. - 20. Let R be 10. - 21. Let S be Result(5). - 22. If S contains any character that is not a radix-R digit, then let Z be - the substring of S consisting of all characters to the left of the - leftmost such character; otherwise, let Z be S. - 23. If Z is empty, return NaN. - 24. Compute the mathematical integer value that is represented by Z in - radix-R notation. (But if R is 10 and Z contains more than 20 - significant digits, every digit after the 20th may be replaced by a 0 - digit, at the option of the implementation; and if R is not 2, 4, 8, - 10, 16, or 32, then Result(24) may be an implementation-dependent - approximation to the mathematical integer value that is represented - by Z in radix-R notation.) - 25. Compute the number value for Result(24). - 26. Return sign Result(25). + 10. If R = 16 and the length of Result(5) is at least 2 and the first two + characters of Result(5) are either "0x" or "0X", let S be the substring + of Result(5) consisting of all but the first two characters; otherwise, + let S be Result(5). + 11. Go to step 22. + 12. If Result(5) is empty or the first character of Result(5) is not 0, + go to step 20. + 13. If the length of Result(5) is at least 2 and the second character of + Result(5) is x or X, go to step 17. + 14. Let R be 8. + 15. Let S be Result(5). + 16. Go to step 22. + 17. Let R be 16. + 18. Let S be the substring of Result(5) consisting of all but the first + two characters. + 19. Go to step 22. + 20. Let R be 10. + 21. Let S be Result(5). + 22. If S contains any character that is not a radix-R digit, then let Z be + the substring of S consisting of all characters to the left of the + leftmost such character; otherwise, let Z be S. + 23. If Z is empty, return NaN. + 24. Compute the mathematical integer value that is represented by Z in + radix-R notation. (But if R is 10 and Z contains more than 20 + significant digits, every digit after the 20th may be replaced by a 0 + digit, at the option of the implementation; and if R is not 2, 4, 8, + 10, 16, or 32, then Result(24) may be an implementation-dependent + approximation to the mathematical integer value that is represented + by Z in radix-R notation.) + 25. Compute the number value for Result(24). + 26. Return sign Result(25). - Note that parseInt may interpret only a leading portion of the string as - an integer value; it ignores any characters that cannot be interpreted as - part of the notation of an integer, and no indication is given that any - such characters were ignored. + Note that parseInt may interpret only a leading portion of the string as + an integer value; it ignores any characters that cannot be interpreted as + part of the notation of an integer, and no indication is given that any + such characters were ignored. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.2.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "parseInt(string, radix)"; - var BUGNUMBER="111199"; +var SECTION = "15.1.2.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "parseInt(string, radix)"; +var BUGNUMBER="111199"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +var HEX_STRING = "0x0"; +var HEX_VALUE = 0; - test(); +new TestCase( SECTION, + "parseInt.length", + 2, + parseInt.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "parseInt.length = 0; parseInt.length", + 2, + eval("parseInt.length = 0; parseInt.length") ); - var HEX_STRING = "0x0"; - var HEX_VALUE = 0; +new TestCase( SECTION, + "var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS", "", + eval("var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS") ); - array[item++] = new TestCase( SECTION, "parseInt.length", 2, parseInt.length ); - array[item++] = new TestCase( SECTION, "parseInt.length = 0; parseInt.length", 2, eval("parseInt.length = 0; parseInt.length") ); - array[item++] = new TestCase( SECTION, "var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS", "", eval("var PROPS=''; for ( var p in parseInt ) { PROPS += p; }; PROPS") ); - array[item++] = new TestCase( SECTION, "delete parseInt.length", false, delete parseInt.length ); - array[item++] = new TestCase( SECTION, "delete parseInt.length; parseInt.length", 2, eval("delete parseInt.length; parseInt.length") ); - array[item++] = new TestCase( SECTION, "parseInt.length = null; parseInt.length", 2, eval("parseInt.length = null; parseInt.length") ); +new TestCase( SECTION, + "delete parseInt.length", + false, + delete parseInt.length ); - array[item++] = new TestCase( SECTION, "parseInt()", NaN, parseInt() ); - array[item++] = new TestCase( SECTION, "parseInt('')", NaN, parseInt("") ); - array[item++] = new TestCase( SECTION, "parseInt('','')", NaN, parseInt("","") ); - array[item++] = new TestCase( SECTION, - "parseInt(\" 0xabcdef ", - 11259375, - parseInt( " 0xabcdef " )); +new TestCase( SECTION, + "delete parseInt.length; parseInt.length", + 2, + eval("delete parseInt.length; parseInt.length") ); - array[item++] = new TestCase( SECTION, - "parseInt(\" 0XABCDEF ", - 11259375, - parseInt( " 0XABCDEF " ) ); +new TestCase( SECTION, + "parseInt.length = null; parseInt.length", + 2, + eval("parseInt.length = null; parseInt.length") ); - array[item++] = new TestCase( SECTION, - "parseInt( 0xabcdef )", - 11259375, - parseInt( "0xabcdef") ); +new TestCase( SECTION, + "parseInt()", + NaN, + parseInt() ); - array[item++] = new TestCase( SECTION, - "parseInt( 0XABCDEF )", - 11259375, - parseInt( "0XABCDEF") ); +new TestCase( SECTION, + "parseInt('')", + NaN, + parseInt("") ); - for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",null)", HEX_VALUE, parseInt(HEX_STRING,null) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+", void 0)", HEX_VALUE, parseInt(HEX_STRING, void 0) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } +new TestCase( SECTION, + "parseInt('','')", + NaN, + parseInt("","") ); - // a few tests with spaces +new TestCase( SECTION, + "parseInt(\" 0xabcdef ", + 11259375, + parseInt( " 0xabcdef " )); - for ( var space = " ", HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; - POWER < 15; - POWER++, HEX_STRING = HEX_STRING +"f", space += " ") - { - array[item++] = new TestCase( SECTION, "parseInt("+space+HEX_STRING+space+", void 0)", HEX_VALUE, parseInt(space+HEX_STRING+space, void 0) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } +new TestCase( SECTION, + "parseInt(\" 0XABCDEF ", + 11259375, + parseInt( " 0XABCDEF " ) ); - // a few tests with negative numbers - for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); - HEX_VALUE -= Math.pow(16,POWER)*15; - } +new TestCase( SECTION, + "parseInt( 0xabcdef )", + 11259375, + parseInt( "0xabcdef") ); - // we should stop parsing when we get to a value that is not a numeric literal for the type we expect +new TestCase( SECTION, + "parseInt( 0XABCDEF )", + 11259375, + parseInt( "0XABCDEF") ); - for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"g",16) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"G",16) ); - HEX_VALUE += Math.pow(16,POWER)*15; - } - - for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); - HEX_VALUE -= Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "-0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); - HEX_VALUE -= Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); - HEX_VALUE -= Math.pow(16,POWER)*15; - } - for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { - array[item++] = new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); - HEX_VALUE -= Math.pow(16,POWER)*15; - } - - // let us do some octal tests. numbers that start with 0 and do not provid a radix should - // default to using "0" as a radix. - - var OCT_STRING = "0"; - var OCT_VALUE = 0; - - for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); - OCT_VALUE += Math.pow(8,POWER)*7; - } - - for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); - OCT_VALUE -= Math.pow(8,POWER)*7; - } - - // should get the same results as above if we provid the radix of 8 (or 010) - - for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+",8)", OCT_VALUE, parseInt(OCT_STRING,8) ); - OCT_VALUE += Math.pow(8,POWER)*7; - } - for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+",010)", OCT_VALUE, parseInt(OCT_STRING,010) ); - OCT_VALUE -= Math.pow(8,POWER)*7; - } - - // we shall stop parsing digits when we get one that isn't a numeric literal of the type we think - // it should be. - for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+"8,8)", OCT_VALUE, parseInt(OCT_STRING+"8",8) ); - OCT_VALUE += Math.pow(8,POWER)*7; - } - for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { - array[item++] = new TestCase( SECTION, "parseInt("+OCT_STRING+"8,010)", OCT_VALUE, parseInt(OCT_STRING+"8",010) ); - OCT_VALUE -= Math.pow(8,POWER)*7; - } - - array[item++] = new TestCase( SECTION, "parseInt( '0x' )", NaN, parseInt("0x") ); - array[item++] = new TestCase( SECTION, "parseInt( '0X' )", NaN, parseInt("0X") ); - - array[item++] = new TestCase( SECTION, "parseInt( '11111111112222222222' )", 11111111112222222222, parseInt("11111111112222222222") ); - array[item++] = new TestCase( SECTION, "parseInt( '111111111122222222223' )", 111111111122222222220, parseInt("111111111122222222223") ); - array[item++] = new TestCase( SECTION, "parseInt( '11111111112222222222',10 )", 11111111112222222222, parseInt("11111111112222222222",10) ); - array[item++] = new TestCase( SECTION, "parseInt( '111111111122222222223',10 )", 111111111122222222220, parseInt("111111111122222222223",10) ); - - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', -1 )", Number.NaN, parseInt("01234567890",-1) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 0 )", Number.NaN, parseInt("01234567890",1) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 1 )", Number.NaN, parseInt("01234567890",1) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 2 )", 1, parseInt("01234567890",2) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 3 )", 5, parseInt("01234567890",3) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 4 )", 27, parseInt("01234567890",4) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 5 )", 194, parseInt("01234567890",5) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 6 )", 1865, parseInt("01234567890",6) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 7 )", 22875, parseInt("01234567890",7) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 8 )", 342391, parseInt("01234567890",8) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 9 )", 6053444, parseInt("01234567890",9) ); - array[item++] = new TestCase( SECTION, "parseInt( '01234567890', 10 )", 1234567890, parseInt("01234567890",10) ); - - // need more test cases with hex radix - - array[item++] = new TestCase( SECTION, "parseInt( '1234567890', '0xa')", 1234567890, parseInt("1234567890","0xa") ); - - array[item++] = new TestCase( SECTION, "parseInt( '012345', 11 )", 17715, parseInt("012345",11) ); - - array[item++] = new TestCase( SECTION, "parseInt( '012345', 35 )", 1590195, parseInt("012345",35) ); - array[item++] = new TestCase( SECTION, "parseInt( '012345', 36 )", 1776965, parseInt("012345",36) ); - array[item++] = new TestCase( SECTION, "parseInt( '012345', 37 )", Number.NaN, parseInt("012345",37) ); - - return ( array ); +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE += Math.pow(16,POWER)*15; } -function test( array ) { - for ( tc=0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( HEX_STRING = "0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE += Math.pow(16,POWER)*15; } +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",null)", HEX_VALUE, parseInt(HEX_STRING,null) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+", void 0)", HEX_VALUE, parseInt(HEX_STRING, void 0) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} + +// a few tests with spaces + +for ( var space = " ", HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; + POWER < 15; + POWER++, HEX_STRING = HEX_STRING +"f", space += " ") +{ + new TestCase( SECTION, "parseInt("+space+HEX_STRING+space+", void 0)", HEX_VALUE, parseInt(space+HEX_STRING+space, void 0) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} + +// a few tests with negative numbers +for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} + +// we should stop parsing when we get to a value that is not a numeric literal for the type we expect + +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"g",16) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+"g,16)", HEX_VALUE, parseInt(HEX_STRING+"G",16) ); + HEX_VALUE += Math.pow(16,POWER)*15; +} + +for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "-0X0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+")", HEX_VALUE, parseInt(HEX_STRING) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} +for ( HEX_STRING = "-0x0", HEX_VALUE = 0, POWER = 0; POWER < 15; POWER++, HEX_STRING = HEX_STRING +"f" ) { + new TestCase( SECTION, "parseInt("+HEX_STRING+",16)", HEX_VALUE, parseInt(HEX_STRING,16) ); + HEX_VALUE -= Math.pow(16,POWER)*15; +} + +// let us do some octal tests. numbers that start with 0 and do not provid a radix should +// default to using "0" as a radix. + +var OCT_STRING = "0"; +var OCT_VALUE = 0; + +for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); + OCT_VALUE += Math.pow(8,POWER)*7; +} + +for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+")", OCT_VALUE, parseInt(OCT_STRING) ); + OCT_VALUE -= Math.pow(8,POWER)*7; +} + +// should get the same results as above if we provid the radix of 8 (or 010) + +for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+",8)", OCT_VALUE, parseInt(OCT_STRING,8) ); + OCT_VALUE += Math.pow(8,POWER)*7; +} +for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+",010)", OCT_VALUE, parseInt(OCT_STRING,010) ); + OCT_VALUE -= Math.pow(8,POWER)*7; +} + +// we shall stop parsing digits when we get one that isn't a numeric literal of the type we think +// it should be. +for ( OCT_STRING = "0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+"8,8)", OCT_VALUE, parseInt(OCT_STRING+"8",8) ); + OCT_VALUE += Math.pow(8,POWER)*7; +} +for ( OCT_STRING = "-0", OCT_VALUE = 0, POWER = 0; POWER < 15; POWER++, OCT_STRING = OCT_STRING +"7" ) { + new TestCase( SECTION, "parseInt("+OCT_STRING+"8,010)", OCT_VALUE, parseInt(OCT_STRING+"8",010) ); + OCT_VALUE -= Math.pow(8,POWER)*7; +} + +new TestCase( SECTION, + "parseInt( '0x' )", + NaN, + parseInt("0x") ); + +new TestCase( SECTION, + "parseInt( '0X' )", + NaN, + parseInt("0X") ); + +new TestCase( SECTION, + "parseInt( '11111111112222222222' )", + 11111111112222222222, + parseInt("11111111112222222222") ); + +new TestCase( SECTION, + "parseInt( '111111111122222222223' )", + 111111111122222222220, + parseInt("111111111122222222223") ); + +new TestCase( SECTION, + "parseInt( '11111111112222222222',10 )", + 11111111112222222222, + parseInt("11111111112222222222",10) ); + +new TestCase( SECTION, + "parseInt( '111111111122222222223',10 )", + 111111111122222222220, + parseInt("111111111122222222223",10) ); + +new TestCase( SECTION, + "parseInt( '01234567890', -1 )", + Number.NaN, + parseInt("01234567890",-1) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 0 )", + Number.NaN, + parseInt("01234567890",1) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 1 )", + Number.NaN, + parseInt("01234567890",1) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 2 )", + 1, + parseInt("01234567890",2) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 3 )", + 5, + parseInt("01234567890",3) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 4 )", + 27, + parseInt("01234567890",4) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 5 )", + 194, + parseInt("01234567890",5) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 6 )", + 1865, + parseInt("01234567890",6) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 7 )", + 22875, + parseInt("01234567890",7) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 8 )", + 342391, + parseInt("01234567890",8) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 9 )", + 6053444, + parseInt("01234567890",9) ); + +new TestCase( SECTION, + "parseInt( '01234567890', 10 )", + 1234567890, + parseInt("01234567890",10) ); + +// need more test cases with hex radix + +new TestCase( SECTION, + "parseInt( '1234567890', '0xa')", + 1234567890, + parseInt("1234567890","0xa") ); + +new TestCase( SECTION, + "parseInt( '012345', 11 )", + 17715, + parseInt("012345",11) ); + +new TestCase( SECTION, + "parseInt( '012345', 35 )", + 1590195, + parseInt("012345",35) ); + +new TestCase( SECTION, + "parseInt( '012345', 36 )", + 1776965, + parseInt("012345",36) ); + +new TestCase( SECTION, + "parseInt( '012345', 37 )", + Number.NaN, + parseInt("012345",37) ); + +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.2-2.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.2-2.js index 2c0231c235a..8d02dd4ca51 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.2-2.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,161 +35,160 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.2.2-1.js - ECMA Section: 15.1.2.2 Function properties of the global object - parseInt( string, radix ) + File Name: 15.1.2.2-1.js + ECMA Section: 15.1.2.2 Function properties of the global object + parseInt( string, radix ) - Description: parseInt test cases written by waldemar, and documented in - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874. + Description: parseInt test cases written by waldemar, and documented in + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ var SECTION = "15.1.2.2-2"; var VERSION = "ECMA_1"; - startTest(); +startTest(); var TITLE = "parseInt(string, radix)"; var BUGNUMBER="123874"; writeHeaderToLog( SECTION + " "+ TITLE); -var testcases = new Array(); +new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)', + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("000000100000000100100011010001010110011110001001101010111100",2)', - 9027215253084860, - parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); +new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)', + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111101",2)); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("000000100000000100100011010001010110011110001001101010111101",2)', - 9027215253084860, - parseInt("000000100000000100100011010001010110011110001001101010111101",2)); +new TestCase( SECTION, + 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)', + 9027215253084864, + parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("000000100000000100100011010001010110011110001001101010111111",2)', - 9027215253084864, - parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); +new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)', + 18054430506169720, + parseInt("0000001000000001001000110100010101100111100010011010101111010",2) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)', - 18054430506169720, - parseInt("0000001000000001001000110100010101100111100010011010101111010",2) ); +new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)', + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111011",2)); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)', - 18054430506169724, - parseInt("0000001000000001001000110100010101100111100010011010101111011",2)); +new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)', + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111100",2) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)', - 18054430506169724, - parseInt("0000001000000001001000110100010101100111100010011010101111100",2) ); +new TestCase( SECTION, + 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)', + 18054430506169728, + parseInt("0000001000000001001000110100010101100111100010011010101111110",2) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)', - 18054430506169728, - parseInt("0000001000000001001000110100010101100111100010011010101111110",2) ); +new TestCase( SECTION, + 'parseInt("yz",35)', + 34, + parseInt("yz",35) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("yz",35)', - 34, - parseInt("yz",35) ); +new TestCase( SECTION, + 'parseInt("yz",36)', + 1259, + parseInt("yz",36) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("yz",36)', - 1259, - parseInt("yz",36) ); +new TestCase( SECTION, + 'parseInt("yz",37)', + NaN, + parseInt("yz",37) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("yz",37)', - NaN, - parseInt("yz",37) ); +new TestCase( SECTION, + 'parseInt("+77")', + 77, + parseInt("+77") ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("+77")', - 77, - parseInt("+77") ); +new TestCase( SECTION, + 'parseInt("-77",9)', + -70, + parseInt("-77",9) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("-77",9)', - -70, - parseInt("-77",9) ); +new TestCase( SECTION, + 'parseInt("\u20001234\u2000")', + 1234, + parseInt("\u20001234\u2000") ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("\u20001234\u2000")', - 1234, - parseInt("\u20001234\u2000") ); +new TestCase( SECTION, + 'parseInt("123456789012345678")', + 123456789012345680, + parseInt("123456789012345678") ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("123456789012345678")', - 123456789012345680, - parseInt("123456789012345678") ); +new TestCase( SECTION, + 'parseInt("9",8)', + NaN, + parseInt("9",8) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("9",8)', - NaN, - parseInt("9",8) ); +new TestCase( SECTION, + 'parseInt("1e2")', + 1, + parseInt("1e2") ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("1e2")', - 1, - parseInt("1e2") ); +new TestCase( SECTION, + 'parseInt("1.9999999999999999999")', + 1, + parseInt("1.9999999999999999999") ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("1.9999999999999999999")', - 1, - parseInt("1.9999999999999999999") ); +new TestCase( SECTION, + 'parseInt("0x10")', + 16, + parseInt("0x10") ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0x10")', - 16, - parseInt("0x10") ); +new TestCase( SECTION, + 'parseInt("0x10",10)', + 0, + parseInt("0x10",10)); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0x10",10)', - 0, - parseInt("0x10",10)); +new TestCase( SECTION, + 'parseInt("0022")', + 18, + parseInt("0022")); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0022")', - 18, - parseInt("0022")); +new TestCase( SECTION, + 'parseInt("0022",10)', + 22, + parseInt("0022",10) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0022",10)', - 22, - parseInt("0022",10) ); +new TestCase( SECTION, + 'parseInt("0x1000000000000080")', + 1152921504606847000, + parseInt("0x1000000000000080") ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0x1000000000000080")', - 1152921504606847000, - parseInt("0x1000000000000080") ); - -testcases[tc++] = new TestCase( SECTION, - 'parseInt("0x1000000000000081")', - 1152921504606847200, - parseInt("0x1000000000000081") ); +new TestCase( SECTION, + 'parseInt("0x1000000000000081")', + 1152921504606847200, + parseInt("0x1000000000000081") ); s = "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" s += "0000000000000000000000000000000000000"; -testcases[tc++] = new TestCase( SECTION, - "s = " + s +"; -s", - -1.7976931348623157e+308, - -s ); +new TestCase( SECTION, + "s = " + s +"; -s", + -1.7976931348623157e+308, + -s ); s = "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; s += "0000000000000000000000000000000000001"; -testcases[tc++] = new TestCase( SECTION, - "s = " + s +"; -s", - -1.7976931348623157e+308, - -s ); +new TestCase( SECTION, + "s = " + s +"; -s", + -1.7976931348623157e+308, + -s ); s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; @@ -196,52 +196,40 @@ s = "0xFFFFFFFFFFFFFC00000000000000000000000000000000000000000000000000000000000 s += "0000000000000000000000000000000000000" -testcases[tc++] = new TestCase( SECTION, - "s = " + s + "; -s", - -Infinity, - -s ); +new TestCase( SECTION, + "s = " + s + "; -s", + -Infinity, + -s ); s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; s += "0000000000000000000000000000000000001"; -testcases[tc++] = new TestCase( SECTION, - "s = " + s + "; -s", - -1.7976931348623157e+308, - -s ); +new TestCase( SECTION, + "s = " + s + "; -s", + -1.7976931348623157e+308, + -s ); s += "0" -testcases[tc++] = new TestCase( SECTION, - "s = " + s + "; -s", - -Infinity, - -s ); +new TestCase( SECTION, + "s = " + s + "; -s", + -Infinity, + -s ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt(s)', - Infinity, - parseInt(s) ); +new TestCase( SECTION, + 'parseInt(s)', + Infinity, + parseInt(s) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt(s,32)', - 0, - parseInt(s,32) ); +new TestCase( SECTION, + 'parseInt(s,32)', + 0, + parseInt(s,32) ); -testcases[tc++] = new TestCase( SECTION, - 'parseInt(s,36)', - Infinity, - parseInt(s,36)); +new TestCase( SECTION, + 'parseInt(s,36)', + Infinity, + parseInt(s,36)); test(); -function test( array ) { - for ( tc=0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.3-1.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.3-1.js index 6b5bd951961..6b99c97b30f 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.3-1.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,425 +36,403 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.1.2.3.js - ECMA Section: 15.1.2.3 Function properties of the global object: - parseFloat( string ) + File Name: 15.1.2.3.js + ECMA Section: 15.1.2.3 Function properties of the global object: + parseFloat( string ) - Description: The parseFloat function produces a number value dictated - by the interpretation of the contents of the string - argument defined as a decimal literal. + Description: The parseFloat function produces a number value dictated + by the interpretation of the contents of the string + argument defined as a decimal literal. - When the parseFloat function is called, the following - steps are taken: + When the parseFloat function is called, the following + steps are taken: - 1. Call ToString( string ). - 2. Remove leading whitespace Result(1). - 3. If neither Result(2) nor any prefix of Result(2) - satisfies the syntax of a StrDecimalLiteral, - return NaN. - 4. Compute the longest prefix of Result(2) which might - be Resusult(2) itself, that satisfies the syntax of - a StrDecimalLiteral - 5. Return the number value for the MV of Result(4). + 1. Call ToString( string ). + 2. Remove leading whitespace Result(1). + 3. If neither Result(2) nor any prefix of Result(2) + satisfies the syntax of a StrDecimalLiteral, + return NaN. + 4. Compute the longest prefix of Result(2) which might + be Resusult(2) itself, that satisfies the syntax of + a StrDecimalLiteral + 5. Return the number value for the MV of Result(4). - Note that parseFloate may interpret only a leading - portion of the string as a number value; it ignores any - characters that cannot be interpreted as part of the - notation of a decimal literal, and no indication is given - that such characters were ignored. + Note that parseFloate may interpret only a leading + portion of the string as a number value; it ignores any + characters that cannot be interpreted as part of the + notation of a decimal literal, and no indication is given + that such characters were ignored. - StrDecimalLiteral:: - Infinity - DecimalDigits.DecimalDigits opt ExponentPart opt - .DecimalDigits ExponentPart opt - DecimalDigits ExponentPart opt + StrDecimalLiteral:: + Infinity + DecimalDigits.DecimalDigits opt ExponentPart opt + .DecimalDigits ExponentPart opt + DecimalDigits ExponentPart opt - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.2.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "parseFloat(string)"; - var BUGNUMBER= "77391"; +var SECTION = "15.1.2.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "parseFloat(string)"; +var BUGNUMBER= "77391"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length ); - test(); +new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") ); +new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length ); +new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") ); +new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") ); +new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() ); +new TestCase( SECTION, "parseFloat('')", Number.NaN, parseFloat('') ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "parseFloat(' ')", Number.NaN, parseFloat(' ') ); +new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); +new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); +new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); - array[item++] = new TestCase( SECTION, "parseFloat.length", 1, parseFloat.length ); +new TestCase( SECTION, "parseFloat(' Infinity')", Infinity, parseFloat("Infinity") ); +new TestCase( SECTION, "parseFloat(' Infinity ')", Infinity, parseFloat(' Infinity ') ); - array[item++] = new TestCase( SECTION, "parseFloat.length = null; parseFloat.length", 1, eval("parseFloat.length = null; parseFloat.length") ); - array[item++] = new TestCase( SECTION, "delete parseFloat.length", false, delete parseFloat.length ); - array[item++] = new TestCase( SECTION, "delete parseFloat.length; parseFloat.length", 1, eval("delete parseFloat.length; parseFloat.length") ); - array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in parseFloat ) { MYPROPS += p }; MYPROPS") ); +new TestCase( SECTION, "parseFloat('Infinity')", Infinity, parseFloat("Infinity") ); +new TestCase( SECTION, "parseFloat(Infinity)", Infinity, parseFloat(Infinity) ); - array[item++] = new TestCase( SECTION, "parseFloat()", Number.NaN, parseFloat() ); - array[item++] = new TestCase( SECTION, "parseFloat('')", Number.NaN, parseFloat('') ); - array[item++] = new TestCase( SECTION, "parseFloat(' ')", Number.NaN, parseFloat(' ') ); - array[item++] = new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); - array[item++] = new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); - array[item++] = new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); +new TestCase( SECTION, "parseFloat(' +Infinity')", +Infinity, parseFloat("+Infinity") ); +new TestCase( SECTION, "parseFloat(' -Infinity ')", -Infinity, parseFloat(' -Infinity ') ); - array[item++] = new TestCase( SECTION, "parseFloat(' Infinity')", Infinity, parseFloat("Infinity") ); - array[item++] = new TestCase( SECTION, "parseFloat(' Infinity ')", Infinity, parseFloat(' Infinity ') ); +new TestCase( SECTION, "parseFloat('+Infinity')", +Infinity, parseFloat("+Infinity") ); +new TestCase( SECTION, "parseFloat(-Infinity)", -Infinity, parseFloat(-Infinity) ); - array[item++] = new TestCase( SECTION, "parseFloat('Infinity')", Infinity, parseFloat("Infinity") ); - array[item++] = new TestCase( SECTION, "parseFloat(Infinity)", Infinity, parseFloat(Infinity) ); +new TestCase( SECTION, "parseFloat('0')", 0, parseFloat("0") ); +new TestCase( SECTION, "parseFloat('-0')", -0, parseFloat("-0") ); +new TestCase( SECTION, "parseFloat('+0')", 0, parseFloat("+0") ); +new TestCase( SECTION, "parseFloat('1')", 1, parseFloat("1") ); +new TestCase( SECTION, "parseFloat('-1')", -1, parseFloat("-1") ); +new TestCase( SECTION, "parseFloat('+1')", 1, parseFloat("+1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +Infinity')", +Infinity, parseFloat("+Infinity") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -Infinity ')", -Infinity, parseFloat(' -Infinity ') ); +new TestCase( SECTION, "parseFloat('2')", 2, parseFloat("2") ); +new TestCase( SECTION, "parseFloat('-2')", -2, parseFloat("-2") ); +new TestCase( SECTION, "parseFloat('+2')", 2, parseFloat("+2") ); - array[item++] = new TestCase( SECTION, "parseFloat('+Infinity')", +Infinity, parseFloat("+Infinity") ); - array[item++] = new TestCase( SECTION, "parseFloat(-Infinity)", -Infinity, parseFloat(-Infinity) ); +new TestCase( SECTION, "parseFloat('3')", 3, parseFloat("3") ); +new TestCase( SECTION, "parseFloat('-3')", -3, parseFloat("-3") ); +new TestCase( SECTION, "parseFloat('+3')", 3, parseFloat("+3") ); - array[item++] = new TestCase( SECTION, "parseFloat('0')", 0, parseFloat("0") ); - array[item++] = new TestCase( SECTION, "parseFloat('-0')", -0, parseFloat("-0") ); - array[item++] = new TestCase( SECTION, "parseFloat('+0')", 0, parseFloat("+0") ); +new TestCase( SECTION, "parseFloat('4')", 4, parseFloat("4") ); +new TestCase( SECTION, "parseFloat('-4')", -4, parseFloat("-4") ); +new TestCase( SECTION, "parseFloat('+4')", 4, parseFloat("+4") ); - array[item++] = new TestCase( SECTION, "parseFloat('1')", 1, parseFloat("1") ); - array[item++] = new TestCase( SECTION, "parseFloat('-1')", -1, parseFloat("-1") ); - array[item++] = new TestCase( SECTION, "parseFloat('+1')", 1, parseFloat("+1") ); +new TestCase( SECTION, "parseFloat('5')", 5, parseFloat("5") ); +new TestCase( SECTION, "parseFloat('-5')", -5, parseFloat("-5") ); +new TestCase( SECTION, "parseFloat('+5')", 5, parseFloat("+5") ); - array[item++] = new TestCase( SECTION, "parseFloat('2')", 2, parseFloat("2") ); - array[item++] = new TestCase( SECTION, "parseFloat('-2')", -2, parseFloat("-2") ); - array[item++] = new TestCase( SECTION, "parseFloat('+2')", 2, parseFloat("+2") ); +new TestCase( SECTION, "parseFloat('6')", 6, parseFloat("6") ); +new TestCase( SECTION, "parseFloat('-6')", -6, parseFloat("-6") ); +new TestCase( SECTION, "parseFloat('+6')", 6, parseFloat("+6") ); - array[item++] = new TestCase( SECTION, "parseFloat('3')", 3, parseFloat("3") ); - array[item++] = new TestCase( SECTION, "parseFloat('-3')", -3, parseFloat("-3") ); - array[item++] = new TestCase( SECTION, "parseFloat('+3')", 3, parseFloat("+3") ); +new TestCase( SECTION, "parseFloat('7')", 7, parseFloat("7") ); +new TestCase( SECTION, "parseFloat('-7')", -7, parseFloat("-7") ); +new TestCase( SECTION, "parseFloat('+7')", 7, parseFloat("+7") ); - array[item++] = new TestCase( SECTION, "parseFloat('4')", 4, parseFloat("4") ); - array[item++] = new TestCase( SECTION, "parseFloat('-4')", -4, parseFloat("-4") ); - array[item++] = new TestCase( SECTION, "parseFloat('+4')", 4, parseFloat("+4") ); +new TestCase( SECTION, "parseFloat('8')", 8, parseFloat("8") ); +new TestCase( SECTION, "parseFloat('-8')", -8, parseFloat("-8") ); +new TestCase( SECTION, "parseFloat('+8')", 8, parseFloat("+8") ); - array[item++] = new TestCase( SECTION, "parseFloat('5')", 5, parseFloat("5") ); - array[item++] = new TestCase( SECTION, "parseFloat('-5')", -5, parseFloat("-5") ); - array[item++] = new TestCase( SECTION, "parseFloat('+5')", 5, parseFloat("+5") ); +new TestCase( SECTION, "parseFloat('9')", 9, parseFloat("9") ); +new TestCase( SECTION, "parseFloat('-9')", -9, parseFloat("-9") ); +new TestCase( SECTION, "parseFloat('+9')", 9, parseFloat("+9") ); - array[item++] = new TestCase( SECTION, "parseFloat('6')", 6, parseFloat("6") ); - array[item++] = new TestCase( SECTION, "parseFloat('-6')", -6, parseFloat("-6") ); - array[item++] = new TestCase( SECTION, "parseFloat('+6')", 6, parseFloat("+6") ); +new TestCase( SECTION, "parseFloat('3.14159')", 3.14159, parseFloat("3.14159") ); +new TestCase( SECTION, "parseFloat('-3.14159')", -3.14159, parseFloat("-3.14159") ); +new TestCase( SECTION, "parseFloat('+3.14159')", 3.14159, parseFloat("+3.14159") ); - array[item++] = new TestCase( SECTION, "parseFloat('7')", 7, parseFloat("7") ); - array[item++] = new TestCase( SECTION, "parseFloat('-7')", -7, parseFloat("-7") ); - array[item++] = new TestCase( SECTION, "parseFloat('+7')", 7, parseFloat("+7") ); +new TestCase( SECTION, "parseFloat('3.')", 3, parseFloat("3.") ); +new TestCase( SECTION, "parseFloat('-3.')", -3, parseFloat("-3.") ); +new TestCase( SECTION, "parseFloat('+3.')", 3, parseFloat("+3.") ); - array[item++] = new TestCase( SECTION, "parseFloat('8')", 8, parseFloat("8") ); - array[item++] = new TestCase( SECTION, "parseFloat('-8')", -8, parseFloat("-8") ); - array[item++] = new TestCase( SECTION, "parseFloat('+8')", 8, parseFloat("+8") ); +new TestCase( SECTION, "parseFloat('3.e1')", 30, parseFloat("3.e1") ); +new TestCase( SECTION, "parseFloat('-3.e1')", -30, parseFloat("-3.e1") ); +new TestCase( SECTION, "parseFloat('+3.e1')", 30, parseFloat("+3.e1") ); - array[item++] = new TestCase( SECTION, "parseFloat('9')", 9, parseFloat("9") ); - array[item++] = new TestCase( SECTION, "parseFloat('-9')", -9, parseFloat("-9") ); - array[item++] = new TestCase( SECTION, "parseFloat('+9')", 9, parseFloat("+9") ); +new TestCase( SECTION, "parseFloat('3.e+1')", 30, parseFloat("3.e+1") ); +new TestCase( SECTION, "parseFloat('-3.e+1')", -30, parseFloat("-3.e+1") ); +new TestCase( SECTION, "parseFloat('+3.e+1')", 30, parseFloat("+3.e+1") ); - array[item++] = new TestCase( SECTION, "parseFloat('3.14159')", 3.14159, parseFloat("3.14159") ); - array[item++] = new TestCase( SECTION, "parseFloat('-3.14159')", -3.14159, parseFloat("-3.14159") ); - array[item++] = new TestCase( SECTION, "parseFloat('+3.14159')", 3.14159, parseFloat("+3.14159") ); +new TestCase( SECTION, "parseFloat('3.e-1')", .30, parseFloat("3.e-1") ); +new TestCase( SECTION, "parseFloat('-3.e-1')", -.30, parseFloat("-3.e-1") ); +new TestCase( SECTION, "parseFloat('+3.e-1')", .30, parseFloat("+3.e-1") ); - array[item++] = new TestCase( SECTION, "parseFloat('3.')", 3, parseFloat("3.") ); - array[item++] = new TestCase( SECTION, "parseFloat('-3.')", -3, parseFloat("-3.") ); - array[item++] = new TestCase( SECTION, "parseFloat('+3.')", 3, parseFloat("+3.") ); +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt - array[item++] = new TestCase( SECTION, "parseFloat('3.e1')", 30, parseFloat("3.e1") ); - array[item++] = new TestCase( SECTION, "parseFloat('-3.e1')", -30, parseFloat("-3.e1") ); - array[item++] = new TestCase( SECTION, "parseFloat('+3.e1')", 30, parseFloat("+3.e1") ); +new TestCase( SECTION, "parseFloat('.00001')", 0.00001, parseFloat(".00001") ); +new TestCase( SECTION, "parseFloat('+.00001')", 0.00001, parseFloat("+.00001") ); +new TestCase( SECTION, "parseFloat('-0.0001')", -0.00001, parseFloat("-.00001") ); - array[item++] = new TestCase( SECTION, "parseFloat('3.e+1')", 30, parseFloat("3.e+1") ); - array[item++] = new TestCase( SECTION, "parseFloat('-3.e+1')", -30, parseFloat("-3.e+1") ); - array[item++] = new TestCase( SECTION, "parseFloat('+3.e+1')", 30, parseFloat("+3.e+1") ); +new TestCase( SECTION, "parseFloat('.01e2')", 1, parseFloat(".01e2") ); +new TestCase( SECTION, "parseFloat('+.01e2')", 1, parseFloat("+.01e2") ); +new TestCase( SECTION, "parseFloat('-.01e2')", -1, parseFloat("-.01e2") ); - array[item++] = new TestCase( SECTION, "parseFloat('3.e-1')", .30, parseFloat("3.e-1") ); - array[item++] = new TestCase( SECTION, "parseFloat('-3.e-1')", -.30, parseFloat("-3.e-1") ); - array[item++] = new TestCase( SECTION, "parseFloat('+3.e-1')", .30, parseFloat("+3.e-1") ); +new TestCase( SECTION, "parseFloat('.01e+2')", 1, parseFloat(".01e+2") ); +new TestCase( SECTION, "parseFloat('+.01e+2')", 1, parseFloat("+.01e+2") ); +new TestCase( SECTION, "parseFloat('-.01e+2')", -1, parseFloat("-.01e+2") ); - // StrDecimalLiteral::: .DecimalDigits ExponentPart opt +new TestCase( SECTION, "parseFloat('.01e-2')", 0.0001, parseFloat(".01e-2") ); +new TestCase( SECTION, "parseFloat('+.01e-2')", 0.0001, parseFloat("+.01e-2") ); +new TestCase( SECTION, "parseFloat('-.01e-2')", -0.0001, parseFloat("-.01e-2") ); - array[item++] = new TestCase( SECTION, "parseFloat('.00001')", 0.00001, parseFloat(".00001") ); - array[item++] = new TestCase( SECTION, "parseFloat('+.00001')", 0.00001, parseFloat("+.00001") ); - array[item++] = new TestCase( SECTION, "parseFloat('-0.0001')", -0.00001, parseFloat("-.00001") ); +// StrDecimalLiteral::: DecimalDigits ExponentPart opt - array[item++] = new TestCase( SECTION, "parseFloat('.01e2')", 1, parseFloat(".01e2") ); - array[item++] = new TestCase( SECTION, "parseFloat('+.01e2')", 1, parseFloat("+.01e2") ); - array[item++] = new TestCase( SECTION, "parseFloat('-.01e2')", -1, parseFloat("-.01e2") ); +new TestCase( SECTION, "parseFloat('1234e5')", 123400000, parseFloat("1234e5") ); +new TestCase( SECTION, "parseFloat('+1234e5')", 123400000, parseFloat("+1234e5") ); +new TestCase( SECTION, "parseFloat('-1234e5')", -123400000, parseFloat("-1234e5") ); - array[item++] = new TestCase( SECTION, "parseFloat('.01e+2')", 1, parseFloat(".01e+2") ); - array[item++] = new TestCase( SECTION, "parseFloat('+.01e+2')", 1, parseFloat("+.01e+2") ); - array[item++] = new TestCase( SECTION, "parseFloat('-.01e+2')", -1, parseFloat("-.01e+2") ); +new TestCase( SECTION, "parseFloat('1234e+5')", 123400000, parseFloat("1234e+5") ); +new TestCase( SECTION, "parseFloat('+1234e+5')", 123400000, parseFloat("+1234e+5") ); +new TestCase( SECTION, "parseFloat('-1234e+5')", -123400000, parseFloat("-1234e+5") ); - array[item++] = new TestCase( SECTION, "parseFloat('.01e-2')", 0.0001, parseFloat(".01e-2") ); - array[item++] = new TestCase( SECTION, "parseFloat('+.01e-2')", 0.0001, parseFloat("+.01e-2") ); - array[item++] = new TestCase( SECTION, "parseFloat('-.01e-2')", -0.0001, parseFloat("-.01e-2") ); +new TestCase( SECTION, "parseFloat('1234e-5')", 0.01234, parseFloat("1234e-5") ); +new TestCase( SECTION, "parseFloat('+1234e-5')", 0.01234, parseFloat("+1234e-5") ); +new TestCase( SECTION, "parseFloat('-1234e-5')", -0.01234, parseFloat("-1234e-5") ); - // StrDecimalLiteral::: DecimalDigits ExponentPart opt - array[item++] = new TestCase( SECTION, "parseFloat('1234e5')", 123400000, parseFloat("1234e5") ); - array[item++] = new TestCase( SECTION, "parseFloat('+1234e5')", 123400000, parseFloat("+1234e5") ); - array[item++] = new TestCase( SECTION, "parseFloat('-1234e5')", -123400000, parseFloat("-1234e5") ); +new TestCase( SECTION, "parseFloat(0)", 0, parseFloat(0) ); +new TestCase( SECTION, "parseFloat(-0)", -0, parseFloat(-0) ); - array[item++] = new TestCase( SECTION, "parseFloat('1234e+5')", 123400000, parseFloat("1234e+5") ); - array[item++] = new TestCase( SECTION, "parseFloat('+1234e+5')", 123400000, parseFloat("+1234e+5") ); - array[item++] = new TestCase( SECTION, "parseFloat('-1234e+5')", -123400000, parseFloat("-1234e+5") ); +new TestCase( SECTION, "parseFloat(1)", 1, parseFloat(1) ); +new TestCase( SECTION, "parseFloat(-1)", -1, parseFloat(-1) ); - array[item++] = new TestCase( SECTION, "parseFloat('1234e-5')", 0.01234, parseFloat("1234e-5") ); - array[item++] = new TestCase( SECTION, "parseFloat('+1234e-5')", 0.01234, parseFloat("+1234e-5") ); - array[item++] = new TestCase( SECTION, "parseFloat('-1234e-5')", -0.01234, parseFloat("-1234e-5") ); +new TestCase( SECTION, "parseFloat(2)", 2, parseFloat(2) ); +new TestCase( SECTION, "parseFloat(-2)", -2, parseFloat(-2) ); +new TestCase( SECTION, "parseFloat(3)", 3, parseFloat(3) ); +new TestCase( SECTION, "parseFloat(-3)", -3, parseFloat(-3) ); - array[item++] = new TestCase( SECTION, "parseFloat(0)", 0, parseFloat(0) ); - array[item++] = new TestCase( SECTION, "parseFloat(-0)", -0, parseFloat(-0) ); +new TestCase( SECTION, "parseFloat(4)", 4, parseFloat(4) ); +new TestCase( SECTION, "parseFloat(-4)", -4, parseFloat(-4) ); - array[item++] = new TestCase( SECTION, "parseFloat(1)", 1, parseFloat(1) ); - array[item++] = new TestCase( SECTION, "parseFloat(-1)", -1, parseFloat(-1) ); +new TestCase( SECTION, "parseFloat(5)", 5, parseFloat(5) ); +new TestCase( SECTION, "parseFloat(-5)", -5, parseFloat(-5) ); - array[item++] = new TestCase( SECTION, "parseFloat(2)", 2, parseFloat(2) ); - array[item++] = new TestCase( SECTION, "parseFloat(-2)", -2, parseFloat(-2) ); +new TestCase( SECTION, "parseFloat(6)", 6, parseFloat(6) ); +new TestCase( SECTION, "parseFloat(-6)", -6, parseFloat(-6) ); - array[item++] = new TestCase( SECTION, "parseFloat(3)", 3, parseFloat(3) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3)", -3, parseFloat(-3) ); +new TestCase( SECTION, "parseFloat(7)", 7, parseFloat(7) ); +new TestCase( SECTION, "parseFloat(-7)", -7, parseFloat(-7) ); - array[item++] = new TestCase( SECTION, "parseFloat(4)", 4, parseFloat(4) ); - array[item++] = new TestCase( SECTION, "parseFloat(-4)", -4, parseFloat(-4) ); +new TestCase( SECTION, "parseFloat(8)", 8, parseFloat(8) ); +new TestCase( SECTION, "parseFloat(-8)", -8, parseFloat(-8) ); - array[item++] = new TestCase( SECTION, "parseFloat(5)", 5, parseFloat(5) ); - array[item++] = new TestCase( SECTION, "parseFloat(-5)", -5, parseFloat(-5) ); +new TestCase( SECTION, "parseFloat(9)", 9, parseFloat(9) ); +new TestCase( SECTION, "parseFloat(-9)", -9, parseFloat(-9) ); - array[item++] = new TestCase( SECTION, "parseFloat(6)", 6, parseFloat(6) ); - array[item++] = new TestCase( SECTION, "parseFloat(-6)", -6, parseFloat(-6) ); +new TestCase( SECTION, "parseFloat(3.14159)", 3.14159, parseFloat(3.14159) ); +new TestCase( SECTION, "parseFloat(-3.14159)", -3.14159, parseFloat(-3.14159) ); - array[item++] = new TestCase( SECTION, "parseFloat(7)", 7, parseFloat(7) ); - array[item++] = new TestCase( SECTION, "parseFloat(-7)", -7, parseFloat(-7) ); +new TestCase( SECTION, "parseFloat(3.)", 3, parseFloat(3.) ); +new TestCase( SECTION, "parseFloat(-3.)", -3, parseFloat(-3.) ); - array[item++] = new TestCase( SECTION, "parseFloat(8)", 8, parseFloat(8) ); - array[item++] = new TestCase( SECTION, "parseFloat(-8)", -8, parseFloat(-8) ); +new TestCase( SECTION, "parseFloat(3.e1)", 30, parseFloat(3.e1) ); +new TestCase( SECTION, "parseFloat(-3.e1)", -30, parseFloat(-3.e1) ); - array[item++] = new TestCase( SECTION, "parseFloat(9)", 9, parseFloat(9) ); - array[item++] = new TestCase( SECTION, "parseFloat(-9)", -9, parseFloat(-9) ); - - array[item++] = new TestCase( SECTION, "parseFloat(3.14159)", 3.14159, parseFloat(3.14159) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3.14159)", -3.14159, parseFloat(-3.14159) ); - - array[item++] = new TestCase( SECTION, "parseFloat(3.)", 3, parseFloat(3.) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3.)", -3, parseFloat(-3.) ); - - array[item++] = new TestCase( SECTION, "parseFloat(3.e1)", 30, parseFloat(3.e1) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3.e1)", -30, parseFloat(-3.e1) ); - - array[item++] = new TestCase( SECTION, "parseFloat(3.e+1)", 30, parseFloat(3.e+1) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3.e+1)", -30, parseFloat(-3.e+1) ); - - array[item++] = new TestCase( SECTION, "parseFloat(3.e-1)", .30, parseFloat(3.e-1) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3.e-1)", -.30, parseFloat(-3.e-1) ); - - - array[item++] = new TestCase( SECTION, "parseFloat(3.E1)", 30, parseFloat(3.E1) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3.E1)", -30, parseFloat(-3.E1) ); - - array[item++] = new TestCase( SECTION, "parseFloat(3.E+1)", 30, parseFloat(3.E+1) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3.E+1)", -30, parseFloat(-3.E+1) ); - - array[item++] = new TestCase( SECTION, "parseFloat(3.E-1)", .30, parseFloat(3.E-1) ); - array[item++] = new TestCase( SECTION, "parseFloat(-3.E-1)", -.30, parseFloat(-3.E-1) ); - - // StrDecimalLiteral::: .DecimalDigits ExponentPart opt - - array[item++] = new TestCase( SECTION, "parseFloat(.00001)", 0.00001, parseFloat(.00001) ); - array[item++] = new TestCase( SECTION, "parseFloat(-0.0001)", -0.00001, parseFloat(-.00001) ); - - array[item++] = new TestCase( SECTION, "parseFloat(.01e2)", 1, parseFloat(.01e2) ); - array[item++] = new TestCase( SECTION, "parseFloat(-.01e2)", -1, parseFloat(-.01e2) ); - - array[item++] = new TestCase( SECTION, "parseFloat(.01e+2)", 1, parseFloat(.01e+2) ); - array[item++] = new TestCase( SECTION, "parseFloat(-.01e+2)", -1, parseFloat(-.01e+2) ); - - array[item++] = new TestCase( SECTION, "parseFloat(.01e-2)", 0.0001, parseFloat(.01e-2) ); - array[item++] = new TestCase( SECTION, "parseFloat(-.01e-2)", -0.0001, parseFloat(-.01e-2) ); - - // StrDecimalLiteral::: DecimalDigits ExponentPart opt - - array[item++] = new TestCase( SECTION, "parseFloat(1234e5)", 123400000, parseFloat(1234e5) ); - array[item++] = new TestCase( SECTION, "parseFloat(-1234e5)", -123400000, parseFloat(-1234e5) ); - - array[item++] = new TestCase( SECTION, "parseFloat(1234e+5)", 123400000, parseFloat(1234e+5) ); - array[item++] = new TestCase( SECTION, "parseFloat(-1234e+5)", -123400000, parseFloat(-1234e+5) ); - - array[item++] = new TestCase( SECTION, "parseFloat(1234e-5)", 0.01234, parseFloat(1234e-5) ); - array[item++] = new TestCase( SECTION, "parseFloat(-1234e-5)", -0.01234, parseFloat(-1234e-5) ); - - // hex cases should all return 0 (0 is the longest string that satisfies a StringDecimalLiteral) - - array[item++] = new TestCase( SECTION, "parseFloat('0x0')", 0, parseFloat("0x0")); - array[item++] = new TestCase( SECTION, "parseFloat('0x1')", 0, parseFloat("0x1")); - array[item++] = new TestCase( SECTION, "parseFloat('0x2')", 0, parseFloat("0x2")); - array[item++] = new TestCase( SECTION, "parseFloat('0x3')", 0, parseFloat("0x3")); - array[item++] = new TestCase( SECTION, "parseFloat('0x4')", 0, parseFloat("0x4")); - array[item++] = new TestCase( SECTION, "parseFloat('0x5')", 0, parseFloat("0x5")); - array[item++] = new TestCase( SECTION, "parseFloat('0x6')", 0, parseFloat("0x6")); - array[item++] = new TestCase( SECTION, "parseFloat('0x7')", 0, parseFloat("0x7")); - array[item++] = new TestCase( SECTION, "parseFloat('0x8')", 0, parseFloat("0x8")); - array[item++] = new TestCase( SECTION, "parseFloat('0x9')", 0, parseFloat("0x9")); - array[item++] = new TestCase( SECTION, "parseFloat('0xa')", 0, parseFloat("0xa")); - array[item++] = new TestCase( SECTION, "parseFloat('0xb')", 0, parseFloat("0xb")); - array[item++] = new TestCase( SECTION, "parseFloat('0xc')", 0, parseFloat("0xc")); - array[item++] = new TestCase( SECTION, "parseFloat('0xd')", 0, parseFloat("0xd")); - array[item++] = new TestCase( SECTION, "parseFloat('0xe')", 0, parseFloat("0xe")); - array[item++] = new TestCase( SECTION, "parseFloat('0xf')", 0, parseFloat("0xf")); - array[item++] = new TestCase( SECTION, "parseFloat('0xA')", 0, parseFloat("0xA")); - array[item++] = new TestCase( SECTION, "parseFloat('0xB')", 0, parseFloat("0xB")); - array[item++] = new TestCase( SECTION, "parseFloat('0xC')", 0, parseFloat("0xC")); - array[item++] = new TestCase( SECTION, "parseFloat('0xD')", 0, parseFloat("0xD")); - array[item++] = new TestCase( SECTION, "parseFloat('0xE')", 0, parseFloat("0xE")); - array[item++] = new TestCase( SECTION, "parseFloat('0xF')", 0, parseFloat("0xF")); - - array[item++] = new TestCase( SECTION, "parseFloat('0X0')", 0, parseFloat("0X0")); - array[item++] = new TestCase( SECTION, "parseFloat('0X1')", 0, parseFloat("0X1")); - array[item++] = new TestCase( SECTION, "parseFloat('0X2')", 0, parseFloat("0X2")); - array[item++] = new TestCase( SECTION, "parseFloat('0X3')", 0, parseFloat("0X3")); - array[item++] = new TestCase( SECTION, "parseFloat('0X4')", 0, parseFloat("0X4")); - array[item++] = new TestCase( SECTION, "parseFloat('0X5')", 0, parseFloat("0X5")); - array[item++] = new TestCase( SECTION, "parseFloat('0X6')", 0, parseFloat("0X6")); - array[item++] = new TestCase( SECTION, "parseFloat('0X7')", 0, parseFloat("0X7")); - array[item++] = new TestCase( SECTION, "parseFloat('0X8')", 0, parseFloat("0X8")); - array[item++] = new TestCase( SECTION, "parseFloat('0X9')", 0, parseFloat("0X9")); - array[item++] = new TestCase( SECTION, "parseFloat('0Xa')", 0, parseFloat("0Xa")); - array[item++] = new TestCase( SECTION, "parseFloat('0Xb')", 0, parseFloat("0Xb")); - array[item++] = new TestCase( SECTION, "parseFloat('0Xc')", 0, parseFloat("0Xc")); - array[item++] = new TestCase( SECTION, "parseFloat('0Xd')", 0, parseFloat("0Xd")); - array[item++] = new TestCase( SECTION, "parseFloat('0Xe')", 0, parseFloat("0Xe")); - array[item++] = new TestCase( SECTION, "parseFloat('0Xf')", 0, parseFloat("0Xf")); - array[item++] = new TestCase( SECTION, "parseFloat('0XA')", 0, parseFloat("0XA")); - array[item++] = new TestCase( SECTION, "parseFloat('0XB')", 0, parseFloat("0XB")); - array[item++] = new TestCase( SECTION, "parseFloat('0XC')", 0, parseFloat("0XC")); - array[item++] = new TestCase( SECTION, "parseFloat('0XD')", 0, parseFloat("0XD")); - array[item++] = new TestCase( SECTION, "parseFloat('0XE')", 0, parseFloat("0XE")); - array[item++] = new TestCase( SECTION, "parseFloat('0XF')", 0, parseFloat("0XF")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0XF ')", 0, parseFloat(" 0XF ")); - - // hex literals should still succeed - - array[item++] = new TestCase( SECTION, "parseFloat(0x0)", 0, parseFloat(0x0)); - array[item++] = new TestCase( SECTION, "parseFloat(0x1)", 1, parseFloat(0x1)); - array[item++] = new TestCase( SECTION, "parseFloat(0x2)", 2, parseFloat(0x2)); - array[item++] = new TestCase( SECTION, "parseFloat(0x3)", 3, parseFloat(0x3)); - array[item++] = new TestCase( SECTION, "parseFloat(0x4)", 4, parseFloat(0x4)); - array[item++] = new TestCase( SECTION, "parseFloat(0x5)", 5, parseFloat(0x5)); - array[item++] = new TestCase( SECTION, "parseFloat(0x6)", 6, parseFloat(0x6)); - array[item++] = new TestCase( SECTION, "parseFloat(0x7)", 7, parseFloat(0x7)); - array[item++] = new TestCase( SECTION, "parseFloat(0x8)", 8, parseFloat(0x8)); - array[item++] = new TestCase( SECTION, "parseFloat(0x9)", 9, parseFloat(0x9)); - array[item++] = new TestCase( SECTION, "parseFloat(0xa)", 10, parseFloat(0xa)); - array[item++] = new TestCase( SECTION, "parseFloat(0xb)", 11, parseFloat(0xb)); - array[item++] = new TestCase( SECTION, "parseFloat(0xc)", 12, parseFloat(0xc)); - array[item++] = new TestCase( SECTION, "parseFloat(0xd)", 13, parseFloat(0xd)); - array[item++] = new TestCase( SECTION, "parseFloat(0xe)", 14, parseFloat(0xe)); - array[item++] = new TestCase( SECTION, "parseFloat(0xf)", 15, parseFloat(0xf)); - array[item++] = new TestCase( SECTION, "parseFloat(0xA)", 10, parseFloat(0xA)); - array[item++] = new TestCase( SECTION, "parseFloat(0xB)", 11, parseFloat(0xB)); - array[item++] = new TestCase( SECTION, "parseFloat(0xC)", 12, parseFloat(0xC)); - array[item++] = new TestCase( SECTION, "parseFloat(0xD)", 13, parseFloat(0xD)); - array[item++] = new TestCase( SECTION, "parseFloat(0xE)", 14, parseFloat(0xE)); - array[item++] = new TestCase( SECTION, "parseFloat(0xF)", 15, parseFloat(0xF)); - - array[item++] = new TestCase( SECTION, "parseFloat(0X0)", 0, parseFloat(0X0)); - array[item++] = new TestCase( SECTION, "parseFloat(0X1)", 1, parseFloat(0X1)); - array[item++] = new TestCase( SECTION, "parseFloat(0X2)", 2, parseFloat(0X2)); - array[item++] = new TestCase( SECTION, "parseFloat(0X3)", 3, parseFloat(0X3)); - array[item++] = new TestCase( SECTION, "parseFloat(0X4)", 4, parseFloat(0X4)); - array[item++] = new TestCase( SECTION, "parseFloat(0X5)", 5, parseFloat(0X5)); - array[item++] = new TestCase( SECTION, "parseFloat(0X6)", 6, parseFloat(0X6)); - array[item++] = new TestCase( SECTION, "parseFloat(0X7)", 7, parseFloat(0X7)); - array[item++] = new TestCase( SECTION, "parseFloat(0X8)", 8, parseFloat(0X8)); - array[item++] = new TestCase( SECTION, "parseFloat(0X9)", 9, parseFloat(0X9)); - array[item++] = new TestCase( SECTION, "parseFloat(0Xa)", 10, parseFloat(0Xa)); - array[item++] = new TestCase( SECTION, "parseFloat(0Xb)", 11, parseFloat(0Xb)); - array[item++] = new TestCase( SECTION, "parseFloat(0Xc)", 12, parseFloat(0Xc)); - array[item++] = new TestCase( SECTION, "parseFloat(0Xd)", 13, parseFloat(0Xd)); - array[item++] = new TestCase( SECTION, "parseFloat(0Xe)", 14, parseFloat(0Xe)); - array[item++] = new TestCase( SECTION, "parseFloat(0Xf)", 15, parseFloat(0Xf)); - array[item++] = new TestCase( SECTION, "parseFloat(0XA)", 10, parseFloat(0XA)); - array[item++] = new TestCase( SECTION, "parseFloat(0XB)", 11, parseFloat(0XB)); - array[item++] = new TestCase( SECTION, "parseFloat(0XC)", 12, parseFloat(0XC)); - array[item++] = new TestCase( SECTION, "parseFloat(0XD)", 13, parseFloat(0XD)); - array[item++] = new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE)); - array[item++] = new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF)); - - - // A StringNumericLiteral may not use octal notation - - array[item++] = new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00")); - array[item++] = new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01")); - array[item++] = new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02")); - array[item++] = new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03")); - array[item++] = new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04")); - array[item++] = new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05")); - array[item++] = new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06")); - array[item++] = new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07")); - array[item++] = new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010")); - array[item++] = new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011")); - - // A StringNumericLIteral may have any number of leading 0 digits - - array[item++] = new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001")); - array[item++] = new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 ")); - - // an octal numeric literal should be treated as an octal - - array[item++] = new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00)); - array[item++] = new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01)); - array[item++] = new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02)); - array[item++] = new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03)); - array[item++] = new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04)); - array[item++] = new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05)); - array[item++] = new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06)); - array[item++] = new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07)); - array[item++] = new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010)); - array[item++] = new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011)); - - // A StringNumericLIteral may have any number of leading 0 digits - - array[item++] = new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); - array[item++] = new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); - - // make sure it's reflexive - array[item++] = new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI)); - array[item++] = new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2)); - array[item++] = new TestCase( SECTION, "parseFloat(Math.LN10)", Math.LN10, parseFloat(Math.LN10)); - array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG2E)", Math.LOG2E, parseFloat(Math.LOG2E)); - array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG10E)", Math.LOG10E, parseFloat(Math.LOG10E)); - array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT2)", Math.SQRT2, parseFloat(Math.SQRT2)); - array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT1_2)", Math.SQRT1_2, parseFloat(Math.SQRT1_2)); - - array[item++] = new TestCase( SECTION, "parseFloat(Math.PI+'')", Math.PI, parseFloat(Math.PI+'')); - array[item++] = new TestCase( SECTION, "parseFloat(Math.LN2+'')", Math.LN2, parseFloat(Math.LN2+'')); - array[item++] = new TestCase( SECTION, "parseFloat(Math.LN10+'')", Math.LN10, parseFloat(Math.LN10+'')); - array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG2E+'')", Math.LOG2E, parseFloat(Math.LOG2E+'')); - array[item++] = new TestCase( SECTION, "parseFloat(Math.LOG10E+'')", Math.LOG10E, parseFloat(Math.LOG10E+'')); - array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT2+'')", Math.SQRT2, parseFloat(Math.SQRT2+'')); - array[item++] = new TestCase( SECTION, "parseFloat(Math.SQRT1_2+'')", Math.SQRT1_2, parseFloat(Math.SQRT1_2+'')); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, "parseFloat(3.e+1)", 30, parseFloat(3.e+1) ); +new TestCase( SECTION, "parseFloat(-3.e+1)", -30, parseFloat(-3.e+1) ); + +new TestCase( SECTION, "parseFloat(3.e-1)", .30, parseFloat(3.e-1) ); +new TestCase( SECTION, "parseFloat(-3.e-1)", -.30, parseFloat(-3.e-1) ); + + +new TestCase( SECTION, "parseFloat(3.E1)", 30, parseFloat(3.E1) ); +new TestCase( SECTION, "parseFloat(-3.E1)", -30, parseFloat(-3.E1) ); + +new TestCase( SECTION, "parseFloat(3.E+1)", 30, parseFloat(3.E+1) ); +new TestCase( SECTION, "parseFloat(-3.E+1)", -30, parseFloat(-3.E+1) ); + +new TestCase( SECTION, "parseFloat(3.E-1)", .30, parseFloat(3.E-1) ); +new TestCase( SECTION, "parseFloat(-3.E-1)", -.30, parseFloat(-3.E-1) ); + +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt + +new TestCase( SECTION, "parseFloat(.00001)", 0.00001, parseFloat(.00001) ); +new TestCase( SECTION, "parseFloat(-0.0001)", -0.00001, parseFloat(-.00001) ); + +new TestCase( SECTION, "parseFloat(.01e2)", 1, parseFloat(.01e2) ); +new TestCase( SECTION, "parseFloat(-.01e2)", -1, parseFloat(-.01e2) ); + +new TestCase( SECTION, "parseFloat(.01e+2)", 1, parseFloat(.01e+2) ); +new TestCase( SECTION, "parseFloat(-.01e+2)", -1, parseFloat(-.01e+2) ); + +new TestCase( SECTION, "parseFloat(.01e-2)", 0.0001, parseFloat(.01e-2) ); +new TestCase( SECTION, "parseFloat(-.01e-2)", -0.0001, parseFloat(-.01e-2) ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt + +new TestCase( SECTION, "parseFloat(1234e5)", 123400000, parseFloat(1234e5) ); +new TestCase( SECTION, "parseFloat(-1234e5)", -123400000, parseFloat(-1234e5) ); + +new TestCase( SECTION, "parseFloat(1234e+5)", 123400000, parseFloat(1234e+5) ); +new TestCase( SECTION, "parseFloat(-1234e+5)", -123400000, parseFloat(-1234e+5) ); + +new TestCase( SECTION, "parseFloat(1234e-5)", 0.01234, parseFloat(1234e-5) ); +new TestCase( SECTION, "parseFloat(-1234e-5)", -0.01234, parseFloat(-1234e-5) ); + +// hex cases should all return 0 (0 is the longest string that satisfies a StringDecimalLiteral) + +new TestCase( SECTION, "parseFloat('0x0')", 0, parseFloat("0x0")); +new TestCase( SECTION, "parseFloat('0x1')", 0, parseFloat("0x1")); +new TestCase( SECTION, "parseFloat('0x2')", 0, parseFloat("0x2")); +new TestCase( SECTION, "parseFloat('0x3')", 0, parseFloat("0x3")); +new TestCase( SECTION, "parseFloat('0x4')", 0, parseFloat("0x4")); +new TestCase( SECTION, "parseFloat('0x5')", 0, parseFloat("0x5")); +new TestCase( SECTION, "parseFloat('0x6')", 0, parseFloat("0x6")); +new TestCase( SECTION, "parseFloat('0x7')", 0, parseFloat("0x7")); +new TestCase( SECTION, "parseFloat('0x8')", 0, parseFloat("0x8")); +new TestCase( SECTION, "parseFloat('0x9')", 0, parseFloat("0x9")); +new TestCase( SECTION, "parseFloat('0xa')", 0, parseFloat("0xa")); +new TestCase( SECTION, "parseFloat('0xb')", 0, parseFloat("0xb")); +new TestCase( SECTION, "parseFloat('0xc')", 0, parseFloat("0xc")); +new TestCase( SECTION, "parseFloat('0xd')", 0, parseFloat("0xd")); +new TestCase( SECTION, "parseFloat('0xe')", 0, parseFloat("0xe")); +new TestCase( SECTION, "parseFloat('0xf')", 0, parseFloat("0xf")); +new TestCase( SECTION, "parseFloat('0xA')", 0, parseFloat("0xA")); +new TestCase( SECTION, "parseFloat('0xB')", 0, parseFloat("0xB")); +new TestCase( SECTION, "parseFloat('0xC')", 0, parseFloat("0xC")); +new TestCase( SECTION, "parseFloat('0xD')", 0, parseFloat("0xD")); +new TestCase( SECTION, "parseFloat('0xE')", 0, parseFloat("0xE")); +new TestCase( SECTION, "parseFloat('0xF')", 0, parseFloat("0xF")); + +new TestCase( SECTION, "parseFloat('0X0')", 0, parseFloat("0X0")); +new TestCase( SECTION, "parseFloat('0X1')", 0, parseFloat("0X1")); +new TestCase( SECTION, "parseFloat('0X2')", 0, parseFloat("0X2")); +new TestCase( SECTION, "parseFloat('0X3')", 0, parseFloat("0X3")); +new TestCase( SECTION, "parseFloat('0X4')", 0, parseFloat("0X4")); +new TestCase( SECTION, "parseFloat('0X5')", 0, parseFloat("0X5")); +new TestCase( SECTION, "parseFloat('0X6')", 0, parseFloat("0X6")); +new TestCase( SECTION, "parseFloat('0X7')", 0, parseFloat("0X7")); +new TestCase( SECTION, "parseFloat('0X8')", 0, parseFloat("0X8")); +new TestCase( SECTION, "parseFloat('0X9')", 0, parseFloat("0X9")); +new TestCase( SECTION, "parseFloat('0Xa')", 0, parseFloat("0Xa")); +new TestCase( SECTION, "parseFloat('0Xb')", 0, parseFloat("0Xb")); +new TestCase( SECTION, "parseFloat('0Xc')", 0, parseFloat("0Xc")); +new TestCase( SECTION, "parseFloat('0Xd')", 0, parseFloat("0Xd")); +new TestCase( SECTION, "parseFloat('0Xe')", 0, parseFloat("0Xe")); +new TestCase( SECTION, "parseFloat('0Xf')", 0, parseFloat("0Xf")); +new TestCase( SECTION, "parseFloat('0XA')", 0, parseFloat("0XA")); +new TestCase( SECTION, "parseFloat('0XB')", 0, parseFloat("0XB")); +new TestCase( SECTION, "parseFloat('0XC')", 0, parseFloat("0XC")); +new TestCase( SECTION, "parseFloat('0XD')", 0, parseFloat("0XD")); +new TestCase( SECTION, "parseFloat('0XE')", 0, parseFloat("0XE")); +new TestCase( SECTION, "parseFloat('0XF')", 0, parseFloat("0XF")); +new TestCase( SECTION, "parseFloat(' 0XF ')", 0, parseFloat(" 0XF ")); + +// hex literals should still succeed + +new TestCase( SECTION, "parseFloat(0x0)", 0, parseFloat(0x0)); +new TestCase( SECTION, "parseFloat(0x1)", 1, parseFloat(0x1)); +new TestCase( SECTION, "parseFloat(0x2)", 2, parseFloat(0x2)); +new TestCase( SECTION, "parseFloat(0x3)", 3, parseFloat(0x3)); +new TestCase( SECTION, "parseFloat(0x4)", 4, parseFloat(0x4)); +new TestCase( SECTION, "parseFloat(0x5)", 5, parseFloat(0x5)); +new TestCase( SECTION, "parseFloat(0x6)", 6, parseFloat(0x6)); +new TestCase( SECTION, "parseFloat(0x7)", 7, parseFloat(0x7)); +new TestCase( SECTION, "parseFloat(0x8)", 8, parseFloat(0x8)); +new TestCase( SECTION, "parseFloat(0x9)", 9, parseFloat(0x9)); +new TestCase( SECTION, "parseFloat(0xa)", 10, parseFloat(0xa)); +new TestCase( SECTION, "parseFloat(0xb)", 11, parseFloat(0xb)); +new TestCase( SECTION, "parseFloat(0xc)", 12, parseFloat(0xc)); +new TestCase( SECTION, "parseFloat(0xd)", 13, parseFloat(0xd)); +new TestCase( SECTION, "parseFloat(0xe)", 14, parseFloat(0xe)); +new TestCase( SECTION, "parseFloat(0xf)", 15, parseFloat(0xf)); +new TestCase( SECTION, "parseFloat(0xA)", 10, parseFloat(0xA)); +new TestCase( SECTION, "parseFloat(0xB)", 11, parseFloat(0xB)); +new TestCase( SECTION, "parseFloat(0xC)", 12, parseFloat(0xC)); +new TestCase( SECTION, "parseFloat(0xD)", 13, parseFloat(0xD)); +new TestCase( SECTION, "parseFloat(0xE)", 14, parseFloat(0xE)); +new TestCase( SECTION, "parseFloat(0xF)", 15, parseFloat(0xF)); + +new TestCase( SECTION, "parseFloat(0X0)", 0, parseFloat(0X0)); +new TestCase( SECTION, "parseFloat(0X1)", 1, parseFloat(0X1)); +new TestCase( SECTION, "parseFloat(0X2)", 2, parseFloat(0X2)); +new TestCase( SECTION, "parseFloat(0X3)", 3, parseFloat(0X3)); +new TestCase( SECTION, "parseFloat(0X4)", 4, parseFloat(0X4)); +new TestCase( SECTION, "parseFloat(0X5)", 5, parseFloat(0X5)); +new TestCase( SECTION, "parseFloat(0X6)", 6, parseFloat(0X6)); +new TestCase( SECTION, "parseFloat(0X7)", 7, parseFloat(0X7)); +new TestCase( SECTION, "parseFloat(0X8)", 8, parseFloat(0X8)); +new TestCase( SECTION, "parseFloat(0X9)", 9, parseFloat(0X9)); +new TestCase( SECTION, "parseFloat(0Xa)", 10, parseFloat(0Xa)); +new TestCase( SECTION, "parseFloat(0Xb)", 11, parseFloat(0Xb)); +new TestCase( SECTION, "parseFloat(0Xc)", 12, parseFloat(0Xc)); +new TestCase( SECTION, "parseFloat(0Xd)", 13, parseFloat(0Xd)); +new TestCase( SECTION, "parseFloat(0Xe)", 14, parseFloat(0Xe)); +new TestCase( SECTION, "parseFloat(0Xf)", 15, parseFloat(0Xf)); +new TestCase( SECTION, "parseFloat(0XA)", 10, parseFloat(0XA)); +new TestCase( SECTION, "parseFloat(0XB)", 11, parseFloat(0XB)); +new TestCase( SECTION, "parseFloat(0XC)", 12, parseFloat(0XC)); +new TestCase( SECTION, "parseFloat(0XD)", 13, parseFloat(0XD)); +new TestCase( SECTION, "parseFloat(0XE)", 14, parseFloat(0XE)); +new TestCase( SECTION, "parseFloat(0XF)", 15, parseFloat(0XF)); + + +// A StringNumericLiteral may not use octal notation + +new TestCase( SECTION, "parseFloat('00')", 0, parseFloat("00")); +new TestCase( SECTION, "parseFloat('01')", 1, parseFloat("01")); +new TestCase( SECTION, "parseFloat('02')", 2, parseFloat("02")); +new TestCase( SECTION, "parseFloat('03')", 3, parseFloat("03")); +new TestCase( SECTION, "parseFloat('04')", 4, parseFloat("04")); +new TestCase( SECTION, "parseFloat('05')", 5, parseFloat("05")); +new TestCase( SECTION, "parseFloat('06')", 6, parseFloat("06")); +new TestCase( SECTION, "parseFloat('07')", 7, parseFloat("07")); +new TestCase( SECTION, "parseFloat('010')", 10, parseFloat("010")); +new TestCase( SECTION, "parseFloat('011')", 11, parseFloat("011")); + +// A StringNumericLIteral may have any number of leading 0 digits + +new TestCase( SECTION, "parseFloat('001')", 1, parseFloat("001")); +new TestCase( SECTION, "parseFloat('0001')", 1, parseFloat("0001")); +new TestCase( SECTION, "parseFloat(' 0001 ')", 1, parseFloat(" 0001 ")); + +// an octal numeric literal should be treated as an octal + +new TestCase( SECTION, "parseFloat(00)", 0, parseFloat(00)); +new TestCase( SECTION, "parseFloat(01)", 1, parseFloat(01)); +new TestCase( SECTION, "parseFloat(02)", 2, parseFloat(02)); +new TestCase( SECTION, "parseFloat(03)", 3, parseFloat(03)); +new TestCase( SECTION, "parseFloat(04)", 4, parseFloat(04)); +new TestCase( SECTION, "parseFloat(05)", 5, parseFloat(05)); +new TestCase( SECTION, "parseFloat(06)", 6, parseFloat(06)); +new TestCase( SECTION, "parseFloat(07)", 7, parseFloat(07)); +new TestCase( SECTION, "parseFloat(010)", 8, parseFloat(010)); +new TestCase( SECTION, "parseFloat(011)", 9, parseFloat(011)); + +// A StringNumericLIteral may have any number of leading 0 digits + +new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); +new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); + +// make sure it's reflexive +new TestCase( SECTION, "parseFloat(Math.PI)", Math.PI, parseFloat(Math.PI)); +new TestCase( SECTION, "parseFloat(Math.LN2)", Math.LN2, parseFloat(Math.LN2)); +new TestCase( SECTION, "parseFloat(Math.LN10)", Math.LN10, parseFloat(Math.LN10)); +new TestCase( SECTION, "parseFloat(Math.LOG2E)", Math.LOG2E, parseFloat(Math.LOG2E)); +new TestCase( SECTION, "parseFloat(Math.LOG10E)", Math.LOG10E, parseFloat(Math.LOG10E)); +new TestCase( SECTION, "parseFloat(Math.SQRT2)", Math.SQRT2, parseFloat(Math.SQRT2)); +new TestCase( SECTION, "parseFloat(Math.SQRT1_2)", Math.SQRT1_2, parseFloat(Math.SQRT1_2)); + +new TestCase( SECTION, "parseFloat(Math.PI+'')", Math.PI, parseFloat(Math.PI+'')); +new TestCase( SECTION, "parseFloat(Math.LN2+'')", Math.LN2, parseFloat(Math.LN2+'')); +new TestCase( SECTION, "parseFloat(Math.LN10+'')", Math.LN10, parseFloat(Math.LN10+'')); +new TestCase( SECTION, "parseFloat(Math.LOG2E+'')", Math.LOG2E, parseFloat(Math.LOG2E+'')); +new TestCase( SECTION, "parseFloat(Math.LOG10E+'')", Math.LOG10E, parseFloat(Math.LOG10E+'')); +new TestCase( SECTION, "parseFloat(Math.SQRT2+'')", Math.SQRT2, parseFloat(Math.SQRT2+'')); +new TestCase( SECTION, "parseFloat(Math.SQRT1_2+'')", Math.SQRT1_2, parseFloat(Math.SQRT1_2+'')); + +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.3-2.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.3-2.js index b54b821945c..2340af97c5b 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.3-2.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,276 +36,253 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.1.2.3-2.js - ECMA Section: 15.1.2.3 Function properties of the global object: - parseFloat( string ) + File Name: 15.1.2.3-2.js + ECMA Section: 15.1.2.3 Function properties of the global object: + parseFloat( string ) - Description: The parseFloat function produces a number value dictated - by the interpretation of the contents of the string - argument defined as a decimal literal. + Description: The parseFloat function produces a number value dictated + by the interpretation of the contents of the string + argument defined as a decimal literal. - When the parseFloat function is called, the following - steps are taken: + When the parseFloat function is called, the following + steps are taken: - 1. Call ToString( string ). - 2. Remove leading whitespace Result(1). - 3. If neither Result(2) nor any prefix of Result(2) - satisfies the syntax of a StrDecimalLiteral, - return NaN. - 4. Compute the longest prefix of Result(2) which might - be Resusult(2) itself, that satisfies the syntax of - a StrDecimalLiteral - 5. Return the number value for the MV of Result(4). + 1. Call ToString( string ). + 2. Remove leading whitespace Result(1). + 3. If neither Result(2) nor any prefix of Result(2) + satisfies the syntax of a StrDecimalLiteral, + return NaN. + 4. Compute the longest prefix of Result(2) which might + be Resusult(2) itself, that satisfies the syntax of + a StrDecimalLiteral + 5. Return the number value for the MV of Result(4). - Note that parseFloate may interpret only a leading - portion of the string as a number value; it ignores any - characters that cannot be interpreted as part of the - notation of a decimal literal, and no indication is given - that such characters were ignored. + Note that parseFloate may interpret only a leading + portion of the string as a number value; it ignores any + characters that cannot be interpreted as part of the + notation of a decimal literal, and no indication is given + that such characters were ignored. - StrDecimalLiteral:: - Infinity - DecimalDigits.DecimalDigits opt ExponentPart opt - .DecimalDigits ExponentPart opt - DecimalDigits ExponentPart opt + StrDecimalLiteral:: + Infinity + DecimalDigits.DecimalDigits opt ExponentPart opt + .DecimalDigits ExponentPart opt + DecimalDigits ExponentPart opt - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.2.3-2"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.1.2.3-2"; +var VERSION = "ECMA_1"; +startTest(); - var BUGNUMBER = "77391"; +var BUGNUMBER = "77391"; - var testcases = getTestCases(); +new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); +new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); +new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); - writeHeaderToLog( SECTION + " parseFloat(string)"); - test(); +new TestCase( SECTION, "parseFloat(' Infinity')", Number.POSITIVE_INFINITY, parseFloat("Infinity") ); +// new TestCase( SECTION, "parseFloat(Infinity)", Number.POSITIVE_INFINITY, parseFloat(Infinity) ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "parseFloat(' 0')", 0, parseFloat(" 0") ); +new TestCase( SECTION, "parseFloat(' -0')", -0, parseFloat(" -0") ); +new TestCase( SECTION, "parseFloat(' +0')", 0, parseFloat(" +0") ); - array[item++] = new TestCase( SECTION, "parseFloat(true)", Number.NaN, parseFloat(true) ); - array[item++] = new TestCase( SECTION, "parseFloat(false)", Number.NaN, parseFloat(false) ); - array[item++] = new TestCase( SECTION, "parseFloat('string')", Number.NaN, parseFloat("string") ); +new TestCase( SECTION, "parseFloat(' 1')", 1, parseFloat(" 1") ); +new TestCase( SECTION, "parseFloat(' -1')", -1, parseFloat(" -1") ); +new TestCase( SECTION, "parseFloat(' +1')", 1, parseFloat(" +1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' Infinity')", Number.POSITIVE_INFINITY, parseFloat("Infinity") ); -// array[item++] = new TestCase( SECTION, "parseFloat(Infinity)", Number.POSITIVE_INFINITY, parseFloat(Infinity) ); +new TestCase( SECTION, "parseFloat(' 2')", 2, parseFloat(" 2") ); +new TestCase( SECTION, "parseFloat(' -2')", -2, parseFloat(" -2") ); +new TestCase( SECTION, "parseFloat(' +2')", 2, parseFloat(" +2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 0')", 0, parseFloat(" 0") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -0')", -0, parseFloat(" -0") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +0')", 0, parseFloat(" +0") ); +new TestCase( SECTION, "parseFloat(' 3')", 3, parseFloat(" 3") ); +new TestCase( SECTION, "parseFloat(' -3')", -3, parseFloat(" -3") ); +new TestCase( SECTION, "parseFloat(' +3')", 3, parseFloat(" +3") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 1')", 1, parseFloat(" 1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -1')", -1, parseFloat(" -1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +1')", 1, parseFloat(" +1") ); +new TestCase( SECTION, "parseFloat(' 4')", 4, parseFloat(" 4") ); +new TestCase( SECTION, "parseFloat(' -4')", -4, parseFloat(" -4") ); +new TestCase( SECTION, "parseFloat(' +4')", 4, parseFloat(" +4") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 2')", 2, parseFloat(" 2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -2')", -2, parseFloat(" -2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +2')", 2, parseFloat(" +2") ); +new TestCase( SECTION, "parseFloat(' 5')", 5, parseFloat(" 5") ); +new TestCase( SECTION, "parseFloat(' -5')", -5, parseFloat(" -5") ); +new TestCase( SECTION, "parseFloat(' +5')", 5, parseFloat(" +5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 3')", 3, parseFloat(" 3") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -3')", -3, parseFloat(" -3") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +3')", 3, parseFloat(" +3") ); +new TestCase( SECTION, "parseFloat(' 6')", 6, parseFloat(" 6") ); +new TestCase( SECTION, "parseFloat(' -6')", -6, parseFloat(" -6") ); +new TestCase( SECTION, "parseFloat(' +6')", 6, parseFloat(" +6") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 4')", 4, parseFloat(" 4") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -4')", -4, parseFloat(" -4") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +4')", 4, parseFloat(" +4") ); +new TestCase( SECTION, "parseFloat(' 7')", 7, parseFloat(" 7") ); +new TestCase( SECTION, "parseFloat(' -7')", -7, parseFloat(" -7") ); +new TestCase( SECTION, "parseFloat(' +7')", 7, parseFloat(" +7") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 5')", 5, parseFloat(" 5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -5')", -5, parseFloat(" -5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +5')", 5, parseFloat(" +5") ); +new TestCase( SECTION, "parseFloat(' 8')", 8, parseFloat(" 8") ); +new TestCase( SECTION, "parseFloat(' -8')", -8, parseFloat(" -8") ); +new TestCase( SECTION, "parseFloat(' +8')", 8, parseFloat(" +8") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 6')", 6, parseFloat(" 6") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -6')", -6, parseFloat(" -6") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +6')", 6, parseFloat(" +6") ); +new TestCase( SECTION, "parseFloat(' 9')", 9, parseFloat(" 9") ); +new TestCase( SECTION, "parseFloat(' -9')", -9, parseFloat(" -9") ); +new TestCase( SECTION, "parseFloat(' +9')", 9, parseFloat(" +9") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 7')", 7, parseFloat(" 7") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -7')", -7, parseFloat(" -7") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +7')", 7, parseFloat(" +7") ); +new TestCase( SECTION, "parseFloat(' 3.14159')", 3.14159, parseFloat(" 3.14159") ); +new TestCase( SECTION, "parseFloat(' -3.14159')", -3.14159, parseFloat(" -3.14159") ); +new TestCase( SECTION, "parseFloat(' +3.14159')", 3.14159, parseFloat(" +3.14159") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 8')", 8, parseFloat(" 8") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -8')", -8, parseFloat(" -8") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +8')", 8, parseFloat(" +8") ); +new TestCase( SECTION, "parseFloat(' 3.')", 3, parseFloat(" 3.") ); +new TestCase( SECTION, "parseFloat(' -3.')", -3, parseFloat(" -3.") ); +new TestCase( SECTION, "parseFloat(' +3.')", 3, parseFloat(" +3.") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 9')", 9, parseFloat(" 9") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -9')", -9, parseFloat(" -9") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +9')", 9, parseFloat(" +9") ); +new TestCase( SECTION, "parseFloat(' 3.e1')", 30, parseFloat(" 3.e1") ); +new TestCase( SECTION, "parseFloat(' -3.e1')", -30, parseFloat(" -3.e1") ); +new TestCase( SECTION, "parseFloat(' +3.e1')", 30, parseFloat(" +3.e1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 3.14159')", 3.14159, parseFloat(" 3.14159") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -3.14159')", -3.14159, parseFloat(" -3.14159") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +3.14159')", 3.14159, parseFloat(" +3.14159") ); +new TestCase( SECTION, "parseFloat(' 3.e+1')", 30, parseFloat(" 3.e+1") ); +new TestCase( SECTION, "parseFloat(' -3.e+1')", -30, parseFloat(" -3.e+1") ); +new TestCase( SECTION, "parseFloat(' +3.e+1')", 30, parseFloat(" +3.e+1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 3.')", 3, parseFloat(" 3.") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -3.')", -3, parseFloat(" -3.") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +3.')", 3, parseFloat(" +3.") ); +new TestCase( SECTION, "parseFloat(' 3.e-1')", .30, parseFloat(" 3.e-1") ); +new TestCase( SECTION, "parseFloat(' -3.e-1')", -.30, parseFloat(" -3.e-1") ); +new TestCase( SECTION, "parseFloat(' +3.e-1')", .30, parseFloat(" +3.e-1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 3.e1')", 30, parseFloat(" 3.e1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -3.e1')", -30, parseFloat(" -3.e1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +3.e1')", 30, parseFloat(" +3.e1") ); +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt - array[item++] = new TestCase( SECTION, "parseFloat(' 3.e+1')", 30, parseFloat(" 3.e+1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -3.e+1')", -30, parseFloat(" -3.e+1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +3.e+1')", 30, parseFloat(" +3.e+1") ); +new TestCase( SECTION, "parseFloat(' .00001')", 0.00001, parseFloat(" .00001") ); +new TestCase( SECTION, "parseFloat(' +.00001')", 0.00001, parseFloat(" +.00001") ); +new TestCase( SECTION, "parseFloat(' -0.0001')", -0.00001, parseFloat(" -.00001") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 3.e-1')", .30, parseFloat(" 3.e-1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -3.e-1')", -.30, parseFloat(" -3.e-1") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +3.e-1')", .30, parseFloat(" +3.e-1") ); +new TestCase( SECTION, "parseFloat(' .01e2')", 1, parseFloat(" .01e2") ); +new TestCase( SECTION, "parseFloat(' +.01e2')", 1, parseFloat(" +.01e2") ); +new TestCase( SECTION, "parseFloat(' -.01e2')", -1, parseFloat(" -.01e2") ); - // StrDecimalLiteral::: .DecimalDigits ExponentPart opt +new TestCase( SECTION, "parseFloat(' .01e+2')", 1, parseFloat(" .01e+2") ); +new TestCase( SECTION, "parseFloat(' +.01e+2')", 1, parseFloat(" +.01e+2") ); +new TestCase( SECTION, "parseFloat(' -.01e+2')", -1, parseFloat(" -.01e+2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' .00001')", 0.00001, parseFloat(" .00001") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +.00001')", 0.00001, parseFloat(" +.00001") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -0.0001')", -0.00001, parseFloat(" -.00001") ); +new TestCase( SECTION, "parseFloat(' .01e-2')", 0.0001, parseFloat(" .01e-2") ); +new TestCase( SECTION, "parseFloat(' +.01e-2')", 0.0001, parseFloat(" +.01e-2") ); +new TestCase( SECTION, "parseFloat(' -.01e-2')", -0.0001, parseFloat(" -.01e-2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' .01e2')", 1, parseFloat(" .01e2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +.01e2')", 1, parseFloat(" +.01e2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -.01e2')", -1, parseFloat(" -.01e2") ); +// StrDecimalLiteral::: DecimalDigits ExponentPart opt - array[item++] = new TestCase( SECTION, "parseFloat(' .01e+2')", 1, parseFloat(" .01e+2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +.01e+2')", 1, parseFloat(" +.01e+2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -.01e+2')", -1, parseFloat(" -.01e+2") ); +new TestCase( SECTION, "parseFloat(' 1234e5')", 123400000, parseFloat(" 1234e5") ); +new TestCase( SECTION, "parseFloat(' +1234e5')", 123400000, parseFloat(" +1234e5") ); +new TestCase( SECTION, "parseFloat(' -1234e5')", -123400000, parseFloat(" -1234e5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' .01e-2')", 0.0001, parseFloat(" .01e-2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +.01e-2')", 0.0001, parseFloat(" +.01e-2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -.01e-2')", -0.0001, parseFloat(" -.01e-2") ); +new TestCase( SECTION, "parseFloat(' 1234e+5')", 123400000, parseFloat(" 1234e+5") ); +new TestCase( SECTION, "parseFloat(' +1234e+5')", 123400000, parseFloat(" +1234e+5") ); +new TestCase( SECTION, "parseFloat(' -1234e+5')", -123400000, parseFloat(" -1234e+5") ); - // StrDecimalLiteral::: DecimalDigits ExponentPart opt - - array[item++] = new TestCase( SECTION, "parseFloat(' 1234e5')", 123400000, parseFloat(" 1234e5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +1234e5')", 123400000, parseFloat(" +1234e5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -1234e5')", -123400000, parseFloat(" -1234e5") ); - - array[item++] = new TestCase( SECTION, "parseFloat(' 1234e+5')", 123400000, parseFloat(" 1234e+5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +1234e+5')", 123400000, parseFloat(" +1234e+5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -1234e+5')", -123400000, parseFloat(" -1234e+5") ); - - array[item++] = new TestCase( SECTION, "parseFloat(' 1234e-5')", 0.01234, parseFloat(" 1234e-5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +1234e-5')", 0.01234, parseFloat(" +1234e-5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -1234e-5')", -0.01234, parseFloat(" -1234e-5") ); +new TestCase( SECTION, "parseFloat(' 1234e-5')", 0.01234, parseFloat(" 1234e-5") ); +new TestCase( SECTION, "parseFloat(' +1234e-5')", 0.01234, parseFloat(" +1234e-5") ); +new TestCase( SECTION, "parseFloat(' -1234e-5')", -0.01234, parseFloat(" -1234e-5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' .01E2')", 1, parseFloat(" .01E2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +.01E2')", 1, parseFloat(" +.01E2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -.01E2')", -1, parseFloat(" -.01E2") ); +new TestCase( SECTION, "parseFloat(' .01E2')", 1, parseFloat(" .01E2") ); +new TestCase( SECTION, "parseFloat(' +.01E2')", 1, parseFloat(" +.01E2") ); +new TestCase( SECTION, "parseFloat(' -.01E2')", -1, parseFloat(" -.01E2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' .01E+2')", 1, parseFloat(" .01E+2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +.01E+2')", 1, parseFloat(" +.01E+2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -.01E+2')", -1, parseFloat(" -.01E+2") ); +new TestCase( SECTION, "parseFloat(' .01E+2')", 1, parseFloat(" .01E+2") ); +new TestCase( SECTION, "parseFloat(' +.01E+2')", 1, parseFloat(" +.01E+2") ); +new TestCase( SECTION, "parseFloat(' -.01E+2')", -1, parseFloat(" -.01E+2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' .01E-2')", 0.0001, parseFloat(" .01E-2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +.01E-2')", 0.0001, parseFloat(" +.01E-2") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -.01E-2')", -0.0001, parseFloat(" -.01E-2") ); +new TestCase( SECTION, "parseFloat(' .01E-2')", 0.0001, parseFloat(" .01E-2") ); +new TestCase( SECTION, "parseFloat(' +.01E-2')", 0.0001, parseFloat(" +.01E-2") ); +new TestCase( SECTION, "parseFloat(' -.01E-2')", -0.0001, parseFloat(" -.01E-2") ); - // StrDecimalLiteral::: DecimalDigits ExponentPart opt - array[item++] = new TestCase( SECTION, "parseFloat(' 1234E5')", 123400000, parseFloat(" 1234E5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +1234E5')", 123400000, parseFloat(" +1234E5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -1234E5')", -123400000, parseFloat(" -1234E5") ); +// StrDecimalLiteral::: DecimalDigits ExponentPart opt +new TestCase( SECTION, "parseFloat(' 1234E5')", 123400000, parseFloat(" 1234E5") ); +new TestCase( SECTION, "parseFloat(' +1234E5')", 123400000, parseFloat(" +1234E5") ); +new TestCase( SECTION, "parseFloat(' -1234E5')", -123400000, parseFloat(" -1234E5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 1234E+5')", 123400000, parseFloat(" 1234E+5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +1234E+5')", 123400000, parseFloat(" +1234E+5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -1234E+5')", -123400000, parseFloat(" -1234E+5") ); +new TestCase( SECTION, "parseFloat(' 1234E+5')", 123400000, parseFloat(" 1234E+5") ); +new TestCase( SECTION, "parseFloat(' +1234E+5')", 123400000, parseFloat(" +1234E+5") ); +new TestCase( SECTION, "parseFloat(' -1234E+5')", -123400000, parseFloat(" -1234E+5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' 1234E-5')", 0.01234, parseFloat(" 1234E-5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' +1234E-5')", 0.01234, parseFloat(" +1234E-5") ); - array[item++] = new TestCase( SECTION, "parseFloat(' -1234E-5')", -0.01234, parseFloat(" -1234E-5") ); +new TestCase( SECTION, "parseFloat(' 1234E-5')", 0.01234, parseFloat(" 1234E-5") ); +new TestCase( SECTION, "parseFloat(' +1234E-5')", 0.01234, parseFloat(" +1234E-5") ); +new TestCase( SECTION, "parseFloat(' -1234E-5')", -0.01234, parseFloat(" -1234E-5") ); - // hex cases should all return NaN +// hex cases should all return NaN - array[item++] = new TestCase( SECTION, "parseFloat(' 0x0')", 0, parseFloat(" 0x0")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x1')", 0, parseFloat(" 0x1")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x2')", 0, parseFloat(" 0x2")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x3')", 0, parseFloat(" 0x3")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x4')", 0, parseFloat(" 0x4")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x5')", 0, parseFloat(" 0x5")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x6')", 0, parseFloat(" 0x6")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x7')", 0, parseFloat(" 0x7")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x8')", 0, parseFloat(" 0x8")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0x9')", 0, parseFloat(" 0x9")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xa')", 0, parseFloat(" 0xa")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xb')", 0, parseFloat(" 0xb")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xc')", 0, parseFloat(" 0xc")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xd')", 0, parseFloat(" 0xd")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xe')", 0, parseFloat(" 0xe")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xf')", 0, parseFloat(" 0xf")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xA')", 0, parseFloat(" 0xA")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xB')", 0, parseFloat(" 0xB")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xC')", 0, parseFloat(" 0xC")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xD')", 0, parseFloat(" 0xD")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xE')", 0, parseFloat(" 0xE")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0xF')", 0, parseFloat(" 0xF")); +new TestCase( SECTION, "parseFloat(' 0x0')", 0, parseFloat(" 0x0")); +new TestCase( SECTION, "parseFloat(' 0x1')", 0, parseFloat(" 0x1")); +new TestCase( SECTION, "parseFloat(' 0x2')", 0, parseFloat(" 0x2")); +new TestCase( SECTION, "parseFloat(' 0x3')", 0, parseFloat(" 0x3")); +new TestCase( SECTION, "parseFloat(' 0x4')", 0, parseFloat(" 0x4")); +new TestCase( SECTION, "parseFloat(' 0x5')", 0, parseFloat(" 0x5")); +new TestCase( SECTION, "parseFloat(' 0x6')", 0, parseFloat(" 0x6")); +new TestCase( SECTION, "parseFloat(' 0x7')", 0, parseFloat(" 0x7")); +new TestCase( SECTION, "parseFloat(' 0x8')", 0, parseFloat(" 0x8")); +new TestCase( SECTION, "parseFloat(' 0x9')", 0, parseFloat(" 0x9")); +new TestCase( SECTION, "parseFloat(' 0xa')", 0, parseFloat(" 0xa")); +new TestCase( SECTION, "parseFloat(' 0xb')", 0, parseFloat(" 0xb")); +new TestCase( SECTION, "parseFloat(' 0xc')", 0, parseFloat(" 0xc")); +new TestCase( SECTION, "parseFloat(' 0xd')", 0, parseFloat(" 0xd")); +new TestCase( SECTION, "parseFloat(' 0xe')", 0, parseFloat(" 0xe")); +new TestCase( SECTION, "parseFloat(' 0xf')", 0, parseFloat(" 0xf")); +new TestCase( SECTION, "parseFloat(' 0xA')", 0, parseFloat(" 0xA")); +new TestCase( SECTION, "parseFloat(' 0xB')", 0, parseFloat(" 0xB")); +new TestCase( SECTION, "parseFloat(' 0xC')", 0, parseFloat(" 0xC")); +new TestCase( SECTION, "parseFloat(' 0xD')", 0, parseFloat(" 0xD")); +new TestCase( SECTION, "parseFloat(' 0xE')", 0, parseFloat(" 0xE")); +new TestCase( SECTION, "parseFloat(' 0xF')", 0, parseFloat(" 0xF")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X0')", 0, parseFloat(" 0X0")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X1')", 0, parseFloat(" 0X1")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X2')", 0, parseFloat(" 0X2")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X3')", 0, parseFloat(" 0X3")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X4')", 0, parseFloat(" 0X4")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X5')", 0, parseFloat(" 0X5")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X6')", 0, parseFloat(" 0X6")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X7')", 0, parseFloat(" 0X7")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X8')", 0, parseFloat(" 0X8")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0X9')", 0, parseFloat(" 0X9")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0Xa')", 0, parseFloat(" 0Xa")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0Xb')", 0, parseFloat(" 0Xb")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0Xc')", 0, parseFloat(" 0Xc")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0Xd')", 0, parseFloat(" 0Xd")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0Xe')", 0, parseFloat(" 0Xe")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0Xf')", 0, parseFloat(" 0Xf")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0XA')", 0, parseFloat(" 0XA")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0XB')", 0, parseFloat(" 0XB")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0XC')", 0, parseFloat(" 0XC")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0XD')", 0, parseFloat(" 0XD")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0XE')", 0, parseFloat(" 0XE")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0XF')", 0, parseFloat(" 0XF")); +new TestCase( SECTION, "parseFloat(' 0X0')", 0, parseFloat(" 0X0")); +new TestCase( SECTION, "parseFloat(' 0X1')", 0, parseFloat(" 0X1")); +new TestCase( SECTION, "parseFloat(' 0X2')", 0, parseFloat(" 0X2")); +new TestCase( SECTION, "parseFloat(' 0X3')", 0, parseFloat(" 0X3")); +new TestCase( SECTION, "parseFloat(' 0X4')", 0, parseFloat(" 0X4")); +new TestCase( SECTION, "parseFloat(' 0X5')", 0, parseFloat(" 0X5")); +new TestCase( SECTION, "parseFloat(' 0X6')", 0, parseFloat(" 0X6")); +new TestCase( SECTION, "parseFloat(' 0X7')", 0, parseFloat(" 0X7")); +new TestCase( SECTION, "parseFloat(' 0X8')", 0, parseFloat(" 0X8")); +new TestCase( SECTION, "parseFloat(' 0X9')", 0, parseFloat(" 0X9")); +new TestCase( SECTION, "parseFloat(' 0Xa')", 0, parseFloat(" 0Xa")); +new TestCase( SECTION, "parseFloat(' 0Xb')", 0, parseFloat(" 0Xb")); +new TestCase( SECTION, "parseFloat(' 0Xc')", 0, parseFloat(" 0Xc")); +new TestCase( SECTION, "parseFloat(' 0Xd')", 0, parseFloat(" 0Xd")); +new TestCase( SECTION, "parseFloat(' 0Xe')", 0, parseFloat(" 0Xe")); +new TestCase( SECTION, "parseFloat(' 0Xf')", 0, parseFloat(" 0Xf")); +new TestCase( SECTION, "parseFloat(' 0XA')", 0, parseFloat(" 0XA")); +new TestCase( SECTION, "parseFloat(' 0XB')", 0, parseFloat(" 0XB")); +new TestCase( SECTION, "parseFloat(' 0XC')", 0, parseFloat(" 0XC")); +new TestCase( SECTION, "parseFloat(' 0XD')", 0, parseFloat(" 0XD")); +new TestCase( SECTION, "parseFloat(' 0XE')", 0, parseFloat(" 0XE")); +new TestCase( SECTION, "parseFloat(' 0XF')", 0, parseFloat(" 0XF")); - // A StringNumericLiteral may not use octal notation +// A StringNumericLiteral may not use octal notation - array[item++] = new TestCase( SECTION, "parseFloat(' 00')", 0, parseFloat(" 00")); - array[item++] = new TestCase( SECTION, "parseFloat(' 01')", 1, parseFloat(" 01")); - array[item++] = new TestCase( SECTION, "parseFloat(' 02')", 2, parseFloat(" 02")); - array[item++] = new TestCase( SECTION, "parseFloat(' 03')", 3, parseFloat(" 03")); - array[item++] = new TestCase( SECTION, "parseFloat(' 04')", 4, parseFloat(" 04")); - array[item++] = new TestCase( SECTION, "parseFloat(' 05')", 5, parseFloat(" 05")); - array[item++] = new TestCase( SECTION, "parseFloat(' 06')", 6, parseFloat(" 06")); - array[item++] = new TestCase( SECTION, "parseFloat(' 07')", 7, parseFloat(" 07")); - array[item++] = new TestCase( SECTION, "parseFloat(' 010')", 10, parseFloat(" 010")); - array[item++] = new TestCase( SECTION, "parseFloat(' 011')", 11, parseFloat(" 011")); +new TestCase( SECTION, "parseFloat(' 00')", 0, parseFloat(" 00")); +new TestCase( SECTION, "parseFloat(' 01')", 1, parseFloat(" 01")); +new TestCase( SECTION, "parseFloat(' 02')", 2, parseFloat(" 02")); +new TestCase( SECTION, "parseFloat(' 03')", 3, parseFloat(" 03")); +new TestCase( SECTION, "parseFloat(' 04')", 4, parseFloat(" 04")); +new TestCase( SECTION, "parseFloat(' 05')", 5, parseFloat(" 05")); +new TestCase( SECTION, "parseFloat(' 06')", 6, parseFloat(" 06")); +new TestCase( SECTION, "parseFloat(' 07')", 7, parseFloat(" 07")); +new TestCase( SECTION, "parseFloat(' 010')", 10, parseFloat(" 010")); +new TestCase( SECTION, "parseFloat(' 011')", 11, parseFloat(" 011")); - // A StringNumericLIteral may have any number of leading 0 digits +// A StringNumericLIteral may have any number of leading 0 digits - array[item++] = new TestCase( SECTION, "parseFloat(' 001')", 1, parseFloat(" 001")); - array[item++] = new TestCase( SECTION, "parseFloat(' 0001')", 1, parseFloat(" 0001")); +new TestCase( SECTION, "parseFloat(' 001')", 1, parseFloat(" 001")); +new TestCase( SECTION, "parseFloat(' 0001')", 1, parseFloat(" 0001")); - // A StringNumericLIteral may have any number of leading 0 digits +// A StringNumericLIteral may have any number of leading 0 digits - array[item++] = new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); - array[item++] = new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); +new TestCase( SECTION, "parseFloat(001)", 1, parseFloat(001)); +new TestCase( SECTION, "parseFloat(0001)", 1, parseFloat(0001)); - // make sure it' s reflexive - array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.PI+' ')", Math.PI, parseFloat( ' ' +Math.PI+' ')); - array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LN2+' ')", Math.LN2, parseFloat( ' ' +Math.LN2+' ')); - array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LN10+' ')", Math.LN10, parseFloat( ' ' +Math.LN10+' ')); - array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LOG2E+' ')", Math.LOG2E, parseFloat( ' ' +Math.LOG2E+' ')); - array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.LOG10E+' ')", Math.LOG10E, parseFloat( ' ' +Math.LOG10E+' ')); - array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT2+' ')", Math.SQRT2, parseFloat( ' ' +Math.SQRT2+' ')); - array[item++] = new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT1_2+' ')", Math.SQRT1_2, parseFloat( ' ' +Math.SQRT1_2+' ')); +// make sure it' s reflexive +new TestCase( SECTION, "parseFloat( ' ' +Math.PI+' ')", Math.PI, parseFloat( ' ' +Math.PI+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.LN2+' ')", Math.LN2, parseFloat( ' ' +Math.LN2+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.LN10+' ')", Math.LN10, parseFloat( ' ' +Math.LN10+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.LOG2E+' ')", Math.LOG2E, parseFloat( ' ' +Math.LOG2E+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.LOG10E+' ')", Math.LOG10E, parseFloat( ' ' +Math.LOG10E+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT2+' ')", Math.SQRT2, parseFloat( ' ' +Math.SQRT2+' ')); +new TestCase( SECTION, "parseFloat( ' ' +Math.SQRT1_2+' ')", Math.SQRT1_2, parseFloat( ' ' +Math.SQRT1_2+' ')); - - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.4.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.4.js index 720bc119eb9..0ee2860dba7 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.4.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,188 +35,169 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.2.4.js - ECMA Section: 15.1.2.4 Function properties of the global object - escape( string ) + File Name: 15.1.2.4.js + ECMA Section: 15.1.2.4 Function properties of the global object + escape( string ) - Description: - The escape function computes a new version of a string value in which - certain characters have been replaced by a hexadecimal escape sequence. - The result thus contains no special characters that might have special - meaning within a URL. + Description: + The escape function computes a new version of a string value in which + certain characters have been replaced by a hexadecimal escape sequence. + The result thus contains no special characters that might have special + meaning within a URL. - For characters whose Unicode encoding is 0xFF or less, a two-digit - escape sequence of the form %xx is used in accordance with RFC1738. - For characters whose Unicode encoding is greater than 0xFF, a four- - digit escape sequence of the form %uxxxx is used. + For characters whose Unicode encoding is 0xFF or less, a two-digit + escape sequence of the form %xx is used in accordance with RFC1738. + For characters whose Unicode encoding is greater than 0xFF, a four- + digit escape sequence of the form %uxxxx is used. - When the escape function is called with one argument string, the - following steps are taken: + When the escape function is called with one argument string, the + following steps are taken: - 1. Call ToString(string). - 2. Compute the number of characters in Result(1). - 3. Let R be the empty string. - 4. Let k be 0. - 5. If k equals Result(2), return R. - 6. Get the character at position k within Result(1). - 7. If Result(6) is one of the 69 nonblank ASCII characters - ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz - 0123456789 @*_+-./, go to step 14. - 8. Compute the 16-bit unsigned integer that is the Unicode character - encoding of Result(6). - 9. If Result(8), is less than 256, go to step 12. + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Get the character at position k within Result(1). + 7. If Result(6) is one of the 69 nonblank ASCII characters + ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz + 0123456789 @*_+-./, go to step 14. + 8. Compute the 16-bit unsigned integer that is the Unicode character + encoding of Result(6). + 9. If Result(8), is less than 256, go to step 12. 10. Let S be a string containing six characters "%uwxyz" where wxyz are - four hexadecimal digits encoding the value of Result(8). + four hexadecimal digits encoding the value of Result(8). 11. Go to step 15. 12. Let S be a string containing three characters "%xy" where xy are two - hexadecimal digits encoding the value of Result(8). + hexadecimal digits encoding the value of Result(8). 13. Go to step 15. 14. Let S be a string containing the single character Result(6). 15. Let R be a new string value computed by concatenating the previous value - of R and S. + of R and S. 16. Increase k by 1. 17. Go to step 5. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.2.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "escape(string)"; +var SECTION = "15.1.2.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "escape(string)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "escape.length", 1, escape.length ); +new TestCase( SECTION, "escape.length = null; escape.length", 1, eval("escape.length = null; escape.length") ); +new TestCase( SECTION, "delete escape.length", false, delete escape.length ); +new TestCase( SECTION, "delete escape.length; escape.length", 1, eval("delete escape.length; escape.length") ); +new TestCase( SECTION, "var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS", "", eval("var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS") ); - test(); +new TestCase( SECTION, "escape()", "undefined", escape() ); +new TestCase( SECTION, "escape('')", "", escape('') ); +new TestCase( SECTION, "escape( null )", "null", escape(null) ); +new TestCase( SECTION, "escape( void 0 )", "undefined", escape(void 0) ); +new TestCase( SECTION, "escape( true )", "true", escape( true ) ); +new TestCase( SECTION, "escape( false )", "false", escape( false ) ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "escape( new Boolean(true) )", "true", escape(new Boolean(true)) ); +new TestCase( SECTION, "escape( new Boolean(false) )", "false", escape(new Boolean(false)) ); - array[item++] = new TestCase( SECTION, "escape.length", 1, escape.length ); - array[item++] = new TestCase( SECTION, "escape.length = null; escape.length", 1, eval("escape.length = null; escape.length") ); - array[item++] = new TestCase( SECTION, "delete escape.length", false, delete escape.length ); - array[item++] = new TestCase( SECTION, "delete escape.length; escape.length", 1, eval("delete escape.length; escape.length") ); - array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS", "", eval("var MYPROPS=''; for ( var p in escape ) { MYPROPS+= p}; MYPROPS") ); +new TestCase( SECTION, "escape( Number.NaN )", "NaN", escape(Number.NaN) ); +new TestCase( SECTION, "escape( -0 )", "0", escape( -0 ) ); +new TestCase( SECTION, "escape( 'Infinity' )", "Infinity", escape( "Infinity" ) ); +new TestCase( SECTION, "escape( Number.POSITIVE_INFINITY )", "Infinity", escape( Number.POSITIVE_INFINITY ) ); +new TestCase( SECTION, "escape( Number.NEGATIVE_INFINITY )", "-Infinity", escape( Number.NEGATIVE_INFINITY ) ); - array[item++] = new TestCase( SECTION, "escape()", "undefined", escape() ); - array[item++] = new TestCase( SECTION, "escape('')", "", escape('') ); - array[item++] = new TestCase( SECTION, "escape( null )", "null", escape(null) ); - array[item++] = new TestCase( SECTION, "escape( void 0 )", "undefined", escape(void 0) ); - array[item++] = new TestCase( SECTION, "escape( true )", "true", escape( true ) ); - array[item++] = new TestCase( SECTION, "escape( false )", "false", escape( false ) ); +var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; - array[item++] = new TestCase( SECTION, "escape( new Boolean(true) )", "true", escape(new Boolean(true)) ); - array[item++] = new TestCase( SECTION, "escape( new Boolean(false) )", "false", escape(new Boolean(false)) ); +new TestCase( SECTION, "escape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, escape( ASCII_TEST_STRING ) ); - array[item++] = new TestCase( SECTION, "escape( Number.NaN )", "NaN", escape(Number.NaN) ); - array[item++] = new TestCase( SECTION, "escape( -0 )", "0", escape( -0 ) ); - array[item++] = new TestCase( SECTION, "escape( 'Infinity' )", "Infinity", escape( "Infinity" ) ); - array[item++] = new TestCase( SECTION, "escape( Number.POSITIVE_INFINITY )", "Infinity", escape( Number.POSITIVE_INFINITY ) ); - array[item++] = new TestCase( SECTION, "escape( Number.NEGATIVE_INFINITY )", "-Infinity", escape( Number.NEGATIVE_INFINITY ) ); +// ASCII value less than - var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; - - array[item++] = new TestCase( SECTION, "escape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, escape( ASCII_TEST_STRING ) ); - - // ASCII value less than - - for ( var CHARCODE = 0; CHARCODE < 32; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "escape(String.fromCharCode("+CHARCODE+"))", - "%"+ToHexString(CHARCODE), - escape(String.fromCharCode(CHARCODE)) ); - } - for ( var CHARCODE = 128; CHARCODE < 256; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "escape(String.fromCharCode("+CHARCODE+"))", - "%"+ToHexString(CHARCODE), - escape(String.fromCharCode(CHARCODE)) ); - } - - for ( var CHARCODE = 256; CHARCODE < 1024; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "escape(String.fromCharCode("+CHARCODE+"))", - "%u"+ ToUnicodeString(CHARCODE), - escape(String.fromCharCode(CHARCODE)) ); - } - for ( var CHARCODE = 65500; CHARCODE < 65536; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "escape(String.fromCharCode("+CHARCODE+"))", - "%u"+ ToUnicodeString(CHARCODE), - escape(String.fromCharCode(CHARCODE)) ); - } - - return ( array ); +for ( var CHARCODE = 0; CHARCODE < 32; CHARCODE++ ) { + new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%"+ToHexString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); } +for ( var CHARCODE = 128; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%"+ToHexString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); +} + +for ( var CHARCODE = 256; CHARCODE < 1024; CHARCODE++ ) { + new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%u"+ ToUnicodeString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); +} +for ( var CHARCODE = 65500; CHARCODE < 65536; CHARCODE++ ) { + new TestCase( SECTION, + "escape(String.fromCharCode("+CHARCODE+"))", + "%u"+ ToUnicodeString(CHARCODE), + escape(String.fromCharCode(CHARCODE)) ); +} + +test(); function ToUnicodeString( n ) { - var string = ToHexString(n); + var string = ToHexString(n); - for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { - string = "0" + string; - } + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } - return string; + return string; } function ToHexString( n ) { - var hex = new Array(); + var hex = new Array(); - for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { - ; + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; } + } - for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { - hex[index] = Math.floor( n / Math.pow(16,mag) ); - n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); - } - - hex[hex.length] = n % 16; - - var string =""; - - for ( var index = 0 ; index < hex.length ; index++ ) { - switch ( hex[index] ) { - case 10: - string += "A"; - break; - case 11: - string += "B"; - break; - case 12: - string += "C"; - break; - case 13: - string += "D"; - break; - case 14: - string += "E"; - break; - case 15: - string += "F"; - break; - default: - string += hex[index]; - } - } - - if ( string.length == 1 ) { - string = "0" + string; - } - return string; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + if ( string.length == 1 ) { + string = "0" + string; + } + return string; } diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-1.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-1.js index 63540c2c1d4..1d0e20a1041 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-1.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,189 +35,170 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.2.5-1.js - ECMA Section: 15.1.2.5 Function properties of the global object - unescape( string ) + File Name: 15.1.2.5-1.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) - Description: - The unescape function computes a new version of a string value in which - each escape sequences of the sort that might be introduced by the escape - function is replaced with the character that it represents. + Description: + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. - When the unescape function is called with one argument string, the - following steps are taken: + When the unescape function is called with one argument string, the + following steps are taken: - 1. Call ToString(string). - 2. Compute the number of characters in Result(1). - 3. Let R be the empty string. - 4. Let k be 0. - 5. If k equals Result(2), return R. - 6. Let c be the character at position k within Result(1). - 7. If c is not %, go to step 18. - 8. If k is greater than Result(2)-6, go to step 14. - 9. If the character at position k+1 within result(1) is not u, go to step - 14. - 10. If the four characters at positions k+2, k+3, k+4, and k+5 within - Result(1) are not all hexadecimal digits, go to step 14. - 11. Let c be the character whose Unicode encoding is the integer represented - by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 - within Result(1). - 12. Increase k by 5. - 13. Go to step 18. - 14. If k is greater than Result(2)-3, go to step 18. - 15. If the two characters at positions k+1 and k+2 within Result(1) are not - both hexadecimal digits, go to step 18. - 16. Let c be the character whose Unicode encoding is the integer represented - by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 - within Result(1). - 17. Increase k by 2. - 18. Let R be a new string value computed by concatenating the previous value - of R and c. - 19. Increase k by 1. - 20. Go to step 5. - Author: christine@netscape.com - Date: 28 october 1997 + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.2.5-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "unescape(string)"; +var SECTION = "15.1.2.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "unescape(string)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "unescape.length", 1, unescape.length ); +new TestCase( SECTION, "unescape.length = null; unescape.length", 1, eval("unescape.length=null; unescape.length") ); +new TestCase( SECTION, "delete unescape.length", false, delete unescape.length ); +new TestCase( SECTION, "delete unescape.length; unescape.length", 1, eval("delete unescape.length; unescape.length") ); +new TestCase( SECTION, "var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS") ); - test(); +new TestCase( SECTION, "unescape()", "undefined", unescape() ); +new TestCase( SECTION, "unescape('')", "", unescape('') ); +new TestCase( SECTION, "unescape( null )", "null", unescape(null) ); +new TestCase( SECTION, "unescape( void 0 )", "undefined", unescape(void 0) ); +new TestCase( SECTION, "unescape( true )", "true", unescape( true ) ); +new TestCase( SECTION, "unescape( false )", "false", unescape( false ) ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "unescape( new Boolean(true) )", "true", unescape(new Boolean(true)) ); +new TestCase( SECTION, "unescape( new Boolean(false) )", "false", unescape(new Boolean(false)) ); - array[item++] = new TestCase( SECTION, "unescape.length", 1, unescape.length ); - array[item++] = new TestCase( SECTION, "unescape.length = null; unescape.length", 1, eval("unescape.length=null; unescape.length") ); - array[item++] = new TestCase( SECTION, "delete unescape.length", false, delete unescape.length ); - array[item++] = new TestCase( SECTION, "delete unescape.length; unescape.length", 1, eval("delete unescape.length; unescape.length") ); - array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in unescape ) { MYPROPS+= p }; MYPROPS") ); +new TestCase( SECTION, "unescape( Number.NaN )", "NaN", unescape(Number.NaN) ); +new TestCase( SECTION, "unescape( -0 )", "0", unescape( -0 ) ); +new TestCase( SECTION, "unescape( 'Infinity' )", "Infinity", unescape( "Infinity" ) ); +new TestCase( SECTION, "unescape( Number.POSITIVE_INFINITY )", "Infinity", unescape( Number.POSITIVE_INFINITY ) ); +new TestCase( SECTION, "unescape( Number.NEGATIVE_INFINITY )", "-Infinity", unescape( Number.NEGATIVE_INFINITY ) ); - array[item++] = new TestCase( SECTION, "unescape()", "undefined", unescape() ); - array[item++] = new TestCase( SECTION, "unescape('')", "", unescape('') ); - array[item++] = new TestCase( SECTION, "unescape( null )", "null", unescape(null) ); - array[item++] = new TestCase( SECTION, "unescape( void 0 )", "undefined", unescape(void 0) ); - array[item++] = new TestCase( SECTION, "unescape( true )", "true", unescape( true ) ); - array[item++] = new TestCase( SECTION, "unescape( false )", "false", unescape( false ) ); +var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; - array[item++] = new TestCase( SECTION, "unescape( new Boolean(true) )", "true", unescape(new Boolean(true)) ); - array[item++] = new TestCase( SECTION, "unescape( new Boolean(false) )", "false", unescape(new Boolean(false)) ); +new TestCase( SECTION, "unescape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, unescape( ASCII_TEST_STRING ) ); - array[item++] = new TestCase( SECTION, "unescape( Number.NaN )", "NaN", unescape(Number.NaN) ); - array[item++] = new TestCase( SECTION, "unescape( -0 )", "0", unescape( -0 ) ); - array[item++] = new TestCase( SECTION, "unescape( 'Infinity' )", "Infinity", unescape( "Infinity" ) ); - array[item++] = new TestCase( SECTION, "unescape( Number.POSITIVE_INFINITY )", "Infinity", unescape( Number.POSITIVE_INFINITY ) ); - array[item++] = new TestCase( SECTION, "unescape( Number.NEGATIVE_INFINITY )", "-Infinity", unescape( Number.NEGATIVE_INFINITY ) ); +// escaped chars with ascii values less than 256 - var ASCII_TEST_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./"; - - array[item++] = new TestCase( SECTION, "unescape( " +ASCII_TEST_STRING+" )", ASCII_TEST_STRING, unescape( ASCII_TEST_STRING ) ); - - // escaped chars with ascii values less than 256 - - for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "unescape( %"+ ToHexString(CHARCODE)+" )", - String.fromCharCode(CHARCODE), - unescape( "%" + ToHexString(CHARCODE) ) ); - } - - // unicode chars represented by two hex digits - for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "unescape( %u"+ ToHexString(CHARCODE)+" )", - "%u"+ToHexString(CHARCODE), - unescape( "%u" + ToHexString(CHARCODE) ) ); - } -/* - for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", - String.fromCharCode(CHARCODE), - unescape( "%u" + ToUnicodeString(CHARCODE) ) ); - } - for ( var CHARCODE = 256; CHARCODE < 65536; CHARCODE+= 333 ) { - array[item++] = new TestCase( SECTION, - "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", - String.fromCharCode(CHARCODE), - unescape( "%u" + ToUnicodeString(CHARCODE) ) ); - } -*/ - return ( array ); +for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "unescape( %"+ ToHexString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%" + ToHexString(CHARCODE) ) ); } +// unicode chars represented by two hex digits +for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "unescape( %u"+ ToHexString(CHARCODE)+" )", + "%u"+ToHexString(CHARCODE), + unescape( "%u" + ToHexString(CHARCODE) ) ); +} +/* + for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%u" + ToUnicodeString(CHARCODE) ) ); + } + for ( var CHARCODE = 256; CHARCODE < 65536; CHARCODE+= 333 ) { + new TestCase( SECTION, + "unescape( %u"+ ToUnicodeString(CHARCODE)+" )", + String.fromCharCode(CHARCODE), + unescape( "%u" + ToUnicodeString(CHARCODE) ) ); + } +*/ + +test(); + function ToUnicodeString( n ) { - var string = ToHexString(n); + var string = ToHexString(n); - for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { - string = "0" + string; - } + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } - return string; + return string; } function ToHexString( n ) { - var hex = new Array(); + var hex = new Array(); - for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { - ; + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; } + } - for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { - hex[index] = Math.floor( n / Math.pow(16,mag) ); - n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); - } - - hex[hex.length] = n % 16; - - var string =""; - - for ( var index = 0 ; index < hex.length ; index++ ) { - switch ( hex[index] ) { - case 10: - string += "A"; - break; - case 11: - string += "B"; - break; - case 12: - string += "C"; - break; - case 13: - string += "D"; - break; - case 14: - string += "E"; - break; - case 15: - string += "F"; - break; - default: - string += hex[index]; - } - } - - if ( string.length == 1 ) { - string = "0" + string; - } - return string; -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + if ( string.length == 1 ) { + string = "0" + string; + } + return string; } diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-2.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-2.js index 59510f6ee16..3cdfa78dc51 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-2.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,166 +35,146 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.1.2.5-2.js - ECMA Section: 15.1.2.5 Function properties of the global object - unescape( string ) - Description: - - This tests the cases where there are fewer than 4 characters following "%u", - or fewer than 2 characters following "%" or "%u". - - The unescape function computes a new version of a string value in which - each escape sequences of the sort that might be introduced by the escape - function is replaced with the character that it represents. - - When the unescape function is called with one argument string, the - following steps are taken: - - 1. Call ToString(string). - 2. Compute the number of characters in Result(1). - 3. Let R be the empty string. - 4. Let k be 0. - 5. If k equals Result(2), return R. - 6. Let c be the character at position k within Result(1). - 7. If c is not %, go to step 18. - 8. If k is greater than Result(2)-6, go to step 14. - 9. If the character at position k+1 within result(1) is not u, go to step - 14. - 10. If the four characters at positions k+2, k+3, k+4, and k+5 within - Result(1) are not all hexadecimal digits, go to step 14. - 11. Let c be the character whose Unicode encoding is the integer represented - by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 - within Result(1). - 12. Increase k by 5. - 13. Go to step 18. - 14. If k is greater than Result(2)-3, go to step 18. - 15. If the two characters at positions k+1 and k+2 within Result(1) are not - both hexadecimal digits, go to step 18. - 16. Let c be the character whose Unicode encoding is the integer represented - by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 - within Result(1). - 17. Increase k by 2. - 18. Let R be a new string value computed by concatenating the previous value - of R and c. - 19. Increase k by 1. - 20. Go to step 5. - Author: christine@netscape.com - Date: 28 october 1997 -*/ - - var SECTION = "15.1.2.5-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "unescape(string)"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // since there is only one character following "%", no conversion should occur. - - for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE += 16 ) { - array[item++] = new TestCase( SECTION, - "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) +" )", - "%"+(ToHexString(CHARCODE)).substring(0,1), - unescape( "%" + (ToHexString(CHARCODE)).substring(0,1) ) ); - } - - // since there is only one character following "%u", no conversion should occur. - - for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE +=16 ) { - array[item++] = new TestCase( SECTION, - "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) +" )", - "%u"+(ToHexString(CHARCODE)).substring(0,1), - unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1) ) ); - } - - - // three char unicode string. no conversion should occur - - for ( var CHARCODE = 1024; CHARCODE < 65536; CHARCODE+= 1234 ) { - array[item++] = new TestCase - ( SECTION, - "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3)+ " )", - - "%u"+(ToUnicodeString(CHARCODE)).substring(0,3), - unescape( "%u"+(ToUnicodeString(CHARCODE)).substring(0,3) ) - ); - } - - return ( array ); -} - -function ToUnicodeString( n ) { - var string = ToHexString(n); - - for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { - string = "0" + string; - } - - return string; -} -function ToHexString( n ) { - var hex = new Array(); - - for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { - ; - } - - for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { - hex[index] = Math.floor( n / Math.pow(16,mag) ); - n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); - } - - hex[hex.length] = n % 16; - - var string =""; - - for ( var index = 0 ; index < hex.length ; index++ ) { - switch ( hex[index] ) { - case 10: - string += "A"; - break; - case 11: - string += "B"; - break; - case 12: - string += "C"; - break; - case 13: - string += "D"; - break; - case 14: - string += "E"; - break; - case 15: - string += "F"; - break; - default: - string += hex[index]; - } - } - - if ( string.length == 1 ) { - string = "0" + string; - } - return string; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.1.2.5-2.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + Description: + + This tests the cases where there are fewer than 4 characters following "%u", + or fewer than 2 characters following "%" or "%u". + + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + +var SECTION = "15.1.2.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "unescape(string)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +// since there is only one character following "%", no conversion should occur. + +for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE += 16 ) { + new TestCase( SECTION, + "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) +" )", + "%"+(ToHexString(CHARCODE)).substring(0,1), + unescape( "%" + (ToHexString(CHARCODE)).substring(0,1) ) ); +} + +// since there is only one character following "%u", no conversion should occur. + +for ( var CHARCODE = 0; CHARCODE < 256; CHARCODE +=16 ) { + new TestCase( SECTION, + "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) +" )", + "%u"+(ToHexString(CHARCODE)).substring(0,1), + unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1) ) ); +} + + +// three char unicode string. no conversion should occur + +for ( var CHARCODE = 1024; CHARCODE < 65536; CHARCODE+= 1234 ) { + new TestCase + ( SECTION, + "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3)+ " )", + + "%u"+(ToUnicodeString(CHARCODE)).substring(0,3), + unescape( "%u"+(ToUnicodeString(CHARCODE)).substring(0,3) ) + ); +} + +test(); + +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-3.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-3.js index 5d5389ea219..d19b99ee7d7 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-3.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.5-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,189 +35,170 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.1.2.5-3.js - ECMA Section: 15.1.2.5 Function properties of the global object - unescape( string ) - - Description: - This tests the cases where one of the four characters following "%u" is - not a hexidecimal character, or one of the two characters following "%" - or "%u" is not a hexidecimal character. - - The unescape function computes a new version of a string value in which - each escape sequences of the sort that might be introduced by the escape - function is replaced with the character that it represents. - - When the unescape function is called with one argument string, the - following steps are taken: - - 1. Call ToString(string). - 2. Compute the number of characters in Result(1). - 3. Let R be the empty string. - 4. Let k be 0. - 5. If k equals Result(2), return R. - 6. Let c be the character at position k within Result(1). - 7. If c is not %, go to step 18. - 8. If k is greater than Result(2)-6, go to step 14. - 9. If the character at position k+1 within result(1) is not u, go to step - 14. - 10. If the four characters at positions k+2, k+3, k+4, and k+5 within - Result(1) are not all hexadecimal digits, go to step 14. - 11. Let c be the character whose Unicode encoding is the integer represented - by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 - within Result(1). - 12. Increase k by 5. - 13. Go to step 18. - 14. If k is greater than Result(2)-3, go to step 18. - 15. If the two characters at positions k+1 and k+2 within Result(1) are not - both hexadecimal digits, go to step 18. - 16. Let c be the character whose Unicode encoding is the integer represented - by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 - within Result(1). - 17. Increase k by 2. - 18. Let R be a new string value computed by concatenating the previous value - of R and c. - 19. Increase k by 1. - 20. Go to step 5. - Author: christine@netscape.com - Date: 28 october 1997 -*/ - - - var SECTION = "15.1.2.5-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "unescape(string)"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { - NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); - - array[item++] = new TestCase( SECTION, - "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) + - String.fromCharCode( NONHEXCHARCODE ) +" )" + - "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", - "%"+(ToHexString(CHARCODE)).substring(0,1)+ - String.fromCharCode( NONHEXCHARCODE ), - unescape( "%" + (ToHexString(CHARCODE)).substring(0,1)+ - String.fromCharCode( NONHEXCHARCODE ) ) ); - } - for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { - NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); - - array[item++] = new TestCase( SECTION, - "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) + - String.fromCharCode( NONHEXCHARCODE ) +" )" + - "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", - "%u"+(ToHexString(CHARCODE)).substring(0,1)+ - String.fromCharCode( NONHEXCHARCODE ), - unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1)+ - String.fromCharCode( NONHEXCHARCODE ) ) ); - } - - for ( var CHARCODE = 0, NONHEXCHARCODE = 0 ; CHARCODE < 65536; CHARCODE+= 54321, NONHEXCHARCODE++ ) { - NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); - - array[item++] = new TestCase( SECTION, - "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3) + - String.fromCharCode( NONHEXCHARCODE ) +" )" + - "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", - - String.fromCharCode(eval("0x"+ (ToUnicodeString(CHARCODE)).substring(0,2))) + - (ToUnicodeString(CHARCODE)).substring(2,3) + - String.fromCharCode( NONHEXCHARCODE ), - - unescape( "%" + (ToUnicodeString(CHARCODE)).substring(0,3)+ - String.fromCharCode( NONHEXCHARCODE ) ) ); - } - - return ( array ); -} -function getNextNonHexCharCode( n ) { - for ( ; n < Math.pow(2,16); n++ ) { - if ( ( n == 43 || n == 45 || n == 46 || n == 47 || - (n >= 71 && n <= 90) || (n >= 103 && n <= 122) || - n == 64 || n == 95 ) ) { - break; - } else { - n = ( n > 122 ) ? 0 : n; - } - } - return n; -} -function ToUnicodeString( n ) { - var string = ToHexString(n); - - for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { - string = "0" + string; - } - - return string; -} -function ToHexString( n ) { - var hex = new Array(); - - for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { - ; - } - - for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { - hex[index] = Math.floor( n / Math.pow(16,mag) ); - n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); - } - - hex[hex.length] = n % 16; - - var string =""; - - for ( var index = 0 ; index < hex.length ; index++ ) { - switch ( hex[index] ) { - case 10: - string += "A"; - break; - case 11: - string += "B"; - break; - case 12: - string += "C"; - break; - case 13: - string += "D"; - break; - case 14: - string += "E"; - break; - case 15: - string += "F"; - break; - default: - string += hex[index]; - } - } - - if ( string.length == 1 ) { - string = "0" + string; - } - return string; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.1.2.5-3.js + ECMA Section: 15.1.2.5 Function properties of the global object + unescape( string ) + + Description: + This tests the cases where one of the four characters following "%u" is + not a hexidecimal character, or one of the two characters following "%" + or "%u" is not a hexidecimal character. + + The unescape function computes a new version of a string value in which + each escape sequences of the sort that might be introduced by the escape + function is replaced with the character that it represents. + + When the unescape function is called with one argument string, the + following steps are taken: + + 1. Call ToString(string). + 2. Compute the number of characters in Result(1). + 3. Let R be the empty string. + 4. Let k be 0. + 5. If k equals Result(2), return R. + 6. Let c be the character at position k within Result(1). + 7. If c is not %, go to step 18. + 8. If k is greater than Result(2)-6, go to step 14. + 9. If the character at position k+1 within result(1) is not u, go to step + 14. + 10. If the four characters at positions k+2, k+3, k+4, and k+5 within + Result(1) are not all hexadecimal digits, go to step 14. + 11. Let c be the character whose Unicode encoding is the integer represented + by the four hexadecimal digits at positions k+2, k+3, k+4, and k+5 + within Result(1). + 12. Increase k by 5. + 13. Go to step 18. + 14. If k is greater than Result(2)-3, go to step 18. + 15. If the two characters at positions k+1 and k+2 within Result(1) are not + both hexadecimal digits, go to step 18. + 16. Let c be the character whose Unicode encoding is the integer represented + by two zeroes plus the two hexadecimal digits at positions k+1 and k+2 + within Result(1). + 17. Increase k by 2. + 18. Let R be a new string value computed by concatenating the previous value + of R and c. + 19. Increase k by 1. + 20. Go to step 5. + Author: christine@netscape.com + Date: 28 october 1997 +*/ + + +var SECTION = "15.1.2.5-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "unescape(string)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + new TestCase( SECTION, + "unescape( %"+ (ToHexString(CHARCODE)).substring(0,1) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + "%"+(ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ), + unescape( "%" + (ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); +} +for ( var CHARCODE = 0, NONHEXCHARCODE = 0; CHARCODE < 256; CHARCODE++, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + new TestCase( SECTION, + "unescape( %u"+ (ToHexString(CHARCODE)).substring(0,1) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + "%u"+(ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ), + unescape( "%u" + (ToHexString(CHARCODE)).substring(0,1)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); +} + +for ( var CHARCODE = 0, NONHEXCHARCODE = 0 ; CHARCODE < 65536; CHARCODE+= 54321, NONHEXCHARCODE++ ) { + NONHEXCHARCODE = getNextNonHexCharCode( NONHEXCHARCODE ); + + new TestCase( SECTION, + "unescape( %u"+ (ToUnicodeString(CHARCODE)).substring(0,3) + + String.fromCharCode( NONHEXCHARCODE ) +" )" + + "[where last character is String.fromCharCode("+NONHEXCHARCODE+")]", + + String.fromCharCode(eval("0x"+ (ToUnicodeString(CHARCODE)).substring(0,2))) + + (ToUnicodeString(CHARCODE)).substring(2,3) + + String.fromCharCode( NONHEXCHARCODE ), + + unescape( "%" + (ToUnicodeString(CHARCODE)).substring(0,3)+ + String.fromCharCode( NONHEXCHARCODE ) ) ); +} + +test(); + +function getNextNonHexCharCode( n ) { + for ( ; n < Math.pow(2,16); n++ ) { + if ( ( n == 43 || n == 45 || n == 46 || n == 47 || + (n >= 71 && n <= 90) || (n >= 103 && n <= 122) || + n == 64 || n == 95 ) ) { + break; + } else { + n = ( n > 122 ) ? 0 : n; + } + } + return n; +} +function ToUnicodeString( n ) { + var string = ToHexString(n); + + for ( var PAD = (4 - string.length ); PAD > 0; PAD-- ) { + string = "0" + string; + } + + return string; +} +function ToHexString( n ) { + var hex = new Array(); + + for ( var mag = 1; Math.pow(16,mag) <= n ; mag++ ) { + ; + } + + for ( index = 0, mag -= 1; mag > 0; index++, mag-- ) { + hex[index] = Math.floor( n / Math.pow(16,mag) ); + n -= Math.pow(16,mag) * Math.floor( n/Math.pow(16,mag) ); + } + + hex[hex.length] = n % 16; + + var string =""; + + for ( var index = 0 ; index < hex.length ; index++ ) { + switch ( hex[index] ) { + case 10: + string += "A"; + break; + case 11: + string += "B"; + break; + case 12: + string += "C"; + break; + case 13: + string += "D"; + break; + case 14: + string += "E"; + break; + case 15: + string += "F"; + break; + default: + string += hex[index]; + } + } + + if ( string.length == 1 ) { + string = "0" + string; + } + return string; +} diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.6.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.6.js index c0935eae354..02357c44c62 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.6.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,109 +35,89 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.2.6.js - ECMA Section: 15.1.2.6 isNaN( x ) + File Name: 15.1.2.6.js + ECMA Section: 15.1.2.6 isNaN( x ) - Description: Applies ToNumber to its argument, then returns true if - the result isNaN and otherwise returns false. + Description: Applies ToNumber to its argument, then returns true if + the result isNaN and otherwise returns false. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.2.6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "isNaN( x )"; +var SECTION = "15.1.2.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "isNaN( x )"; - var BUGNUMBER = "77391"; +var BUGNUMBER = "77391"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "isNaN.length", 1, isNaN.length ); +new TestCase( SECTION, "var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS") ); +new TestCase( SECTION, "isNaN.length = null; isNaN.length", 1, eval("isNaN.length=null; isNaN.length") ); +new TestCase( SECTION, "delete isNaN.length", false, delete isNaN.length ); +new TestCase( SECTION, "delete isNaN.length; isNaN.length", 1, eval("delete isNaN.length; isNaN.length") ); - test(); +// new TestCase( SECTION, "isNaN.__proto__", Function.prototype, isNaN.__proto__ ); + +new TestCase( SECTION, "isNaN()", true, isNaN() ); +new TestCase( SECTION, "isNaN( null )", false, isNaN(null) ); +new TestCase( SECTION, "isNaN( void 0 )", true, isNaN(void 0) ); +new TestCase( SECTION, "isNaN( true )", false, isNaN(true) ); +new TestCase( SECTION, "isNaN( false)", false, isNaN(false) ); +new TestCase( SECTION, "isNaN( ' ' )", false, isNaN( " " ) ); + +new TestCase( SECTION, "isNaN( 0 )", false, isNaN(0) ); +new TestCase( SECTION, "isNaN( 1 )", false, isNaN(1) ); +new TestCase( SECTION, "isNaN( 2 )", false, isNaN(2) ); +new TestCase( SECTION, "isNaN( 3 )", false, isNaN(3) ); +new TestCase( SECTION, "isNaN( 4 )", false, isNaN(4) ); +new TestCase( SECTION, "isNaN( 5 )", false, isNaN(5) ); +new TestCase( SECTION, "isNaN( 6 )", false, isNaN(6) ); +new TestCase( SECTION, "isNaN( 7 )", false, isNaN(7) ); +new TestCase( SECTION, "isNaN( 8 )", false, isNaN(8) ); +new TestCase( SECTION, "isNaN( 9 )", false, isNaN(9) ); + +new TestCase( SECTION, "isNaN( '0' )", false, isNaN('0') ); +new TestCase( SECTION, "isNaN( '1' )", false, isNaN('1') ); +new TestCase( SECTION, "isNaN( '2' )", false, isNaN('2') ); +new TestCase( SECTION, "isNaN( '3' )", false, isNaN('3') ); +new TestCase( SECTION, "isNaN( '4' )", false, isNaN('4') ); +new TestCase( SECTION, "isNaN( '5' )", false, isNaN('5') ); +new TestCase( SECTION, "isNaN( '6' )", false, isNaN('6') ); +new TestCase( SECTION, "isNaN( '7' )", false, isNaN('7') ); +new TestCase( SECTION, "isNaN( '8' )", false, isNaN('8') ); +new TestCase( SECTION, "isNaN( '9' )", false, isNaN('9') ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "isNaN( 0x0a )", false, isNaN( 0x0a ) ); +new TestCase( SECTION, "isNaN( 0xaa )", false, isNaN( 0xaa ) ); +new TestCase( SECTION, "isNaN( 0x0A )", false, isNaN( 0x0A ) ); +new TestCase( SECTION, "isNaN( 0xAA )", false, isNaN( 0xAA ) ); - array[item++] = new TestCase( SECTION, "isNaN.length", 1, isNaN.length ); - array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( var p in isNaN ) { MYPROPS+= p }; MYPROPS") ); - array[item++] = new TestCase( SECTION, "isNaN.length = null; isNaN.length", 1, eval("isNaN.length=null; isNaN.length") ); - array[item++] = new TestCase( SECTION, "delete isNaN.length", false, delete isNaN.length ); - array[item++] = new TestCase( SECTION, "delete isNaN.length; isNaN.length", 1, eval("delete isNaN.length; isNaN.length") ); +new TestCase( SECTION, "isNaN( '0x0a' )", false, isNaN( "0x0a" ) ); +new TestCase( SECTION, "isNaN( '0xaa' )", false, isNaN( "0xaa" ) ); +new TestCase( SECTION, "isNaN( '0x0A' )", false, isNaN( "0x0A" ) ); +new TestCase( SECTION, "isNaN( '0xAA' )", false, isNaN( "0xAA" ) ); -// array[item++] = new TestCase( SECTION, "isNaN.__proto__", Function.prototype, isNaN.__proto__ ); - - array[item++] = new TestCase( SECTION, "isNaN()", true, isNaN() ); - array[item++] = new TestCase( SECTION, "isNaN( null )", false, isNaN(null) ); - array[item++] = new TestCase( SECTION, "isNaN( void 0 )", true, isNaN(void 0) ); - array[item++] = new TestCase( SECTION, "isNaN( true )", false, isNaN(true) ); - array[item++] = new TestCase( SECTION, "isNaN( false)", false, isNaN(false) ); - array[item++] = new TestCase( SECTION, "isNaN( ' ' )", false, isNaN( " " ) ); - - array[item++] = new TestCase( SECTION, "isNaN( 0 )", false, isNaN(0) ); - array[item++] = new TestCase( SECTION, "isNaN( 1 )", false, isNaN(1) ); - array[item++] = new TestCase( SECTION, "isNaN( 2 )", false, isNaN(2) ); - array[item++] = new TestCase( SECTION, "isNaN( 3 )", false, isNaN(3) ); - array[item++] = new TestCase( SECTION, "isNaN( 4 )", false, isNaN(4) ); - array[item++] = new TestCase( SECTION, "isNaN( 5 )", false, isNaN(5) ); - array[item++] = new TestCase( SECTION, "isNaN( 6 )", false, isNaN(6) ); - array[item++] = new TestCase( SECTION, "isNaN( 7 )", false, isNaN(7) ); - array[item++] = new TestCase( SECTION, "isNaN( 8 )", false, isNaN(8) ); - array[item++] = new TestCase( SECTION, "isNaN( 9 )", false, isNaN(9) ); - - array[item++] = new TestCase( SECTION, "isNaN( '0' )", false, isNaN('0') ); - array[item++] = new TestCase( SECTION, "isNaN( '1' )", false, isNaN('1') ); - array[item++] = new TestCase( SECTION, "isNaN( '2' )", false, isNaN('2') ); - array[item++] = new TestCase( SECTION, "isNaN( '3' )", false, isNaN('3') ); - array[item++] = new TestCase( SECTION, "isNaN( '4' )", false, isNaN('4') ); - array[item++] = new TestCase( SECTION, "isNaN( '5' )", false, isNaN('5') ); - array[item++] = new TestCase( SECTION, "isNaN( '6' )", false, isNaN('6') ); - array[item++] = new TestCase( SECTION, "isNaN( '7' )", false, isNaN('7') ); - array[item++] = new TestCase( SECTION, "isNaN( '8' )", false, isNaN('8') ); - array[item++] = new TestCase( SECTION, "isNaN( '9' )", false, isNaN('9') ); +new TestCase( SECTION, "isNaN( 077 )", false, isNaN( 077 ) ); +new TestCase( SECTION, "isNaN( '077' )", false, isNaN( "077" ) ); - array[item++] = new TestCase( SECTION, "isNaN( 0x0a )", false, isNaN( 0x0a ) ); - array[item++] = new TestCase( SECTION, "isNaN( 0xaa )", false, isNaN( 0xaa ) ); - array[item++] = new TestCase( SECTION, "isNaN( 0x0A )", false, isNaN( 0x0A ) ); - array[item++] = new TestCase( SECTION, "isNaN( 0xAA )", false, isNaN( 0xAA ) ); +new TestCase( SECTION, "isNaN( Number.NaN )", true, isNaN(Number.NaN) ); +new TestCase( SECTION, "isNaN( Number.POSITIVE_INFINITY )", false, isNaN(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "isNaN( Number.NEGATIVE_INFINITY )", false, isNaN(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "isNaN( Number.MAX_VALUE )", false, isNaN(Number.MAX_VALUE) ); +new TestCase( SECTION, "isNaN( Number.MIN_VALUE )", false, isNaN(Number.MIN_VALUE) ); - array[item++] = new TestCase( SECTION, "isNaN( '0x0a' )", false, isNaN( "0x0a" ) ); - array[item++] = new TestCase( SECTION, "isNaN( '0xaa' )", false, isNaN( "0xaa" ) ); - array[item++] = new TestCase( SECTION, "isNaN( '0x0A' )", false, isNaN( "0x0A" ) ); - array[item++] = new TestCase( SECTION, "isNaN( '0xAA' )", false, isNaN( "0xAA" ) ); +new TestCase( SECTION, "isNaN( NaN )", true, isNaN(NaN) ); +new TestCase( SECTION, "isNaN( Infinity )", false, isNaN(Infinity) ); - array[item++] = new TestCase( SECTION, "isNaN( 077 )", false, isNaN( 077 ) ); - array[item++] = new TestCase( SECTION, "isNaN( '077' )", false, isNaN( "077" ) ); +new TestCase( SECTION, "isNaN( 'Infinity' )", false, isNaN("Infinity") ); +new TestCase( SECTION, "isNaN( '-Infinity' )", false, isNaN("-Infinity") ); - - array[item++] = new TestCase( SECTION, "isNaN( Number.NaN )", true, isNaN(Number.NaN) ); - array[item++] = new TestCase( SECTION, "isNaN( Number.POSITIVE_INFINITY )", false, isNaN(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "isNaN( Number.NEGATIVE_INFINITY )", false, isNaN(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "isNaN( Number.MAX_VALUE )", false, isNaN(Number.MAX_VALUE) ); - array[item++] = new TestCase( SECTION, "isNaN( Number.MIN_VALUE )", false, isNaN(Number.MIN_VALUE) ); - - array[item++] = new TestCase( SECTION, "isNaN( NaN )", true, isNaN(NaN) ); - array[item++] = new TestCase( SECTION, "isNaN( Infinity )", false, isNaN(Infinity) ); - - array[item++] = new TestCase( SECTION, "isNaN( 'Infinity' )", false, isNaN("Infinity") ); - array[item++] = new TestCase( SECTION, "isNaN( '-Infinity' )", false, isNaN("-Infinity") ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/15.1.2.7.js b/mozilla/js/tests/ecma/GlobalObject/15.1.2.7.js index 5879d08be6b..724ef29f907 100644 --- a/mozilla/js/tests/ecma/GlobalObject/15.1.2.7.js +++ b/mozilla/js/tests/ecma/GlobalObject/15.1.2.7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,113 +35,94 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.1.2.7.js - ECMA Section: 15.1.2.7 isFinite(number) + File Name: 15.1.2.7.js + ECMA Section: 15.1.2.7 isFinite(number) - Description: Applies ToNumber to its argument, then returns false if - the result is NaN, Infinity, or -Infinity, and otherwise - returns true. + Description: Applies ToNumber to its argument, then returns false if + the result is NaN, Infinity, or -Infinity, and otherwise + returns true. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.1.2.7"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "isFinite( x )"; +var SECTION = "15.1.2.7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "isFinite( x )"; - var BUGNUMBER= "77391"; +var BUGNUMBER= "77391"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "isFinite.length", 1, isFinite.length ); +new TestCase( SECTION, "isFinite.length = null; isFinite.length", 1, eval("isFinite.length=null; isFinite.length") ); +new TestCase( SECTION, "delete isFinite.length", false, delete isFinite.length ); +new TestCase( SECTION, "delete isFinite.length; isFinite.length", 1, eval("delete isFinite.length; isFinite.length") ); +new TestCase( SECTION, "var MYPROPS=''; for ( p in isFinite ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( p in isFinite ) { MYPROPS += p }; MYPROPS") ); - test(); +new TestCase( SECTION, "isFinite()", false, isFinite() ); +new TestCase( SECTION, "isFinite( null )", true, isFinite(null) ); +new TestCase( SECTION, "isFinite( void 0 )", false, isFinite(void 0) ); +new TestCase( SECTION, "isFinite( false )", true, isFinite(false) ); +new TestCase( SECTION, "isFinite( true)", true, isFinite(true) ); +new TestCase( SECTION, "isFinite( ' ' )", true, isFinite( " " ) ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "isFinite( new Boolean(true) )", true, isFinite(new Boolean(true)) ); +new TestCase( SECTION, "isFinite( new Boolean(false) )", true, isFinite(new Boolean(false)) ); - array[item++] = new TestCase( SECTION, "isFinite.length", 1, isFinite.length ); - array[item++] = new TestCase( SECTION, "isFinite.length = null; isFinite.length", 1, eval("isFinite.length=null; isFinite.length") ); - array[item++] = new TestCase( SECTION, "delete isFinite.length", false, delete isFinite.length ); - array[item++] = new TestCase( SECTION, "delete isFinite.length; isFinite.length", 1, eval("delete isFinite.length; isFinite.length") ); - array[item++] = new TestCase( SECTION, "var MYPROPS=''; for ( p in isFinite ) { MYPROPS+= p }; MYPROPS", "", eval("var MYPROPS=''; for ( p in isFinite ) { MYPROPS += p }; MYPROPS") ); +new TestCase( SECTION, "isFinite( 0 )", true, isFinite(0) ); +new TestCase( SECTION, "isFinite( 1 )", true, isFinite(1) ); +new TestCase( SECTION, "isFinite( 2 )", true, isFinite(2) ); +new TestCase( SECTION, "isFinite( 3 )", true, isFinite(3) ); +new TestCase( SECTION, "isFinite( 4 )", true, isFinite(4) ); +new TestCase( SECTION, "isFinite( 5 )", true, isFinite(5) ); +new TestCase( SECTION, "isFinite( 6 )", true, isFinite(6) ); +new TestCase( SECTION, "isFinite( 7 )", true, isFinite(7) ); +new TestCase( SECTION, "isFinite( 8 )", true, isFinite(8) ); +new TestCase( SECTION, "isFinite( 9 )", true, isFinite(9) ); - array[item++] = new TestCase( SECTION, "isFinite()", false, isFinite() ); - array[item++] = new TestCase( SECTION, "isFinite( null )", true, isFinite(null) ); - array[item++] = new TestCase( SECTION, "isFinite( void 0 )", false, isFinite(void 0) ); - array[item++] = new TestCase( SECTION, "isFinite( false )", true, isFinite(false) ); - array[item++] = new TestCase( SECTION, "isFinite( true)", true, isFinite(true) ); - array[item++] = new TestCase( SECTION, "isFinite( ' ' )", true, isFinite( " " ) ); +new TestCase( SECTION, "isFinite( '0' )", true, isFinite('0') ); +new TestCase( SECTION, "isFinite( '1' )", true, isFinite('1') ); +new TestCase( SECTION, "isFinite( '2' )", true, isFinite('2') ); +new TestCase( SECTION, "isFinite( '3' )", true, isFinite('3') ); +new TestCase( SECTION, "isFinite( '4' )", true, isFinite('4') ); +new TestCase( SECTION, "isFinite( '5' )", true, isFinite('5') ); +new TestCase( SECTION, "isFinite( '6' )", true, isFinite('6') ); +new TestCase( SECTION, "isFinite( '7' )", true, isFinite('7') ); +new TestCase( SECTION, "isFinite( '8' )", true, isFinite('8') ); +new TestCase( SECTION, "isFinite( '9' )", true, isFinite('9') ); - array[item++] = new TestCase( SECTION, "isFinite( new Boolean(true) )", true, isFinite(new Boolean(true)) ); - array[item++] = new TestCase( SECTION, "isFinite( new Boolean(false) )", true, isFinite(new Boolean(false)) ); +new TestCase( SECTION, "isFinite( 0x0a )", true, isFinite( 0x0a ) ); +new TestCase( SECTION, "isFinite( 0xaa )", true, isFinite( 0xaa ) ); +new TestCase( SECTION, "isFinite( 0x0A )", true, isFinite( 0x0A ) ); +new TestCase( SECTION, "isFinite( 0xAA )", true, isFinite( 0xAA ) ); - array[item++] = new TestCase( SECTION, "isFinite( 0 )", true, isFinite(0) ); - array[item++] = new TestCase( SECTION, "isFinite( 1 )", true, isFinite(1) ); - array[item++] = new TestCase( SECTION, "isFinite( 2 )", true, isFinite(2) ); - array[item++] = new TestCase( SECTION, "isFinite( 3 )", true, isFinite(3) ); - array[item++] = new TestCase( SECTION, "isFinite( 4 )", true, isFinite(4) ); - array[item++] = new TestCase( SECTION, "isFinite( 5 )", true, isFinite(5) ); - array[item++] = new TestCase( SECTION, "isFinite( 6 )", true, isFinite(6) ); - array[item++] = new TestCase( SECTION, "isFinite( 7 )", true, isFinite(7) ); - array[item++] = new TestCase( SECTION, "isFinite( 8 )", true, isFinite(8) ); - array[item++] = new TestCase( SECTION, "isFinite( 9 )", true, isFinite(9) ); +new TestCase( SECTION, "isFinite( '0x0a' )", true, isFinite( "0x0a" ) ); +new TestCase( SECTION, "isFinite( '0xaa' )", true, isFinite( "0xaa" ) ); +new TestCase( SECTION, "isFinite( '0x0A' )", true, isFinite( "0x0A" ) ); +new TestCase( SECTION, "isFinite( '0xAA' )", true, isFinite( "0xAA" ) ); - array[item++] = new TestCase( SECTION, "isFinite( '0' )", true, isFinite('0') ); - array[item++] = new TestCase( SECTION, "isFinite( '1' )", true, isFinite('1') ); - array[item++] = new TestCase( SECTION, "isFinite( '2' )", true, isFinite('2') ); - array[item++] = new TestCase( SECTION, "isFinite( '3' )", true, isFinite('3') ); - array[item++] = new TestCase( SECTION, "isFinite( '4' )", true, isFinite('4') ); - array[item++] = new TestCase( SECTION, "isFinite( '5' )", true, isFinite('5') ); - array[item++] = new TestCase( SECTION, "isFinite( '6' )", true, isFinite('6') ); - array[item++] = new TestCase( SECTION, "isFinite( '7' )", true, isFinite('7') ); - array[item++] = new TestCase( SECTION, "isFinite( '8' )", true, isFinite('8') ); - array[item++] = new TestCase( SECTION, "isFinite( '9' )", true, isFinite('9') ); +new TestCase( SECTION, "isFinite( 077 )", true, isFinite( 077 ) ); +new TestCase( SECTION, "isFinite( '077' )", true, isFinite( "077" ) ); - array[item++] = new TestCase( SECTION, "isFinite( 0x0a )", true, isFinite( 0x0a ) ); - array[item++] = new TestCase( SECTION, "isFinite( 0xaa )", true, isFinite( 0xaa ) ); - array[item++] = new TestCase( SECTION, "isFinite( 0x0A )", true, isFinite( 0x0A ) ); - array[item++] = new TestCase( SECTION, "isFinite( 0xAA )", true, isFinite( 0xAA ) ); +new TestCase( SECTION, "isFinite( new String('Infinity') )", false, isFinite(new String("Infinity")) ); +new TestCase( SECTION, "isFinite( new String('-Infinity') )", false, isFinite(new String("-Infinity")) ); - array[item++] = new TestCase( SECTION, "isFinite( '0x0a' )", true, isFinite( "0x0a" ) ); - array[item++] = new TestCase( SECTION, "isFinite( '0xaa' )", true, isFinite( "0xaa" ) ); - array[item++] = new TestCase( SECTION, "isFinite( '0x0A' )", true, isFinite( "0x0A" ) ); - array[item++] = new TestCase( SECTION, "isFinite( '0xAA' )", true, isFinite( "0xAA" ) ); +new TestCase( SECTION, "isFinite( 'Infinity' )", false, isFinite("Infinity") ); +new TestCase( SECTION, "isFinite( '-Infinity' )", false, isFinite("-Infinity") ); +new TestCase( SECTION, "isFinite( Number.POSITIVE_INFINITY )", false, isFinite(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "isFinite( Number.NEGATIVE_INFINITY )", false, isFinite(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "isFinite( Number.NaN )", false, isFinite(Number.NaN) ); - array[item++] = new TestCase( SECTION, "isFinite( 077 )", true, isFinite( 077 ) ); - array[item++] = new TestCase( SECTION, "isFinite( '077' )", true, isFinite( "077" ) ); - - array[item++] = new TestCase( SECTION, "isFinite( new String('Infinity') )", false, isFinite(new String("Infinity")) ); - array[item++] = new TestCase( SECTION, "isFinite( new String('-Infinity') )", false, isFinite(new String("-Infinity")) ); - - array[item++] = new TestCase( SECTION, "isFinite( 'Infinity' )", false, isFinite("Infinity") ); - array[item++] = new TestCase( SECTION, "isFinite( '-Infinity' )", false, isFinite("-Infinity") ); - array[item++] = new TestCase( SECTION, "isFinite( Number.POSITIVE_INFINITY )", false, isFinite(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "isFinite( Number.NEGATIVE_INFINITY )", false, isFinite(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "isFinite( Number.NaN )", false, isFinite(Number.NaN) ); - - array[item++] = new TestCase( SECTION, "isFinite( Infinity )", false, isFinite(Infinity) ); - array[item++] = new TestCase( SECTION, "isFinite( -Infinity )", false, isFinite(-Infinity) ); - array[item++] = new TestCase( SECTION, "isFinite( NaN )", false, isFinite(NaN) ); +new TestCase( SECTION, "isFinite( Infinity )", false, isFinite(Infinity) ); +new TestCase( SECTION, "isFinite( -Infinity )", false, isFinite(-Infinity) ); +new TestCase( SECTION, "isFinite( NaN )", false, isFinite(NaN) ); - array[item++] = new TestCase( SECTION, "isFinite( Number.MAX_VALUE )", true, isFinite(Number.MAX_VALUE) ); - array[item++] = new TestCase( SECTION, "isFinite( Number.MIN_VALUE )", true, isFinite(Number.MIN_VALUE) ); +new TestCase( SECTION, "isFinite( Number.MAX_VALUE )", true, isFinite(Number.MAX_VALUE) ); +new TestCase( SECTION, "isFinite( Number.MIN_VALUE )", true, isFinite(Number.MIN_VALUE) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/GlobalObject/browser.js b/mozilla/js/tests/ecma/GlobalObject/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/GlobalObject/shell.js b/mozilla/js/tests/ecma/GlobalObject/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.1-1.js b/mozilla/js/tests/ecma/LexicalConventions/7.1-1.js index 810eb3bb960..14e4d7cb6e1 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.1-1.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,68 +35,46 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.1-1.js - ECMA Section: 7.1 White Space - Description: - readability - - separate tokens - - otherwise should be insignificant - - in strings, white space characters are significant - - cannot appear within any other kind of token + File Name: 7.1-1.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token - white space characters are: - unicode name formal name string representation - \u0009 tab \t - \u000B veritical tab \v - \U000C form feed \f - \u0020 space " " + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab \v + \U000C form feed \f + \u0020 space " " - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "White Space"; +var SECTION = "7.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "White Space"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// whitespace between var keyword and identifier +new TestCase( SECTION, 'var'+'\t'+'MYVAR1=10;MYVAR1', 10, eval('var'+'\t'+'MYVAR1=10;MYVAR1') ); +new TestCase( SECTION, 'var'+'\f'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\f'+'MYVAR2=10;MYVAR2') ); +new TestCase( SECTION, 'var'+'\v'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\v'+'MYVAR2=10;MYVAR2') ); +new TestCase( SECTION, 'var'+'\ '+'MYVAR2=10;MYVAR2', 10, eval('var'+'\ '+'MYVAR2=10;MYVAR2') ); -function getTestCases() { - var array = new Array(); - var item = 0; +// use whitespace between tokens object name, dot operator, and object property - // whitespace between var keyword and identifier +new TestCase( SECTION, + "var a = new Array(12345); a\t\v\f .\\u0009\\000B\\u000C\\u0020length", + 12345, + eval("var a = new Array(12345); a\t\v\f .\u0009\u0020\u000C\u000Blength") ); - array[item++] = new TestCase( SECTION, 'var'+'\t'+'MYVAR1=10;MYVAR1', 10, eval('var'+'\t'+'MYVAR1=10;MYVAR1') ); - array[item++] = new TestCase( SECTION, 'var'+'\f'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\f'+'MYVAR2=10;MYVAR2') ); - array[item++] = new TestCase( SECTION, 'var'+'\v'+'MYVAR2=10;MYVAR2', 10, eval('var'+'\v'+'MYVAR2=10;MYVAR2') ); - array[item++] = new TestCase( SECTION, 'var'+'\ '+'MYVAR2=10;MYVAR2', 10, eval('var'+'\ '+'MYVAR2=10;MYVAR2') ); - - // use whitespace between tokens object name, dot operator, and object property - - array[item++] = new TestCase( SECTION, - "var a = new Array(12345); a\t\v\f .\\u0009\\000B\\u000C\\u0020length", - 12345, - eval("var a = new Array(12345); a\t\v\f .\u0009\u0020\u000C\u000Blength") ); - - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.1-2.js b/mozilla/js/tests/ecma/LexicalConventions/7.1-2.js index 9b6de77c196..03a1c0253cd 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.1-2.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,56 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.1-2.js - ECMA Section: 7.1 White Space - Description: - readability - - separate tokens - - otherwise should be insignificant - - in strings, white space characters are significant - - cannot appear within any other kind of token + File Name: 7.1-2.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token - white space characters are: - unicode name formal name string representation - \u0009 tab \t - \u000B veritical tab ?? - \U000C form feed \f - \u0020 space " " + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab ?? + \U000C form feed \f + \u0020 space " " - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "White Space"; +var SECTION = "7.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "White Space"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); +new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); +new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); +new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); - array[item++] = new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); - array[item++] = new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); - array[item++] = new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.1-3.js b/mozilla/js/tests/ecma/LexicalConventions/7.1-3.js index 70c784ff94a..07825fcc96a 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.1-3.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,74 +35,53 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.1-3.js - ECMA Section: 7.1 White Space - Description: - readability - - separate tokens - - otherwise should be insignificant - - in strings, white space characters are significant - - cannot appear within any other kind of token + File Name: 7.1-3.js + ECMA Section: 7.1 White Space + Description: - readability + - separate tokens + - otherwise should be insignificant + - in strings, white space characters are significant + - cannot appear within any other kind of token - white space characters are: - unicode name formal name string representation - \u0009 tab \t - \u000B veritical tab ?? - \U000C form feed \f - \u0020 space " " + white space characters are: + unicode name formal name string representation + \u0009 tab \t + \u000B veritical tab ?? + \U000C form feed \f + \u0020 space " " - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "White Space"; +var SECTION = "7.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "White Space"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); +new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); +new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); +new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); +// ++ should be interpreted as the unary + operator twice, not as a post or prefix increment operator -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "'var'+'\u000B'+'MYVAR1=10;MYVAR1'", 10, eval('var'+'\u000B'+'MYVAR1=10;MYVAR1') ); - array[item++] = new TestCase( SECTION, "'var'+'\u0009'+'MYVAR2=10;MYVAR2'", 10, eval('var'+'\u0009'+'MYVAR2=10;MYVAR2') ); - array[item++] = new TestCase( SECTION, "'var'+'\u000C'+'MYVAR3=10;MYVAR3'", 10, eval('var'+'\u000C'+'MYVAR3=10;MYVAR3') ); - array[item++] = new TestCase( SECTION, "'var'+'\u0020'+'MYVAR4=10;MYVAR4'", 10, eval('var'+'\u0020'+'MYVAR4=10;MYVAR4') ); +new TestCase( SECTION, + "var VAR = 12345; + + VAR", + 12345, + eval("var VAR = 12345; + + VAR") ); - // ++ should be interpreted as the unary + operator twice, not as a post or prefix increment operator +new TestCase( SECTION, + "var VAR = 12345;VAR+ + VAR", + 24690, + eval("var VAR = 12345;VAR+ +VAR") ); +new TestCase( SECTION, + "var VAR = 12345;VAR - - VAR", + 24690, + eval("var VAR = 12345;VAR- -VAR") ); - array[item++] = new TestCase( SECTION, - "var VAR = 12345; + + VAR", - 12345, - eval("var VAR = 12345; + + VAR") ); - - array[item++] = new TestCase( SECTION, - "var VAR = 12345;VAR+ + VAR", - 24690, - eval("var VAR = 12345;VAR+ +VAR") ); - array[item++] = new TestCase( SECTION, - "var VAR = 12345;VAR - - VAR", - 24690, - eval("var VAR = 12345;VAR- -VAR") ); - - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.2-1.js b/mozilla/js/tests/ecma/LexicalConventions/7.2-1.js index 7d17abeed58..ba28c4493b6 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.2-1.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.2-1.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. + File Name: 7.2-1.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Line Terminators"; +var SECTION = "7.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var a\nb = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); +new TestCase( SECTION, "var a\nb = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); +new TestCase( SECTION, "var a\rb = 5; ab=10;ab;", 10, eval("var a\rb = 5; ab=10;ab") ); +new TestCase( SECTION, "var a\rb = 5; ab=10;b;", 5, eval("var a\rb = 5; ab=10;b") ); +new TestCase( SECTION, "var a\r\nb = 5; ab=10;ab;", 10, eval("var a\r\nb = 5; ab=10;ab") ); +new TestCase( SECTION, "var a\r\nb = 5; ab=10;b;", 5, eval("var a\r\nb = 5; ab=10;b") ); - array[item++] = new TestCase( SECTION, "var a\nb = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); - array[item++] = new TestCase( SECTION, "var a\nb = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); - array[item++] = new TestCase( SECTION, "var a\rb = 5; ab=10;ab;", 10, eval("var a\rb = 5; ab=10;ab") ); - array[item++] = new TestCase( SECTION, "var a\rb = 5; ab=10;b;", 5, eval("var a\rb = 5; ab=10;b") ); - array[item++] = new TestCase( SECTION, "var a\r\nb = 5; ab=10;ab;", 10, eval("var a\r\nb = 5; ab=10;ab") ); - array[item++] = new TestCase( SECTION, "var a\r\nb = 5; ab=10;b;", 5, eval("var a\r\nb = 5; ab=10;b") ); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.2-2-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.2-2-n.js index d284d77ea48..a318c0e2cac 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.2-2-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.2-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.2.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Line Terminators"; +var SECTION = "7.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "\r\r\r\nb"; +EXPECTED = "error" -function test() { - // this is line 29 - a = "\r\r\r\nb"; - eval( a ); +new TestCase( SECTION, DESCRIPTION, "error", eval("\r\r\r\nb")); - // if we get this far, the test failed. - testcases[tc].passed = writeTestCaseResult( - "failure on line" + testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +test(); - testcases[0].passed = false; - - testcases[tc].reason = "test should have caused runtime error "; - - stopTest(); - - return ( testcases ); -} - - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[0] = new TestCase( "7.2", "a", "error", ""); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.2-3-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.2-3-n.js index b2337d5c00d..fa559940ca4 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.2-3-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.2-3-n.js @@ -35,64 +35,36 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.2-3.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. + File Name: 7.2-3.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.2-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Line Terminators"; +var SECTION = "7.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function test() { - - // this is line 27 - - a = "\r\nb"; - eval( a ); - - // if we get this far, the test failed. - testcases[tc].passed = writeTestCaseResult( - "failure on line" + testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[0].passed = false; - - testcases[tc].reason = "test should have caused runtime error "; - - stopTest(); - return ( testcases ); -} +writeHeaderToLog( SECTION + " "+ TITLE); +DESCRIPTION = "\r\nb"; +EXPECTED = "error" -function getTestCases() { - var array = new Array(); - var item = 0; - - array[0] = new TestCase( "7.2", "a", "error", ""); - - return ( array ); -} +new TestCase( SECTION, "a", "error", eval("\r\nb")); +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.2-4-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.2-4-n.js index 8967ff4761f..7bd8772ff85 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.2-4-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.2-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,64 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.2.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.2-6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Line Terminators"; +var SECTION = "7.2-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "\nb"; +EXPECTED = "error"; -function test() { - // this is line 33 +new TestCase( SECTION, "\nb", "error", eval("\nb")); - a = "\nb"; - eval( a ); - - // if we get this far, the test failed. - testcases[tc].passed = writeTestCaseResult( - "failure on line" + testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[0].passed = false; - - testcases[tc].reason = "test should have caused runtime error "; - - stopTest(); - - return ( testcases ); -} - - - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[0] = new TestCase( "7.2", "a = \\nb", "error", ""); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.2-5-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.2-5-n.js index a9fe62a61c4..67ef820349d 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.2-5-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.2-5-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,67 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.2.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. + File Name: 7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.2-5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Line Terminators"; +var SECTION = "7.2-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = +EXPECTED = "error"; - -function test() { - // this is line 27 - - a = "\rb"; - eval( a ); - - // if we get this far, the test failed. - testcases[tc].passed = writeTestCaseResult( - "failure on line" + testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].passed = false; - - testcases[tc].reason = "test should have caused runtime error "; - - passed = false; - stopTest(); - - // all tests must return a boolean value - return ( testcases ); -} - - - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[0] = new TestCase( "7.2", "a", "error", ""); - - return ( array ); -} +new TestCase( SECTION, "\rb", "error", eval("\rb")); +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.2-6.js b/mozilla/js/tests/ecma/LexicalConventions/7.2-6.js index c2bc0fcc31a..314acaa73f2 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.2-6.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.2-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,32 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.2-6.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. + File Name: 7.2-6.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.2-6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Line Terminators"; +var SECTION = "7.2-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Line Terminators"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "var a\u000Ab = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); +new TestCase( SECTION, "var a\u000Db = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "var a\u000Ab = 5; ab=10;ab;", 10, eval("var a\nb = 5; ab=10;ab") ); - array[item++] = new TestCase( SECTION, "var a\u000Db = 5; ab=10;b;", 5, eval("var a\nb = 5; ab=10;b") ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-1.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-1.js index acce31f59d4..2dfe6f0dc06 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-1.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-1.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-1.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +var testcase; - test(); +testcase = new TestCase( SECTION, + "a comment with a line terminator string, and text following", + "pass", + "pass"); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item] = new TestCase( SECTION, - "a comment with a line terminator string, and text following", - "pass", - "pass"); +// "\u000A" testcase.actual = "fail"; - // "\u000A" array[item].actual = "fail"; - item++; +testcase = new TestCase( SECTION, + "// test \\n testcase.actual = \"pass\"", + "pass", + "" ); - array[item] = new TestCase( SECTION, - "// test \\n array[item].actual = \"pass\"", - "pass", - "" ); +var x = "// test \n testcase.actual = 'pass'" - var x = "// test \n array[item].actual = 'pass'" +testcase.actual = eval(x); - array[0].actual = eval(x); - - return ( array ); -} +test(); +// XXX bc replace test() function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +": "+ + testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; + } + stopTest(); + return ( testcases ); } diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-10.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-10.js index 0a2b92e3abb..ef7d9efe0c6 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-10.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-10.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-10.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-10.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); +/*//*/testcase.actual="pass"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "code following multiline comment", - "pass", - "fail"); - return ( array ); -} -function test() { - - /*//*/testcases[tc].actual="pass"; - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-11.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-11.js index c3320df5311..10f0b3066d7 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-11.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-11.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-11.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-11.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "code following multiline comment", - "pass", - "pass"); - return ( array ); -} -function test() { +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "pass"); - ////testcases[tc].actual="fail"; +////testcase.actual="fail"; - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-12.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-12.js index 0d9c619c494..8b39207f347 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-12.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-12.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-12.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-12.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "pass"); +/*testcase.actual="fail";**/ -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "code following multiline comment", - "pass", - "pass"); - return ( array ); -} -function test() { - - /*testcases[tc].actual="fail";**/ - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-13-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-13-n.js index 36e1430582a..9985499afc3 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-13-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-13-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-13-n.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-13-n.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-13-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-13-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "nested comment"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "nested comment", - "error", - "pass"); - return ( array ); -} -function test() { +var testcase = new TestCase( SECTION, + "nested comment", + "error", + eval("/*/*\"fail\";*/*/")); - /*/*testcases[tc].actual="fail";*/*/ - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-2.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-2.js index c82f219e92b..f33ab3c42c3 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-2.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-2.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-2.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "a comment with a carriage return, and text following", + "pass", + "pass"); +// "\u000D" testcase.actual = "fail"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "a comment with a carriage return, and text following", - "pass", - "pass"); - return ( array ); -} -function test() { - - // "\u000D" testcases[tc].actual = "fail"; - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-3.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-3.js index 4bf1f218fa8..e5459d0827a 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-3.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-3.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-3.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "source text directly following a single-line comment", + "pass", + "fail"); +// a comment string +testcase.actual = "pass"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "source text directly following a single-line comment", - "pass", - "fail"); - return ( array ); -} -function test() { - - // a comment string - testcases[tc].actual = "pass"; - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-4.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-4.js index 9ff4478695f..1b459f4ce6e 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-4.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-4.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-4.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "multiline comment ", + "pass", + "pass"); +/*testcase.actual = "fail";*/ -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "multiline comment ", - "pass", - "pass"); - return ( array ); -} -function test() { - - /*testcases[tc].actual = "fail";*/ - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-5.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-5.js index d09c4883072..eb16d8fb337 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-5.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-5.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-5.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "a comment with a carriage return, and text following", + "pass", + "pass"); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "a comment with a carriage return, and text following", - "pass", - "pass"); - return ( array ); -} -function test() { +// "\u000A" testcase.actual = "fail"; - // "\u000A" testcases[tc].actual = "fail"; - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-6.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-6.js index 0087a24a15b..302e26f0952 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-6.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-6.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-6.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); +var testcase = new TestCase( SECTION, + "comment with multiple asterisks", + "pass", + "fail"); - var testcases = getTestCases(); - test(); +/* +***/testcase.actual="pass"; - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "comment with multiple asterisks", - "pass", - "fail"); - return ( array ); -} -function test() { - - /* - ***/testcases[tc].actual="pass"; - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-7.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-7.js index 31fc332c1e1..b9aa637d42b 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-7.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-7.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-7.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-7"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "single line comment following multiline comment", + "pass", + "pass"); +/* +***///testcase.actual="fail"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "single line comment following multiline comment", - "pass", - "pass"); - return ( array ); -} -function test() { - - /* - ***///testcases[tc].actual="fail"; - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-8.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-8.js index 64ecd4a1b4d..d1b7cc5192a 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-8.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-7.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-7.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-8"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); +/**/testcase.actual="pass"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "code following multiline comment", - "pass", - "fail"); - return ( array ); -} -function test() { - - /**/testcases[tc].actual="pass"; - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.3-9.js b/mozilla/js/tests/ecma/LexicalConventions/7.3-9.js index c2fc3e272ec..413c2e106e0 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.3-9.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.3-9.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.3-9.js - ECMA Section: 7.3 Comments - Description: + File Name: 7.3-9.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.3-9"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Comments"; +var SECTION = "7.3-9"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Comments"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var testcase = new TestCase( SECTION, + "code following multiline comment", + "pass", + "fail"); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "code following multiline comment", - "pass", - "fail"); - return ( array ); -} -function test() { +/*/*/testcase.actual="pass"; - /*/*/testcases[tc].actual="pass"; - - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.1-1-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.1-1-n.js index c3ea25f9219..a249f60b56e 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.1-1-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.1-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.1-1-n.js - ECMA Section: 7.4.1 + File Name: 7.4.1-1-n.js + ECMA Section: 7.4.1 - Description: + Description: - Reserved words cannot be used as identifiers. + Reserved words cannot be used as identifiers. - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-1-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var null = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var null = true", "error", eval("var null = true") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var null = true", "error", "var null = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.1-2-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.1-2-n.js index f635f5c6640..eb872686eba 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.1-2-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.1-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.1-2.js - ECMA Section: 7.4.1 + File Name: 7.4.1-2.js + ECMA Section: 7.4.1 - Description: + Description: - Reserved words cannot be used as identifiers. + Reserved words cannot be used as identifiers. - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-2-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var true = false"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var true = false", "error", "var true = false" ); - return ( array ); -} +new TestCase( SECTION, "var true = false", "error", eval("var true = false") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.1-3-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.1-3-n.js index 6fadb7de080..ddf75071794 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.1-3-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.1-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 7.4.1-3-n.js ECMA Section: 7.4.1 @@ -57,29 +59,9 @@ startTest(); var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +DESCRIPTION = "var false = true"; +EXPECTED = "error"; - var testcases = getTestCases(); - test(); + new TestCase( SECTION, "var false = true", "error", eval("var false = true") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var false = true", "error", "var false = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-1-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-1-n.js index 414920d2f85..98ca168cf02 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-1-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-1.js - ECMA Section: 7.4.2 + File Name: 7.4.2-1.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.2-1-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.2-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var break = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var break = true", "error", "var break = true" ); - return ( array ); -} +new TestCase( SECTION, "var break = true", "error", eval("var break = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-10-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-10-n.js index cb43ad75cd3..e35ae715363 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-10-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-10-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-10.js - ECMA Section: 7.4.2 + File Name: 7.4.2-10.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-10-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-10-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var if = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var if = true", "error", "var if = true" ); - return ( array ); -} +new TestCase( SECTION, "var if = true", "error", eval("var if = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-11-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-11-n.js index a9d1ae4eef8..a9506d7ef9a 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-11-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-11-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-11-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-11-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-11-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-11-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var this = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var this = true", "error", "var this = true" ); - return ( array ); -} +new TestCase( SECTION, "var this = true", "error", eval("var this = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-12-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-12-n.js index fecf33fa9f8..26862d9cc77 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-12-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-12-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,59 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-12-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-12-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-12-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-12-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var while = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var while = true", "error", eval("var while = true") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var while = true", "error", "var while = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-13-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-13-n.js index d41d0a05886..22fefa46f95 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-13-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-13-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-13-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-13-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-13-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-13-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var else = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var else = true", "error", "var else = true" ); - return ( array ); -} +new TestCase( SECTION, "var else = true", "error", eval("var else = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-14-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-14-n.js index da10c5a8193..cd5e7dfa44a 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-14-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-14-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-14-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-14-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-14-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-14-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var in = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var in = true", "error", "var in = true" ); - return ( array ); -} +new TestCase( SECTION, "var in = true", "error", eval("var in = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-15-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-15-n.js index 4e0584bb25e..0899e088d87 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-15-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-15-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,59 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-15-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-15-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-15-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-15-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - test(); +DESCRIPTION = "var typeof = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var typeof = true", "error", "var typeof = true" ); - return ( array ); -} +new TestCase( SECTION, "var typeof = true", "error", eval("var typeof = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-16-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-16-n.js index 0284f3e4df2..5a102c6e985 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-16-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-16-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-16-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-16-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-16-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-16-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var with = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var with = true", "error", "var with = true" ); - return ( array ); -} +new TestCase( SECTION, "var with = true", "error", eval("var with = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-2-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-2-n.js index e3df20bb6eb..86f30ac14b8 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-2-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-2-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-2-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-2-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var for = true", "error", "var for = true" ); - return ( array ); -} +DESCRIPTION = "var for = true"; +EXPECTED = "error"; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "var for = true", "error", eval("var for = true") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-3-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-3-n.js index 44637d1fecc..321dae68aee 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-3-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-3-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-3-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.2-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.2-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var new = true", "error", "var new = true" ); - return ( array ); -} +DESCRIPTION = "var new = true"; +EXPECTED = "error"; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "var new = true", "error", eval("var new = true") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-4-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-4-n.js index 56983aaf389..c336de8b7c0 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-4-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-4-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-4-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.2-4-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.2-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var var = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var var = true", "error", "var var = true" ); - return ( array ); -} +TestCase( SECTION, "var var = true", "error", eval("var var = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-5-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-5-n.js index 40db3205fa5..ccfdbcc5ac1 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-5-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-5-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-5-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-5-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.2-5-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.2-5-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var continue = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var continue = true", "error", "var continue = true" ); - return ( array ); -} +new TestCase( SECTION, "var continue = true", "error", eval("var continue = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-6-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-6-n.js index 3c05b6d6ab7..87c5faea86f 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-6-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-6-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-6.js - ECMA Section: 7.4.2 + File Name: 7.4.2-6.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.2-6-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.2-6-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var function = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var function = true", "error", "var function = true" ); - return ( array ); -} +new TestCase( SECTION, "var function = true", "error", eval("var function = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-7-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-7-n.js index 1ffb24c3177..6bf4d2c547e 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-7-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-7-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,55 +35,39 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-7-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-7-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.2-7"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); - writeHeaderToLog( SECTION + " Keywords"); - test(); +var SECTION = "7.4.2-7"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Keywords"); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var return = true", "error", "var return = true" ); - return ( array ); -} +DESCRIPTION = "var return = true"; +EXPECTED = "error"; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "var return = true", "error", eval("var return = true") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-8-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-8-n.js index 97ac520a97d..ca57de785c8 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-8-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-8-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 7.4.2-8-n.js ECMA Section: 7.4.2 @@ -61,28 +63,12 @@ var SECTION = "7.4.2-8"; var VERSION = "ECMA_1"; startTest(); - var testcases = getTestCases(); + writeHeaderToLog( SECTION + " Keywords"); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var void = true", "error", "var void = true" ); - return ( array ); -} +DESCRIPTION = "var void = true"; +EXPECTED = "error"; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "var void = true", "error", eval("var void = true") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-9-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-9-n.js index 882de2d0b49..ce561f12d11 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.2-9-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.2-9-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.2-9-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-9-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.1-9-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Keywords"; +var SECTION = "7.4.1-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Keywords"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var delete = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var delete = true", "error", "var delete = true" ); - return ( array ); -} +new TestCase( SECTION, "var delete = true", "error", eval("var delete = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-1-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-1-n.js index 3d00e0cf735..8c89c38a6f3 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-1-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-1-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-1-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-1-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var case = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var case = true", "error", eval("var case = true") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var case = true", "error", "var case = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-10-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-10-n.js index abd13eeff01..b87bce7293a 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-10-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-10-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-10-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-10-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-10-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-10-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var do = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var do = true", "error", eval("var do = true") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var do = true", "error", "var do = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-11-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-11-n.js index a965f554780..0f0b92fd4be 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-11-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-11-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-11-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-11-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-11-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-11-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var finally = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var finally = true", "error", "var finally = true" ); - return ( array ); -} +new TestCase( SECTION, "var finally = true", "error", eval("var finally = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-12-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-12-n.js index 1f63fb15d0e..b213cc5b3cc 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-12-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-12-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-12-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-12-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-12-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-12-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var throw = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var throw = true", "error", eval("var throw = true") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var throw = true", "error", "var throw = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-13-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-13-n.js index a7057af12e8..bbc53908174 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-13-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-13-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-13-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-13-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-13-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-13-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var const = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var const = true", "error", eval("var const = true") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var const = true", "error", "var const = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-14-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-14-n.js index 976c69cf27c..092bd5663a7 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-14-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-14-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,51 +36,32 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.4.3-14-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-14-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-14-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-14-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var enum = true", "error", "var enum = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "var enum = true", + "error", + eval("var enum = true") ); +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-15-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-15-n.js index 1dc50ac7c0a..1aa58fecc79 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-15-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-15-n.js @@ -1,4 +1,5 @@ -/* ***** BEGIN LICENSE BLOCK ***** +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ + ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version @@ -34,54 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-15-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-15-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-15-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-15-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var import = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var import = true", "error", eval("var import = true") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var import = true", "error", "var import = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-16-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-16-n.js index 87371491c1d..9e255e8b1ee 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-16-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-16-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,51 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: lexical-023.js - Corresponds To: 7.4.3-16-n.js - ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + File Name: lexical-023.js + Corresponds To: 7.4.3-16-n.js + ECMA Section: 7.4.3 + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-023.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-023.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; +/* + try { + try = true; + } catch ( e ) { + result = expect; + exception = e.toString(); + } +*/ - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; - - try { - try = true; - } catch ( e ) { - result = expect; - exception = e.toString(); - } - - testcases[tc++] = new TestCase( - SECTION, - "try = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +DESCRIPTION = "try = true"; +EXPECTED = "error"; +new TestCase( + SECTION, + "try = true" + + " (threw " + exception +")", + "error", + eval("try = true") ); +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-2-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-2-n.js index 8e1e4414df5..e1b9d5fed07 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-2-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-2-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-2-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-2-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var debugger = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var debugger = true", "error", eval("var debugger = true") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var debugger = true", "error", "var debugger = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-3-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-3-n.js index 5158a4aecbd..076d3ea550b 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-3-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-3-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-3-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var export = true"; +EXPECTED = "error"; +new TestCase( SECTION, "var export = true", "error", eval("var export = true") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var export = true", "error", "var export = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-4-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-4-n.js index 52a15da320a..462b9d7bf84 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-4-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,53 +36,32 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.4.3-4-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-4-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-4-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - - - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var super = true", "error", "var super = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "var super = true", + "error", + eval("var super = true") ); +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-5-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-5-n.js index db0cfbf8ca6..b9f63f06227 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-5-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-5-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-5-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-5-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-5-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-5-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "var catch = true"; +EXPECTED = "error"; - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "var catch = true", "error", eval("var catch = true") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var catch = true", "error", "var catch = true" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-6-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-6-n.js index 154236181c1..1695142787a 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-6-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-6-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-6-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-6-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-6-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-6-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var default = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var default = true", "error", "var default = true" ); - return ( array ); -} +new TestCase( SECTION, "var default = true", "error", eval("var default = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-7-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-7-n.js index cecf2e1a391..189b7d76173 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-7-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-7-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,51 +36,35 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.4.3-7-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-7-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-7-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-7-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var extends = true", "error", "var extends = true" ); - return ( array ); -} +new TestCase( SECTION, + "var extends = true", + "error", + eval("var extends = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-8-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-8-n.js index 5868746f4ab..9ddb672fefc 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-8-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-8-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.4.3-8-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-8-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-9-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var switch = true"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var switch = true", "error", "var switch = true" ); - return ( array ); -} +new TestCase( SECTION, "var switch = true", "error", eval("var switch = true") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-9-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-9-n.js index 87090b10455..5faca192758 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.4.3-9-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.4.3-9-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,51 +36,34 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.4.3-9-n.js - ECMA Section: 7.4.3 + File Name: 7.4.3-9-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.4.3-9-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Future Reserved Words"; +var SECTION = "7.4.3-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Future Reserved Words"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "var class = true", + "error", + eval("var class = true") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var class = true", "error", "var class = true" ); - return ( array ); -} +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-1.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-1.js index b444f0aa651..e385fee5d76 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-1.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,26 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-1.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-1.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "var $123 = 5", 5, eval("var $123 = 5;$123") ); +new TestCase( SECTION, "var _123 = 5", 5, eval("var _123 = 5;_123") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "var $123 = 5", 5, eval("var $123 = 5;$123") ); - array[item++] = new TestCase( SECTION, "var _123 = 5", 5, eval("var _123 = 5;_123") ); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-10-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-10-n.js index cdeb90f5578..185f12e97c0 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-10-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-10-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-9-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-9-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var 123=\"hi\""; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var 123=\"hi\"", "error", eval("123 = \"hi\"; array[item] = 123;") ); - array[item] = new TestCase( SECTION, "var 123=\"hi\"", "error", "" ); - - 123 = "hi"; - - array[item] = 123; - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-2-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-2-n.js index b7e8339cf73..811734a6930 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-2-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-2-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-2-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-2-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var 0abc"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var 0abc", "error", eval("var 0abc") ); - array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 0abc" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-3-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-3-n.js index 1ca79d7b997..ed441bfa583 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-3-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-2.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-2.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var 1abc"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var 1abc", "error", eval("var 1abc") ); - array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 1abc" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-4-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-4-n.js index f07f8b84f89..98886b086eb 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-4-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-4-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-4-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-4-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-4-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-4-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var 2abc"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var 2abc", "error", eval("var 2abc") ); - array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 2abc" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-5-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-5-n.js index d717933f9f5..ce1ef7d0997 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-5-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-5-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-5-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-5-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-5-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-5-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var 3abc"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var 3abc", "error", eval("var 3abc") ); - array[item++] = new TestCase( SECTION, "var 0abc", "error", "var 3abc" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-6.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-6.js index c3b81a16a4c..511dadd28da 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-6.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,25 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-6.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-6.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "var _0abc = 5", 5, eval("var _0abc = 5; _0abc") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "var _0abc = 5", 5, "var _0abc = 5; _0abc" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-7.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-7.js index e39ee721102..5e6eab4a56a 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-7.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,25 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-7.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-7.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-7"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "var $0abc = 5", 5, eval("var $0abc = 5; $0abc") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "var $0abc = 5", 5, "var $0abc = 5; $0abc" ); - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-8-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-8-n.js index 66d749192b3..78d7a630644 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-8-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-8-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.5-8-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: 7.5-8-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "7.5-8-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Identifiers"; +var SECTION = "7.5-8-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Identifiers"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var @0abc = 5; @0abc"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var @0abc = 5; @0abc", "error", eval("var @0abc = 5; @0abc") ); - array[item++] = new TestCase( SECTION, "var @0abc = 5", "error", "var @0abc = 5; @0abc" ); - return ( array ); -} - -function test() {s - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.5-9-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.5-9-n.js index 9fa1b067753..719b48cfd99 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.5-9-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.5-9-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 7.5-9-n.js ECMA Section: 7.5 Identifiers @@ -52,34 +54,9 @@ writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var 123=\"hi\""; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var 123=\"hi\"", "error", eval("var 123 = \"hi\";array[item] = 123;") ); - array[item] = new TestCase( SECTION, "var 123=\"hi\"", "error", "" ); - - var 123 = "hi"; - - array[item] = 123; - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +": "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : " ignored chars after line terminator of single-line comment"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.6.js b/mozilla/js/tests/ecma/LexicalConventions/7.6.js index 5ebaaf2c8fb..d19445a6fba 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.6.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,290 +36,275 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.6.js - ECMA Section: Punctuators - Description: + File Name: 7.6.js + ECMA Section: Punctuators + Description: - This tests verifies that all ECMA punctutors are recognized as a - token separator, but does not attempt to verify the functionality - of any punctuator. + This tests verifies that all ECMA punctutors are recognized as a + token separator, but does not attempt to verify the functionality + of any punctuator. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "7.6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Punctuators"; +var SECTION = "7.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Punctuators"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// == +new TestCase( SECTION, + "var c,d;c==d", + true, + eval("var c,d;c==d") ); - // == - testcases[tc++] = new TestCase( SECTION, - "var c,d;c==d", - true, - eval("var c,d;c==d") ); +// = - // = +new TestCase( SECTION, + "var a=true;a", + true, + eval("var a=true;a") ); - testcases[tc++] = new TestCase( SECTION, - "var a=true;a", - true, - eval("var a=true;a") ); +// > +new TestCase( SECTION, + "var a=true,b=false;a>b", + true, + eval("var a=true,b=false;a>b") ); - // > - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=false;a>b", - true, - eval("var a=true,b=false;a>b") ); +// < +new TestCase( SECTION, + "var a=true,b=false;a= +new TestCase( SECTION, + "var a=0xFFFF,b=0XFFFE;a>=b", + true, + eval("var a=0xFFFF,b=0XFFFE;a>=b") ); - // >= - testcases[tc++] = new TestCase( SECTION, - "var a=0xFFFF,b=0XFFFE;a>=b", - true, - eval("var a=0xFFFF,b=0XFFFE;a>=b") ); +// != +new TestCase( SECTION, + "var a=true,b=false;a!=b", + true, + eval("var a=true,b=false;a!=b") ); - // != - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=false;a!=b", - true, - eval("var a=true,b=false;a!=b") ); +new TestCase( SECTION, + "var a=false,b=false;a!=b", + false, + eval("var a=false,b=false;a!=b") ); +// , +new TestCase( SECTION, + "var a=true,b=false;a,b", + false, + eval("var a=true,b=false;a,b") ); +// ! +new TestCase( SECTION, + "var a=true,b=false;!a", + false, + eval("var a=true,b=false;!a") ); - testcases[tc++] = new TestCase( SECTION, - "var a=false,b=false;a!=b", - false, - eval("var a=false,b=false;a!=b") ); - // , - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=false;a,b", - false, - eval("var a=true,b=false;a,b") ); - // ! - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=false;!a", - false, - eval("var a=true,b=false;!a") ); +// ~ +new TestCase( SECTION, + "var a=true;~a", + -2, + eval("var a=true;~a") ); +// ? +new TestCase( SECTION, + "var a=true; (a ? 'PASS' : '')", + "PASS", + eval("var a=true; (a ? 'PASS' : '')") ); - // ~ - testcases[tc++] = new TestCase( SECTION, - "var a=true;~a", - -2, - eval("var a=true;~a") ); - // ? - testcases[tc++] = new TestCase( SECTION, - "var a=true; (a ? 'PASS' : '')", - "PASS", - eval("var a=true; (a ? 'PASS' : '')") ); +// : - // : +new TestCase( SECTION, + "var a=false; (a ? 'FAIL' : 'PASS')", + "PASS", + eval("var a=false; (a ? 'FAIL' : 'PASS')") ); +// . - testcases[tc++] = new TestCase( SECTION, - "var a=false; (a ? 'FAIL' : 'PASS')", - "PASS", - eval("var a=false; (a ? 'FAIL' : 'PASS')") ); - // . +new TestCase( SECTION, + "var a=Number;a.NaN", + NaN, + eval("var a=Number;a.NaN") ); - testcases[tc++] = new TestCase( SECTION, - "var a=Number;a.NaN", - NaN, - eval("var a=Number;a.NaN") ); +// && +new TestCase( SECTION, + "var a=true,b=true;if(a&&b)'PASS';else'FAIL'", + "PASS", + eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") ); - // && - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=true;if(a&&b)'PASS';else'FAIL'", - "PASS", - eval("var a=true,b=true;if(a&&b)'PASS';else'FAIL'") ); +// || +new TestCase( SECTION, + "var a=false,b=false;if(a||b)'FAIL';else'PASS'", + "PASS", + eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") ); +// ++ +new TestCase( SECTION, + "var a=false,b=false;++a", + 1, + eval("var a=false,b=false;++a") ); +// -- +new TestCase( SECTION, + "var a=true,b=false--a", + 0, + eval("var a=true,b=false;--a") ); +// + - // || - testcases[tc++] = new TestCase( SECTION, - "var a=false,b=false;if(a||b)'FAIL';else'PASS'", - "PASS", - eval("var a=false,b=false;if(a||b)'FAIL';else'PASS'") ); - // ++ - testcases[tc++] = new TestCase( SECTION, - "var a=false,b=false;++a", - 1, - eval("var a=false,b=false;++a") ); - // -- - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=false--a", - 0, - eval("var a=true,b=false;--a") ); - // + +new TestCase( SECTION, + "var a=true,b=true;a+b", + 2, + eval("var a=true,b=true;a+b") ); +// - +new TestCase( SECTION, + "var a=true,b=true;a-b", + 0, + eval("var a=true,b=true;a-b") ); +// * +new TestCase( SECTION, + "var a=true,b=true;a*b", + 1, + eval("var a=true,b=true;a*b") ); +// / +new TestCase( SECTION, + "var a=true,b=true;a/b", + 1, + eval("var a=true,b=true;a/b") ); +// & +new TestCase( SECTION, + "var a=3,b=2;a&b", + 2, + eval("var a=3,b=2;a&b") ); +// | +new TestCase( SECTION, + "var a=4,b=3;a|b", + 7, + eval("var a=4,b=3;a|b") ); - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=true;a+b", - 2, - eval("var a=true,b=true;a+b") ); - // - - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=true;a-b", - 0, - eval("var a=true,b=true;a-b") ); - // * - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=true;a*b", - 1, - eval("var a=true,b=true;a*b") ); - // / - testcases[tc++] = new TestCase( SECTION, - "var a=true,b=true;a/b", - 1, - eval("var a=true,b=true;a/b") ); - // & - testcases[tc++] = new TestCase( SECTION, - "var a=3,b=2;a&b", - 2, - eval("var a=3,b=2;a&b") ); - // | - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;a|b", - 7, - eval("var a=4,b=3;a|b") ); +// | +new TestCase( SECTION, + "var a=4,b=3;a^b", + 7, + eval("var a=4,b=3;a^b") ); - // | - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;a^b", - 7, - eval("var a=4,b=3;a^b") ); +// % +new TestCase( SECTION, + "var a=4,b=3;a|b", + 1, + eval("var a=4,b=3;a%b") ); - // % - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;a|b", - 1, - eval("var a=4,b=3;a%b") ); +// << +new TestCase( SECTION, + "var a=4,b=3;a<> +new TestCase( SECTION, + "var a=4,b=1;a>>b", + 2, + eval("var a=4,b=1;a>>b") ); - // >> - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=1;a>>b", - 2, - eval("var a=4,b=1;a>>b") ); +// >>> +new TestCase( SECTION, + "var a=1,b=1;a>>>b", + 0, + eval("var a=1,b=1;a>>>b") ); +// += +new TestCase( SECTION, + "var a=4,b=3;a+=b;a", + 7, + eval("var a=4,b=3;a+=b;a") ); - // >>> - testcases[tc++] = new TestCase( SECTION, - "var a=1,b=1;a>>>b", - 0, - eval("var a=1,b=1;a>>>b") ); - // += - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;a+=b;a", - 7, - eval("var a=4,b=3;a+=b;a") ); +// -= +new TestCase( SECTION, + "var a=4,b=3;a-=b;a", + 1, + eval("var a=4,b=3;a-=b;a") ); +// *= +new TestCase( SECTION, + "var a=4,b=3;a*=b;a", + 12, + eval("var a=4,b=3;a*=b;a") ); +// += +new TestCase( SECTION, + "var a=4,b=3;a+=b;a", + 7, + eval("var a=4,b=3;a+=b;a") ); +// /= +new TestCase( SECTION, + "var a=12,b=3;a/=b;a", + 4, + eval("var a=12,b=3;a/=b;a") ); - // -= - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;a-=b;a", - 1, - eval("var a=4,b=3;a-=b;a") ); - // *= - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;a*=b;a", - 12, - eval("var a=4,b=3;a*=b;a") ); - // += - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;a+=b;a", - 7, - eval("var a=4,b=3;a+=b;a") ); - // /= - testcases[tc++] = new TestCase( SECTION, - "var a=12,b=3;a/=b;a", - 4, - eval("var a=12,b=3;a/=b;a") ); +// &= +new TestCase( SECTION, + "var a=4,b=5;a&=b;a", + 4, + eval("var a=4,b=5;a&=b;a") ); - // &= - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=5;a&=b;a", - 4, - eval("var a=4,b=5;a&=b;a") ); +// |= +new TestCase( SECTION, + "var a=4,b=5;a&=b;a", + 5, + eval("var a=4,b=5;a|=b;a") ); +// ^= +new TestCase( SECTION, + "var a=4,b=5;a^=b;a", + 1, + eval("var a=4,b=5;a^=b;a") ); +// %= +new TestCase( SECTION, + "var a=12,b=5;a%=b;a", + 2, + eval("var a=12,b=5;a%=b;a") ); +// <<= +new TestCase( SECTION, + "var a=4,b=3;a<<=b;a", + 32, + eval("var a=4,b=3;a<<=b;a") ); - // |= - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=5;a&=b;a", - 5, - eval("var a=4,b=5;a|=b;a") ); - // ^= - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=5;a^=b;a", - 1, - eval("var a=4,b=5;a^=b;a") ); - // %= - testcases[tc++] = new TestCase( SECTION, - "var a=12,b=5;a%=b;a", - 2, - eval("var a=12,b=5;a%=b;a") ); - // <<= - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;a<<=b;a", - 32, - eval("var a=4,b=3;a<<=b;a") ); +// >> +new TestCase( SECTION, + "var a=4,b=1;a>>=b;a", + 2, + eval("var a=4,b=1;a>>=b;a") ); - // >> - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=1;a>>=b;a", - 2, - eval("var a=4,b=1;a>>=b;a") ); +// >>> +new TestCase( SECTION, + "var a=1,b=1;a>>>=b;a", + 0, + eval("var a=1,b=1;a>>>=b;a") ); - // >>> - testcases[tc++] = new TestCase( SECTION, - "var a=1,b=1;a>>>=b;a", - 0, - eval("var a=1,b=1;a>>>=b;a") ); +// () +new TestCase( SECTION, + "var a=4,b=3;(a)", + 4, + eval("var a=4,b=3;(a)") ); +// {} +new TestCase( SECTION, + "var a=4,b=3;{b}", + 3, + eval("var a=4,b=3;{b}") ); - // () - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;(a)", - 4, - eval("var a=4,b=3;(a)") ); - // {} - testcases[tc++] = new TestCase( SECTION, - "var a=4,b=3;{b}", - 3, - eval("var a=4,b=3;{b}") ); +// [] +new TestCase( SECTION, + "var a=new Array('hi');a[0]", + "hi", + eval("var a=new Array('hi');a[0]") ); +// [] +new TestCase( SECTION, + ";", + void 0, + eval(";") ); +test(); - // [] - testcases[tc++] = new TestCase( SECTION, - "var a=new Array('hi');a[0]", - "hi", - eval("var a=new Array('hi');a[0]") ); - // [] - testcases[tc++] = new TestCase( SECTION, - ";", - void 0, - eval(";") ); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.7.1.js b/mozilla/js/tests/ecma/LexicalConventions/7.7.1.js index 81b5134dbde..cf17a8393d4 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.7.1.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.7.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.7.1.js - ECMA Section: 7.7.1 Null Literals + File Name: 7.7.1.js + ECMA Section: 7.7.1 Null Literals - Description: NullLiteral:: - null + Description: NullLiteral:: + null - The value of the null literal null is the sole value - of the Null type, namely null. + The value of the null literal null is the sole value + of the Null type, namely null. - Author: christine@netscape.com - Date: 21 october 1997 + Author: christine@netscape.com + Date: 21 october 1997 */ - var SECTION = "7.7.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Null Literals"; +var SECTION = "7.7.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Null Literals"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "null", null, null); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "null", null, null); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = testcases[tc].actual; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - - stopTest(); - - // all tests must return the test array - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.7.2.js b/mozilla/js/tests/ecma/LexicalConventions/7.7.2.js index 196c291e344..c24951e0996 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.7.2.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.7.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.7.2.js - ECMA Section: 7.7.2 Boolean Literals + File Name: 7.7.2.js + ECMA Section: 7.7.2 Boolean Literals - Description: BooleanLiteral:: - true - false + Description: BooleanLiteral:: + true + false - The value of the Boolean literal true is a value of the - Boolean type, namely true. + The value of the Boolean literal true is a value of the + Boolean type, namely true. - The value of the Boolean literal false is a value of the - Boolean type, namely false. + The value of the Boolean literal false is a value of the + Boolean type, namely false. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "7.7.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Boolean Literals"; +var SECTION = "7.7.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Boolean Literals"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// StringLiteral:: "" and '' -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "true", Boolean(true), true ); +new TestCase( SECTION, "false", Boolean(false), false ); - // StringLiteral:: "" and '' - - array[item++] = new TestCase( SECTION, "true", Boolean(true), true ); - array[item++] = new TestCase( SECTION, "false", Boolean(false), false ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = testcases[tc].actual; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - - stopTest(); - } - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.7.3-1.js b/mozilla/js/tests/ecma/LexicalConventions/7.7.3-1.js index 8f3772b3137..66521abff35 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.7.3-1.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.7.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,179 +35,161 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.7.3-1.js - ECMA Section: 7.7.3 Numeric Literals + File Name: 7.7.3-1.js + ECMA Section: 7.7.3 Numeric Literals - Description: A numeric literal stands for a value of the Number type - This value is determined in two steps: first a - mathematical value (MV) is derived from the literal; - second, this mathematical value is rounded, ideally - using IEEE 754 round-to-nearest mode, to a reprentable - value of of the number type. + Description: A numeric literal stands for a value of the Number type + This value is determined in two steps: first a + mathematical value (MV) is derived from the literal; + second, this mathematical value is rounded, ideally + using IEEE 754 round-to-nearest mode, to a reprentable + value of of the number type. - These test cases came from Waldemar. + These test cases came from Waldemar. - Author: christine@netscape.com - Date: 12 June 1998 + Author: christine@netscape.com + Date: 12 June 1998 */ var SECTION = "7.7.3-1"; var VERSION = "ECMA_1"; - startTest(); +startTest(); var TITLE = "Numeric Literals"; var BUGNUMBER="122877"; writeHeaderToLog( SECTION + " "+ TITLE); -var testcases = new Array(); +new TestCase( SECTION, + "0x12345678", + 305419896, + 0x12345678 ); +new TestCase( SECTION, + "0x80000000", + 2147483648, + 0x80000000 ); -testcases[tc++] = new TestCase( SECTION, - "0x12345678", - 305419896, - 0x12345678 ); +new TestCase( SECTION, + "0xffffffff", + 4294967295, + 0xffffffff ); -testcases[tc++] = new TestCase( SECTION, - "0x80000000", - 2147483648, - 0x80000000 ); +new TestCase( SECTION, + "0x100000000", + 4294967296, + 0x100000000 ); -testcases[tc++] = new TestCase( SECTION, - "0xffffffff", - 4294967295, - 0xffffffff ); +new TestCase( SECTION, + "077777777777777777", + 2251799813685247, + 077777777777777777 ); -testcases[tc++] = new TestCase( SECTION, - "0x100000000", - 4294967296, - 0x100000000 ); +new TestCase( SECTION, + "077777777777777776", + 2251799813685246, + 077777777777777776 ); -testcases[tc++] = new TestCase( SECTION, - "077777777777777777", - 2251799813685247, - 077777777777777777 ); +new TestCase( SECTION, + "0x1fffffffffffff", + 9007199254740991, + 0x1fffffffffffff ); -testcases[tc++] = new TestCase( SECTION, - "077777777777777776", - 2251799813685246, - 077777777777777776 ); +new TestCase( SECTION, + "0x20000000000000", + 9007199254740992, + 0x20000000000000 ); -testcases[tc++] = new TestCase( SECTION, - "0x1fffffffffffff", - 9007199254740991, - 0x1fffffffffffff ); +new TestCase( SECTION, + "0x20123456789abc", + 9027215253084860, + 0x20123456789abc ); -testcases[tc++] = new TestCase( SECTION, - "0x20000000000000", - 9007199254740992, - 0x20000000000000 ); +new TestCase( SECTION, + "0x20123456789abd", + 9027215253084860, + 0x20123456789abd ); -testcases[tc++] = new TestCase( SECTION, - "0x20123456789abc", - 9027215253084860, - 0x20123456789abc ); +new TestCase( SECTION, + "0x20123456789abe", + 9027215253084862, + 0x20123456789abe ); -testcases[tc++] = new TestCase( SECTION, - "0x20123456789abd", - 9027215253084860, - 0x20123456789abd ); +new TestCase( SECTION, + "0x20123456789abf", + 9027215253084864, + 0x20123456789abf ); -testcases[tc++] = new TestCase( SECTION, - "0x20123456789abe", - 9027215253084862, - 0x20123456789abe ); +new TestCase( SECTION, + "0x1000000000000080", + 1152921504606847000, + 0x1000000000000080 ); -testcases[tc++] = new TestCase( SECTION, - "0x20123456789abf", - 9027215253084864, - 0x20123456789abf ); +new TestCase( SECTION, + "0x1000000000000081", + 1152921504606847200, + 0x1000000000000081 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000080", - 1152921504606847000, - 0x1000000000000080 ); +new TestCase( SECTION, + "0x1000000000000100", + 1152921504606847200, + 0x1000000000000100 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000081", - 1152921504606847200, - 0x1000000000000081 ); +new TestCase( SECTION, + "0x100000000000017f", + 1152921504606847200, + 0x100000000000017f ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000100", - 1152921504606847200, - 0x1000000000000100 ); +new TestCase( SECTION, + "0x1000000000000180", + 1152921504606847500, + 0x1000000000000180 ); -testcases[tc++] = new TestCase( SECTION, - "0x100000000000017f", - 1152921504606847200, - 0x100000000000017f ); +new TestCase( SECTION, + "0x1000000000000181", + 1152921504606847500, + 0x1000000000000181 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000180", - 1152921504606847500, - 0x1000000000000180 ); +new TestCase( SECTION, + "0x10000000000001f0", + 1152921504606847500, + 0x10000000000001f0 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000181", - 1152921504606847500, - 0x1000000000000181 ); +new TestCase( SECTION, + "0x1000000000000200", + 1152921504606847500, + 0x1000000000000200 ); -testcases[tc++] = new TestCase( SECTION, - "0x10000000000001f0", - 1152921504606847500, - 0x10000000000001f0 ); +new TestCase( SECTION, + "0x100000000000027f", + 1152921504606847500, + 0x100000000000027f ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000200", - 1152921504606847500, - 0x1000000000000200 ); +new TestCase( SECTION, + "0x1000000000000280", + 1152921504606847500, + 0x1000000000000280 ); -testcases[tc++] = new TestCase( SECTION, - "0x100000000000027f", - 1152921504606847500, - 0x100000000000027f ); +new TestCase( SECTION, + "0x1000000000000281", + 1152921504606847700, + 0x1000000000000281 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000280", - 1152921504606847500, - 0x1000000000000280 ); +new TestCase( SECTION, + "0x10000000000002ff", + 1152921504606847700, + 0x10000000000002ff ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000281", - 1152921504606847700, - 0x1000000000000281 ); +new TestCase( SECTION, + "0x1000000000000300", + 1152921504606847700, + 0x1000000000000300 ); -testcases[tc++] = new TestCase( SECTION, - "0x10000000000002ff", - 1152921504606847700, - 0x10000000000002ff ); - -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000300", - 1152921504606847700, - 0x1000000000000300 ); - -testcases[tc++] = new TestCase( SECTION, - "0x10000000000000000", - 18446744073709552000, - 0x10000000000000000 ); +new TestCase( SECTION, + "0x10000000000000000", + 18446744073709552000, + 0x10000000000000000 ); test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = testcases[tc].actual; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - - } - - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.7.3-2.js b/mozilla/js/tests/ecma/LexicalConventions/7.7.3-2.js index 504eaeafbe8..8fd820edf85 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.7.3-2.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.7.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,75 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 7.7.3-2.js - ECMA Section: 7.7.3 Numeric Literals + File Name: 7.7.3-2.js + ECMA Section: 7.7.3 Numeric Literals - Description: + Description: - This is a regression test for - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122884 + This is a regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122884 - Waldemar's comments: + Waldemar's comments: - A numeric literal that starts with either '08' or '09' is interpreted as a - decimal literal; it should be an error instead. (Strictly speaking, according - to ECMA v1 such literals should be interpreted as two integers -- a zero - followed by a decimal number whose first digit is 8 or 9, but this is a bug in - ECMA that will be fixed in v2. In any case, there is no place in the grammar - where two consecutive numbers would be legal.) + A numeric literal that starts with either '08' or '09' is interpreted as a + decimal literal; it should be an error instead. (Strictly speaking, according + to ECMA v1 such literals should be interpreted as two integers -- a zero + followed by a decimal number whose first digit is 8 or 9, but this is a bug in + ECMA that will be fixed in v2. In any case, there is no place in the grammar + where two consecutive numbers would be legal.) - Author: christine@netscape.com - Date: 15 june 1998 + Author: christine@netscape.com + Date: 15 june 1998 */ - var SECTION = "7.7.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Numeric Literals"; - var BUGNUMBER="122884"; +var SECTION = "7.7.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Numeric Literals"; +var BUGNUMBER="122884"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "9", + 9, + 9 ); - testcases[tc++] = new TestCase( SECTION, - "9", - 9, - 9 ); +new TestCase( SECTION, + "09", + 9, + 09 ); - testcases[tc++] = new TestCase( SECTION, - "09", - 9, - 09 ); - - testcases[tc++] = new TestCase( SECTION, - "099", - 99, - 099 ); +new TestCase( SECTION, + "099", + 99, + 099 ); - testcases[tc++] = new TestCase( SECTION, - "077", - 63, - 077 ); +new TestCase( SECTION, + "077", + 63, + 077 ); - test(); - - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = testcases[tc].actual; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - - } - - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.7.3.js b/mozilla/js/tests/ecma/LexicalConventions/7.7.3.js index fb8686e0a66..9f480eff754 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.7.3.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.7.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,318 +36,293 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.7.3.js - ECMA Section: 7.7.3 Numeric Literals + File Name: 7.7.3.js + ECMA Section: 7.7.3 Numeric Literals - Description: A numeric literal stands for a value of the Number type - This value is determined in two steps: first a - mathematical value (MV) is derived from the literal; - second, this mathematical value is rounded, ideally - using IEEE 754 round-to-nearest mode, to a reprentable - value of of the number type. + Description: A numeric literal stands for a value of the Number type + This value is determined in two steps: first a + mathematical value (MV) is derived from the literal; + second, this mathematical value is rounded, ideally + using IEEE 754 round-to-nearest mode, to a reprentable + value of of the number type. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "7.7.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Numeric Literals"; +var SECTION = "7.7.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Numeric Literals"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "0", 0, 0 ); +new TestCase( SECTION, "1", 1, 1 ); +new TestCase( SECTION, "2", 2, 2 ); +new TestCase( SECTION, "3", 3, 3 ); +new TestCase( SECTION, "4", 4, 4 ); +new TestCase( SECTION, "5", 5, 5 ); +new TestCase( SECTION, "6", 6, 6 ); +new TestCase( SECTION, "7", 7, 7 ); +new TestCase( SECTION, "8", 8, 8 ); +new TestCase( SECTION, "9", 9, 9 ); + +new TestCase( SECTION, "0.", 0, 0. ); +new TestCase( SECTION, "1.", 1, 1. ); +new TestCase( SECTION, "2.", 2, 2. ); +new TestCase( SECTION, "3.", 3, 3. ); +new TestCase( SECTION, "4.", 4, 4. ); + +new TestCase( SECTION, "0.e0", 0, 0.e0 ); +new TestCase( SECTION, "1.e1", 10, 1.e1 ); +new TestCase( SECTION, "2.e2", 200, 2.e2 ); +new TestCase( SECTION, "3.e3", 3000, 3.e3 ); +new TestCase( SECTION, "4.e4", 40000, 4.e4 ); + +new TestCase( SECTION, "0.1e0", .1, 0.1e0 ); +new TestCase( SECTION, "1.1e1", 11, 1.1e1 ); +new TestCase( SECTION, "2.2e2", 220, 2.2e2 ); +new TestCase( SECTION, "3.3e3", 3300, 3.3e3 ); +new TestCase( SECTION, "4.4e4", 44000, 4.4e4 ); + +new TestCase( SECTION, ".1e0", .1, .1e0 ); +new TestCase( SECTION, ".1e1", 1, .1e1 ); +new TestCase( SECTION, ".2e2", 20, .2e2 ); +new TestCase( SECTION, ".3e3", 300, .3e3 ); +new TestCase( SECTION, ".4e4", 4000, .4e4 ); + +new TestCase( SECTION, "0e0", 0, 0e0 ); +new TestCase( SECTION, "1e1", 10, 1e1 ); +new TestCase( SECTION, "2e2", 200, 2e2 ); +new TestCase( SECTION, "3e3", 3000, 3e3 ); +new TestCase( SECTION, "4e4", 40000, 4e4 ); + +new TestCase( SECTION, "0e0", 0, 0e0 ); +new TestCase( SECTION, "1e1", 10, 1e1 ); +new TestCase( SECTION, "2e2", 200, 2e2 ); +new TestCase( SECTION, "3e3", 3000, 3e3 ); +new TestCase( SECTION, "4e4", 40000, 4e4 ); + +new TestCase( SECTION, "0E0", 0, 0E0 ); +new TestCase( SECTION, "1E1", 10, 1E1 ); +new TestCase( SECTION, "2E2", 200, 2E2 ); +new TestCase( SECTION, "3E3", 3000, 3E3 ); +new TestCase( SECTION, "4E4", 40000, 4E4 ); + +new TestCase( SECTION, "1.e-1", 0.1, 1.e-1 ); +new TestCase( SECTION, "2.e-2", 0.02, 2.e-2 ); +new TestCase( SECTION, "3.e-3", 0.003, 3.e-3 ); +new TestCase( SECTION, "4.e-4", 0.0004, 4.e-4 ); + +new TestCase( SECTION, "0.1e-0", .1, 0.1e-0 ); +new TestCase( SECTION, "1.1e-1", 0.11, 1.1e-1 ); +new TestCase( SECTION, "2.2e-2", .022, 2.2e-2 ); +new TestCase( SECTION, "3.3e-3", .0033, 3.3e-3 ); +new TestCase( SECTION, "4.4e-4", .00044, 4.4e-4 ); + +new TestCase( SECTION, ".1e-0", .1, .1e-0 ); +new TestCase( SECTION, ".1e-1", .01, .1e-1 ); +new TestCase( SECTION, ".2e-2", .002, .2e-2 ); +new TestCase( SECTION, ".3e-3", .0003, .3e-3 ); +new TestCase( SECTION, ".4e-4", .00004, .4e-4 ); + +new TestCase( SECTION, "1.e+1", 10, 1.e+1 ); +new TestCase( SECTION, "2.e+2", 200, 2.e+2 ); +new TestCase( SECTION, "3.e+3", 3000, 3.e+3 ); +new TestCase( SECTION, "4.e+4", 40000, 4.e+4 ); + +new TestCase( SECTION, "0.1e+0", .1, 0.1e+0 ); +new TestCase( SECTION, "1.1e+1", 11, 1.1e+1 ); +new TestCase( SECTION, "2.2e+2", 220, 2.2e+2 ); +new TestCase( SECTION, "3.3e+3", 3300, 3.3e+3 ); +new TestCase( SECTION, "4.4e+4", 44000, 4.4e+4 ); + +new TestCase( SECTION, ".1e+0", .1, .1e+0 ); +new TestCase( SECTION, ".1e+1", 1, .1e+1 ); +new TestCase( SECTION, ".2e+2", 20, .2e+2 ); +new TestCase( SECTION, ".3e+3", 300, .3e+3 ); +new TestCase( SECTION, ".4e+4", 4000, .4e+4 ); + +new TestCase( SECTION, "0x0", 0, 0x0 ); +new TestCase( SECTION, "0x1", 1, 0x1 ); +new TestCase( SECTION, "0x2", 2, 0x2 ); +new TestCase( SECTION, "0x3", 3, 0x3 ); +new TestCase( SECTION, "0x4", 4, 0x4 ); +new TestCase( SECTION, "0x5", 5, 0x5 ); +new TestCase( SECTION, "0x6", 6, 0x6 ); +new TestCase( SECTION, "0x7", 7, 0x7 ); +new TestCase( SECTION, "0x8", 8, 0x8 ); +new TestCase( SECTION, "0x9", 9, 0x9 ); +new TestCase( SECTION, "0xa", 10, 0xa ); +new TestCase( SECTION, "0xb", 11, 0xb ); +new TestCase( SECTION, "0xc", 12, 0xc ); +new TestCase( SECTION, "0xd", 13, 0xd ); +new TestCase( SECTION, "0xe", 14, 0xe ); +new TestCase( SECTION, "0xf", 15, 0xf ); + +new TestCase( SECTION, "0X0", 0, 0X0 ); +new TestCase( SECTION, "0X1", 1, 0X1 ); +new TestCase( SECTION, "0X2", 2, 0X2 ); +new TestCase( SECTION, "0X3", 3, 0X3 ); +new TestCase( SECTION, "0X4", 4, 0X4 ); +new TestCase( SECTION, "0X5", 5, 0X5 ); +new TestCase( SECTION, "0X6", 6, 0X6 ); +new TestCase( SECTION, "0X7", 7, 0X7 ); +new TestCase( SECTION, "0X8", 8, 0X8 ); +new TestCase( SECTION, "0X9", 9, 0X9 ); +new TestCase( SECTION, "0Xa", 10, 0Xa ); +new TestCase( SECTION, "0Xb", 11, 0Xb ); +new TestCase( SECTION, "0Xc", 12, 0Xc ); +new TestCase( SECTION, "0Xd", 13, 0Xd ); +new TestCase( SECTION, "0Xe", 14, 0Xe ); +new TestCase( SECTION, "0Xf", 15, 0Xf ); + +new TestCase( SECTION, "0x0", 0, 0x0 ); +new TestCase( SECTION, "0x1", 1, 0x1 ); +new TestCase( SECTION, "0x2", 2, 0x2 ); +new TestCase( SECTION, "0x3", 3, 0x3 ); +new TestCase( SECTION, "0x4", 4, 0x4 ); +new TestCase( SECTION, "0x5", 5, 0x5 ); +new TestCase( SECTION, "0x6", 6, 0x6 ); +new TestCase( SECTION, "0x7", 7, 0x7 ); +new TestCase( SECTION, "0x8", 8, 0x8 ); +new TestCase( SECTION, "0x9", 9, 0x9 ); +new TestCase( SECTION, "0xA", 10, 0xA ); +new TestCase( SECTION, "0xB", 11, 0xB ); +new TestCase( SECTION, "0xC", 12, 0xC ); +new TestCase( SECTION, "0xD", 13, 0xD ); +new TestCase( SECTION, "0xE", 14, 0xE ); +new TestCase( SECTION, "0xF", 15, 0xF ); + +new TestCase( SECTION, "0X0", 0, 0X0 ); +new TestCase( SECTION, "0X1", 1, 0X1 ); +new TestCase( SECTION, "0X2", 2, 0X2 ); +new TestCase( SECTION, "0X3", 3, 0X3 ); +new TestCase( SECTION, "0X4", 4, 0X4 ); +new TestCase( SECTION, "0X5", 5, 0X5 ); +new TestCase( SECTION, "0X6", 6, 0X6 ); +new TestCase( SECTION, "0X7", 7, 0X7 ); +new TestCase( SECTION, "0X8", 8, 0X8 ); +new TestCase( SECTION, "0X9", 9, 0X9 ); +new TestCase( SECTION, "0XA", 10, 0XA ); +new TestCase( SECTION, "0XB", 11, 0XB ); +new TestCase( SECTION, "0XC", 12, 0XC ); +new TestCase( SECTION, "0XD", 13, 0XD ); +new TestCase( SECTION, "0XE", 14, 0XE ); +new TestCase( SECTION, "0XF", 15, 0XF ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "00", 0, 00 ); +new TestCase( SECTION, "01", 1, 01 ); +new TestCase( SECTION, "02", 2, 02 ); +new TestCase( SECTION, "03", 3, 03 ); +new TestCase( SECTION, "04", 4, 04 ); +new TestCase( SECTION, "05", 5, 05 ); +new TestCase( SECTION, "06", 6, 06 ); +new TestCase( SECTION, "07", 7, 07 ); - array[item++] = new TestCase( SECTION, "0", 0, 0 ); - array[item++] = new TestCase( SECTION, "1", 1, 1 ); - array[item++] = new TestCase( SECTION, "2", 2, 2 ); - array[item++] = new TestCase( SECTION, "3", 3, 3 ); - array[item++] = new TestCase( SECTION, "4", 4, 4 ); - array[item++] = new TestCase( SECTION, "5", 5, 5 ); - array[item++] = new TestCase( SECTION, "6", 6, 6 ); - array[item++] = new TestCase( SECTION, "7", 7, 7 ); - array[item++] = new TestCase( SECTION, "8", 8, 8 ); - array[item++] = new TestCase( SECTION, "9", 9, 9 ); +new TestCase( SECTION, "000", 0, 000 ); +new TestCase( SECTION, "011", 9, 011 ); +new TestCase( SECTION, "022", 18, 022 ); +new TestCase( SECTION, "033", 27, 033 ); +new TestCase( SECTION, "044", 36, 044 ); +new TestCase( SECTION, "055", 45, 055 ); +new TestCase( SECTION, "066", 54, 066 ); +new TestCase( SECTION, "077", 63, 077 ); - array[item++] = new TestCase( SECTION, "0.", 0, 0. ); - array[item++] = new TestCase( SECTION, "1.", 1, 1. ); - array[item++] = new TestCase( SECTION, "2.", 2, 2. ); - array[item++] = new TestCase( SECTION, "3.", 3, 3. ); - array[item++] = new TestCase( SECTION, "4.", 4, 4. ); - - array[item++] = new TestCase( SECTION, "0.e0", 0, 0.e0 ); - array[item++] = new TestCase( SECTION, "1.e1", 10, 1.e1 ); - array[item++] = new TestCase( SECTION, "2.e2", 200, 2.e2 ); - array[item++] = new TestCase( SECTION, "3.e3", 3000, 3.e3 ); - array[item++] = new TestCase( SECTION, "4.e4", 40000, 4.e4 ); - - array[item++] = new TestCase( SECTION, "0.1e0", .1, 0.1e0 ); - array[item++] = new TestCase( SECTION, "1.1e1", 11, 1.1e1 ); - array[item++] = new TestCase( SECTION, "2.2e2", 220, 2.2e2 ); - array[item++] = new TestCase( SECTION, "3.3e3", 3300, 3.3e3 ); - array[item++] = new TestCase( SECTION, "4.4e4", 44000, 4.4e4 ); - - array[item++] = new TestCase( SECTION, ".1e0", .1, .1e0 ); - array[item++] = new TestCase( SECTION, ".1e1", 1, .1e1 ); - array[item++] = new TestCase( SECTION, ".2e2", 20, .2e2 ); - array[item++] = new TestCase( SECTION, ".3e3", 300, .3e3 ); - array[item++] = new TestCase( SECTION, ".4e4", 4000, .4e4 ); - - array[item++] = new TestCase( SECTION, "0e0", 0, 0e0 ); - array[item++] = new TestCase( SECTION, "1e1", 10, 1e1 ); - array[item++] = new TestCase( SECTION, "2e2", 200, 2e2 ); - array[item++] = new TestCase( SECTION, "3e3", 3000, 3e3 ); - array[item++] = new TestCase( SECTION, "4e4", 40000, 4e4 ); - - array[item++] = new TestCase( SECTION, "0e0", 0, 0e0 ); - array[item++] = new TestCase( SECTION, "1e1", 10, 1e1 ); - array[item++] = new TestCase( SECTION, "2e2", 200, 2e2 ); - array[item++] = new TestCase( SECTION, "3e3", 3000, 3e3 ); - array[item++] = new TestCase( SECTION, "4e4", 40000, 4e4 ); - - array[item++] = new TestCase( SECTION, "0E0", 0, 0E0 ); - array[item++] = new TestCase( SECTION, "1E1", 10, 1E1 ); - array[item++] = new TestCase( SECTION, "2E2", 200, 2E2 ); - array[item++] = new TestCase( SECTION, "3E3", 3000, 3E3 ); - array[item++] = new TestCase( SECTION, "4E4", 40000, 4E4 ); - - array[item++] = new TestCase( SECTION, "1.e-1", 0.1, 1.e-1 ); - array[item++] = new TestCase( SECTION, "2.e-2", 0.02, 2.e-2 ); - array[item++] = new TestCase( SECTION, "3.e-3", 0.003, 3.e-3 ); - array[item++] = new TestCase( SECTION, "4.e-4", 0.0004, 4.e-4 ); - - array[item++] = new TestCase( SECTION, "0.1e-0", .1, 0.1e-0 ); - array[item++] = new TestCase( SECTION, "1.1e-1", 0.11, 1.1e-1 ); - array[item++] = new TestCase( SECTION, "2.2e-2", .022, 2.2e-2 ); - array[item++] = new TestCase( SECTION, "3.3e-3", .0033, 3.3e-3 ); - array[item++] = new TestCase( SECTION, "4.4e-4", .00044, 4.4e-4 ); - - array[item++] = new TestCase( SECTION, ".1e-0", .1, .1e-0 ); - array[item++] = new TestCase( SECTION, ".1e-1", .01, .1e-1 ); - array[item++] = new TestCase( SECTION, ".2e-2", .002, .2e-2 ); - array[item++] = new TestCase( SECTION, ".3e-3", .0003, .3e-3 ); - array[item++] = new TestCase( SECTION, ".4e-4", .00004, .4e-4 ); - - array[item++] = new TestCase( SECTION, "1.e+1", 10, 1.e+1 ); - array[item++] = new TestCase( SECTION, "2.e+2", 200, 2.e+2 ); - array[item++] = new TestCase( SECTION, "3.e+3", 3000, 3.e+3 ); - array[item++] = new TestCase( SECTION, "4.e+4", 40000, 4.e+4 ); - - array[item++] = new TestCase( SECTION, "0.1e+0", .1, 0.1e+0 ); - array[item++] = new TestCase( SECTION, "1.1e+1", 11, 1.1e+1 ); - array[item++] = new TestCase( SECTION, "2.2e+2", 220, 2.2e+2 ); - array[item++] = new TestCase( SECTION, "3.3e+3", 3300, 3.3e+3 ); - array[item++] = new TestCase( SECTION, "4.4e+4", 44000, 4.4e+4 ); - - array[item++] = new TestCase( SECTION, ".1e+0", .1, .1e+0 ); - array[item++] = new TestCase( SECTION, ".1e+1", 1, .1e+1 ); - array[item++] = new TestCase( SECTION, ".2e+2", 20, .2e+2 ); - array[item++] = new TestCase( SECTION, ".3e+3", 300, .3e+3 ); - array[item++] = new TestCase( SECTION, ".4e+4", 4000, .4e+4 ); - - array[item++] = new TestCase( SECTION, "0x0", 0, 0x0 ); - array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); - array[item++] = new TestCase( SECTION, "0x2", 2, 0x2 ); - array[item++] = new TestCase( SECTION, "0x3", 3, 0x3 ); - array[item++] = new TestCase( SECTION, "0x4", 4, 0x4 ); - array[item++] = new TestCase( SECTION, "0x5", 5, 0x5 ); - array[item++] = new TestCase( SECTION, "0x6", 6, 0x6 ); - array[item++] = new TestCase( SECTION, "0x7", 7, 0x7 ); - array[item++] = new TestCase( SECTION, "0x8", 8, 0x8 ); - array[item++] = new TestCase( SECTION, "0x9", 9, 0x9 ); - array[item++] = new TestCase( SECTION, "0xa", 10, 0xa ); - array[item++] = new TestCase( SECTION, "0xb", 11, 0xb ); - array[item++] = new TestCase( SECTION, "0xc", 12, 0xc ); - array[item++] = new TestCase( SECTION, "0xd", 13, 0xd ); - array[item++] = new TestCase( SECTION, "0xe", 14, 0xe ); - array[item++] = new TestCase( SECTION, "0xf", 15, 0xf ); - - array[item++] = new TestCase( SECTION, "0X0", 0, 0X0 ); - array[item++] = new TestCase( SECTION, "0X1", 1, 0X1 ); - array[item++] = new TestCase( SECTION, "0X2", 2, 0X2 ); - array[item++] = new TestCase( SECTION, "0X3", 3, 0X3 ); - array[item++] = new TestCase( SECTION, "0X4", 4, 0X4 ); - array[item++] = new TestCase( SECTION, "0X5", 5, 0X5 ); - array[item++] = new TestCase( SECTION, "0X6", 6, 0X6 ); - array[item++] = new TestCase( SECTION, "0X7", 7, 0X7 ); - array[item++] = new TestCase( SECTION, "0X8", 8, 0X8 ); - array[item++] = new TestCase( SECTION, "0X9", 9, 0X9 ); - array[item++] = new TestCase( SECTION, "0Xa", 10, 0Xa ); - array[item++] = new TestCase( SECTION, "0Xb", 11, 0Xb ); - array[item++] = new TestCase( SECTION, "0Xc", 12, 0Xc ); - array[item++] = new TestCase( SECTION, "0Xd", 13, 0Xd ); - array[item++] = new TestCase( SECTION, "0Xe", 14, 0Xe ); - array[item++] = new TestCase( SECTION, "0Xf", 15, 0Xf ); - - array[item++] = new TestCase( SECTION, "0x0", 0, 0x0 ); - array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); - array[item++] = new TestCase( SECTION, "0x2", 2, 0x2 ); - array[item++] = new TestCase( SECTION, "0x3", 3, 0x3 ); - array[item++] = new TestCase( SECTION, "0x4", 4, 0x4 ); - array[item++] = new TestCase( SECTION, "0x5", 5, 0x5 ); - array[item++] = new TestCase( SECTION, "0x6", 6, 0x6 ); - array[item++] = new TestCase( SECTION, "0x7", 7, 0x7 ); - array[item++] = new TestCase( SECTION, "0x8", 8, 0x8 ); - array[item++] = new TestCase( SECTION, "0x9", 9, 0x9 ); - array[item++] = new TestCase( SECTION, "0xA", 10, 0xA ); - array[item++] = new TestCase( SECTION, "0xB", 11, 0xB ); - array[item++] = new TestCase( SECTION, "0xC", 12, 0xC ); - array[item++] = new TestCase( SECTION, "0xD", 13, 0xD ); - array[item++] = new TestCase( SECTION, "0xE", 14, 0xE ); - array[item++] = new TestCase( SECTION, "0xF", 15, 0xF ); - - array[item++] = new TestCase( SECTION, "0X0", 0, 0X0 ); - array[item++] = new TestCase( SECTION, "0X1", 1, 0X1 ); - array[item++] = new TestCase( SECTION, "0X2", 2, 0X2 ); - array[item++] = new TestCase( SECTION, "0X3", 3, 0X3 ); - array[item++] = new TestCase( SECTION, "0X4", 4, 0X4 ); - array[item++] = new TestCase( SECTION, "0X5", 5, 0X5 ); - array[item++] = new TestCase( SECTION, "0X6", 6, 0X6 ); - array[item++] = new TestCase( SECTION, "0X7", 7, 0X7 ); - array[item++] = new TestCase( SECTION, "0X8", 8, 0X8 ); - array[item++] = new TestCase( SECTION, "0X9", 9, 0X9 ); - array[item++] = new TestCase( SECTION, "0XA", 10, 0XA ); - array[item++] = new TestCase( SECTION, "0XB", 11, 0XB ); - array[item++] = new TestCase( SECTION, "0XC", 12, 0XC ); - array[item++] = new TestCase( SECTION, "0XD", 13, 0XD ); - array[item++] = new TestCase( SECTION, "0XE", 14, 0XE ); - array[item++] = new TestCase( SECTION, "0XF", 15, 0XF ); +new TestCase( SECTION, "0.00000000001", 0.00000000001, 0.00000000001 ); +new TestCase( SECTION, "0.00000000001e-2", 0.0000000000001, 0.00000000001e-2 ); - array[item++] = new TestCase( SECTION, "00", 0, 00 ); - array[item++] = new TestCase( SECTION, "01", 1, 01 ); - array[item++] = new TestCase( SECTION, "02", 2, 02 ); - array[item++] = new TestCase( SECTION, "03", 3, 03 ); - array[item++] = new TestCase( SECTION, "04", 4, 04 ); - array[item++] = new TestCase( SECTION, "05", 5, 05 ); - array[item++] = new TestCase( SECTION, "06", 6, 06 ); - array[item++] = new TestCase( SECTION, "07", 7, 07 ); +new TestCase( SECTION, + "123456789012345671.9999", + "123456789012345660", + 123456789012345671.9999 +""); +new TestCase( SECTION, + "123456789012345672", + "123456789012345660", + 123456789012345672 +""); - array[item++] = new TestCase( SECTION, "000", 0, 000 ); - array[item++] = new TestCase( SECTION, "011", 9, 011 ); - array[item++] = new TestCase( SECTION, "022", 18, 022 ); - array[item++] = new TestCase( SECTION, "033", 27, 033 ); - array[item++] = new TestCase( SECTION, "044", 36, 044 ); - array[item++] = new TestCase( SECTION, "055", 45, 055 ); - array[item++] = new TestCase( SECTION, "066", 54, 066 ); - array[item++] = new TestCase( SECTION, "077", 63, 077 ); +new TestCase( SECTION, + "123456789012345672.000000000000000000000000000", + "123456789012345660", + 123456789012345672.000000000000000000000000000 +""); - array[item++] = new TestCase( SECTION, "0.00000000001", 0.00000000001, 0.00000000001 ); - array[item++] = new TestCase( SECTION, "0.00000000001e-2", 0.0000000000001, 0.00000000001e-2 ); +new TestCase( SECTION, + "123456789012345672.01", + "123456789012345680", + 123456789012345672.01 +""); +new TestCase( SECTION, + "123456789012345672.000000000000000000000000001+'' == 123456789012345680 || 123456789012345660", + true, + ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345680 ) + || + ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345660) ); - array[item++] = new TestCase( SECTION, - "123456789012345671.9999", - "123456789012345660", - 123456789012345671.9999 +""); - array[item++] = new TestCase( SECTION, - "123456789012345672", - "123456789012345660", - 123456789012345672 +""); +new TestCase( SECTION, + "123456789012345673", + "123456789012345680", + 123456789012345673 +"" ); - array[item++] = new TestCase( SECTION, - "123456789012345672.000000000000000000000000000", - "123456789012345660", - 123456789012345672.000000000000000000000000000 +""); +new TestCase( SECTION, + "-123456789012345671.9999", + "-123456789012345660", + -123456789012345671.9999 +"" ); - array[item++] = new TestCase( SECTION, - "123456789012345672.01", - "123456789012345680", - 123456789012345672.01 +""); +new TestCase( SECTION, + "-123456789012345672", + "-123456789012345660", + -123456789012345672+""); - array[item++] = new TestCase( SECTION, - "123456789012345672.000000000000000000000000001+'' == 123456789012345680 || 123456789012345660", - true, - ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345680 ) - || - ( 123456789012345672.00000000000000000000000000 +"" == 1234567890 * 100000000 + 12345660) ); +new TestCase( SECTION, + "-123456789012345672.000000000000000000000000000", + "-123456789012345660", + -123456789012345672.000000000000000000000000000 +""); - array[item++] = new TestCase( SECTION, - "123456789012345673", - "123456789012345680", - 123456789012345673 +"" ); +new TestCase( SECTION, + "-123456789012345672.01", + "-123456789012345680", + -123456789012345672.01 +"" ); - array[item++] = new TestCase( SECTION, - "-123456789012345671.9999", - "-123456789012345660", - -123456789012345671.9999 +"" ); +new TestCase( SECTION, + "-123456789012345672.000000000000000000000000001 == -123456789012345680 or -123456789012345660", + true, + (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345680) + || + (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345660)); - array[item++] = new TestCase( SECTION, - "-123456789012345672", - "-123456789012345660", - -123456789012345672+""); +new TestCase( SECTION, + -123456789012345673, + "-123456789012345680", + -123456789012345673 +""); - array[item++] = new TestCase( SECTION, - "-123456789012345672.000000000000000000000000000", - "-123456789012345660", - -123456789012345672.000000000000000000000000000 +""); - - array[item++] = new TestCase( SECTION, - "-123456789012345672.01", - "-123456789012345680", - -123456789012345672.01 +"" ); - - array[item++] = new TestCase( SECTION, - "-123456789012345672.000000000000000000000000001 == -123456789012345680 or -123456789012345660", - true, - (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345680) - || - (-123456789012345672.000000000000000000000000001 +"" == -1234567890 * 100000000 -12345660)); - - array[item++] = new TestCase( SECTION, - -123456789012345673, - "-123456789012345680", - -123456789012345673 +""); - - array[item++] = new TestCase( SECTION, - "12345678901234567890", - "12345678901234567000", - 12345678901234567890 +"" ); +new TestCase( SECTION, + "12345678901234567890", + "12345678901234567000", + 12345678901234567890 +"" ); /* - array[item++] = new TestCase( SECTION, "12345678901234567", "12345678901234567", 12345678901234567+"" ); - array[item++] = new TestCase( SECTION, "123456789012345678", "123456789012345678", 123456789012345678+"" ); - array[item++] = new TestCase( SECTION, "1234567890123456789", "1234567890123456789", 1234567890123456789+"" ); - array[item++] = new TestCase( SECTION, "12345678901234567890", "12345678901234567890", 12345678901234567890+"" ); - array[item++] = new TestCase( SECTION, "123456789012345678900", "123456789012345678900", 123456789012345678900+"" ); - array[item++] = new TestCase( SECTION, "1234567890123456789000", "1234567890123456789000", 1234567890123456789000+"" ); + new TestCase( SECTION, "12345678901234567", "12345678901234567", 12345678901234567+"" ); + new TestCase( SECTION, "123456789012345678", "123456789012345678", 123456789012345678+"" ); + new TestCase( SECTION, "1234567890123456789", "1234567890123456789", 1234567890123456789+"" ); + new TestCase( SECTION, "12345678901234567890", "12345678901234567890", 12345678901234567890+"" ); + new TestCase( SECTION, "123456789012345678900", "123456789012345678900", 123456789012345678900+"" ); + new TestCase( SECTION, "1234567890123456789000", "1234567890123456789000", 1234567890123456789000+"" ); */ - array[item++] = new TestCase( SECTION, "0x1", 1, 0x1 ); - array[item++] = new TestCase( SECTION, "0x10", 16, 0x10 ); - array[item++] = new TestCase( SECTION, "0x100", 256, 0x100 ); - array[item++] = new TestCase( SECTION, "0x1000", 4096, 0x1000 ); - array[item++] = new TestCase( SECTION, "0x10000", 65536, 0x10000 ); - array[item++] = new TestCase( SECTION, "0x100000", 1048576, 0x100000 ); - array[item++] = new TestCase( SECTION, "0x1000000", 16777216, 0x1000000 ); - array[item++] = new TestCase( SECTION, "0x10000000", 268435456, 0x10000000 ); +new TestCase( SECTION, "0x1", 1, 0x1 ); +new TestCase( SECTION, "0x10", 16, 0x10 ); +new TestCase( SECTION, "0x100", 256, 0x100 ); +new TestCase( SECTION, "0x1000", 4096, 0x1000 ); +new TestCase( SECTION, "0x10000", 65536, 0x10000 ); +new TestCase( SECTION, "0x100000", 1048576, 0x100000 ); +new TestCase( SECTION, "0x1000000", 16777216, 0x1000000 ); +new TestCase( SECTION, "0x10000000", 268435456, 0x10000000 ); /* - array[item++] = new TestCase( SECTION, "0x100000000", 4294967296, 0x100000000 ); - array[item++] = new TestCase( SECTION, "0x1000000000", 68719476736, 0x1000000000 ); - array[item++] = new TestCase( SECTION, "0x10000000000", 1099511627776, 0x10000000000 ); + new TestCase( SECTION, "0x100000000", 4294967296, 0x100000000 ); + new TestCase( SECTION, "0x1000000000", 68719476736, 0x1000000000 ); + new TestCase( SECTION, "0x10000000000", 1099511627776, 0x10000000000 ); */ - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = testcases[tc].actual; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - - } - - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.7.4.js b/mozilla/js/tests/ecma/LexicalConventions/7.7.4.js index 375fe4b7cd1..7a5ca56b859 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.7.4.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.7.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,256 +36,231 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.7.4.js - ECMA Section: 7.7.4 String Literals + File Name: 7.7.4.js + ECMA Section: 7.7.4 String Literals - Description: A string literal is zero or more characters enclosed in - single or double quotes. Each character may be - represented by an escape sequence. + Description: A string literal is zero or more characters enclosed in + single or double quotes. Each character may be + represented by an escape sequence. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "7.7.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String Literals"; +var SECTION = "7.7.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String Literals"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// StringLiteral:: "" and '' -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "\"\"", "", "" ); +new TestCase( SECTION, "\'\'", "", '' ); - // StringLiteral:: "" and '' +// DoubleStringCharacters:: DoubleStringCharacter :: EscapeSequence :: CharacterEscapeSequence +new TestCase( SECTION, "\\\"", String.fromCharCode(0x0022), "\"" ); +new TestCase( SECTION, "\\\'", String.fromCharCode(0x0027), "\'" ); +new TestCase( SECTION, "\\", String.fromCharCode(0x005C), "\\" ); +new TestCase( SECTION, "\\b", String.fromCharCode(0x0008), "\b" ); +new TestCase( SECTION, "\\f", String.fromCharCode(0x000C), "\f" ); +new TestCase( SECTION, "\\n", String.fromCharCode(0x000A), "\n" ); +new TestCase( SECTION, "\\r", String.fromCharCode(0x000D), "\r" ); +new TestCase( SECTION, "\\t", String.fromCharCode(0x0009), "\t" ); +new TestCase( SECTION, "\\v", String.fromCharCode(0x000B), "\v" ); - array[item++] = new TestCase( SECTION, "\"\"", "", "" ); - array[item++] = new TestCase( SECTION, "\'\'", "", '' ); +// DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::OctalEscapeSequence - // DoubleStringCharacters:: DoubleStringCharacter :: EscapeSequence :: CharacterEscapeSequence - array[item++] = new TestCase( SECTION, "\\\"", String.fromCharCode(0x0022), "\"" ); - array[item++] = new TestCase( SECTION, "\\\'", String.fromCharCode(0x0027), "\'" ); - array[item++] = new TestCase( SECTION, "\\", String.fromCharCode(0x005C), "\\" ); - array[item++] = new TestCase( SECTION, "\\b", String.fromCharCode(0x0008), "\b" ); - array[item++] = new TestCase( SECTION, "\\f", String.fromCharCode(0x000C), "\f" ); - array[item++] = new TestCase( SECTION, "\\n", String.fromCharCode(0x000A), "\n" ); - array[item++] = new TestCase( SECTION, "\\r", String.fromCharCode(0x000D), "\r" ); - array[item++] = new TestCase( SECTION, "\\t", String.fromCharCode(0x0009), "\t" ); - array[item++] = new TestCase( SECTION, "\\v", String.fromCharCode(0x000B), "\v" ); +new TestCase( SECTION, "\\00", String.fromCharCode(0x0000), "\00" ); +new TestCase( SECTION, "\\01", String.fromCharCode(0x0001), "\01" ); +new TestCase( SECTION, "\\02", String.fromCharCode(0x0002), "\02" ); +new TestCase( SECTION, "\\03", String.fromCharCode(0x0003), "\03" ); +new TestCase( SECTION, "\\04", String.fromCharCode(0x0004), "\04" ); +new TestCase( SECTION, "\\05", String.fromCharCode(0x0005), "\05" ); +new TestCase( SECTION, "\\06", String.fromCharCode(0x0006), "\06" ); +new TestCase( SECTION, "\\07", String.fromCharCode(0x0007), "\07" ); - // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::OctalEscapeSequence +new TestCase( SECTION, "\\010", String.fromCharCode(0x0008), "\010" ); +new TestCase( SECTION, "\\011", String.fromCharCode(0x0009), "\011" ); +new TestCase( SECTION, "\\012", String.fromCharCode(0x000A), "\012" ); +new TestCase( SECTION, "\\013", String.fromCharCode(0x000B), "\013" ); +new TestCase( SECTION, "\\014", String.fromCharCode(0x000C), "\014" ); +new TestCase( SECTION, "\\015", String.fromCharCode(0x000D), "\015" ); +new TestCase( SECTION, "\\016", String.fromCharCode(0x000E), "\016" ); +new TestCase( SECTION, "\\017", String.fromCharCode(0x000F), "\017" ); +new TestCase( SECTION, "\\020", String.fromCharCode(0x0010), "\020" ); +new TestCase( SECTION, "\\042", String.fromCharCode(0x0022), "\042" ); - array[item++] = new TestCase( SECTION, "\\00", String.fromCharCode(0x0000), "\00" ); - array[item++] = new TestCase( SECTION, "\\01", String.fromCharCode(0x0001), "\01" ); - array[item++] = new TestCase( SECTION, "\\02", String.fromCharCode(0x0002), "\02" ); - array[item++] = new TestCase( SECTION, "\\03", String.fromCharCode(0x0003), "\03" ); - array[item++] = new TestCase( SECTION, "\\04", String.fromCharCode(0x0004), "\04" ); - array[item++] = new TestCase( SECTION, "\\05", String.fromCharCode(0x0005), "\05" ); - array[item++] = new TestCase( SECTION, "\\06", String.fromCharCode(0x0006), "\06" ); - array[item++] = new TestCase( SECTION, "\\07", String.fromCharCode(0x0007), "\07" ); +new TestCase( SECTION, "\\0", String.fromCharCode(0x0000), "\0" ); +new TestCase( SECTION, "\\1", String.fromCharCode(0x0001), "\1" ); +new TestCase( SECTION, "\\2", String.fromCharCode(0x0002), "\2" ); +new TestCase( SECTION, "\\3", String.fromCharCode(0x0003), "\3" ); +new TestCase( SECTION, "\\4", String.fromCharCode(0x0004), "\4" ); +new TestCase( SECTION, "\\5", String.fromCharCode(0x0005), "\5" ); +new TestCase( SECTION, "\\6", String.fromCharCode(0x0006), "\6" ); +new TestCase( SECTION, "\\7", String.fromCharCode(0x0007), "\7" ); - array[item++] = new TestCase( SECTION, "\\010", String.fromCharCode(0x0008), "\010" ); - array[item++] = new TestCase( SECTION, "\\011", String.fromCharCode(0x0009), "\011" ); - array[item++] = new TestCase( SECTION, "\\012", String.fromCharCode(0x000A), "\012" ); - array[item++] = new TestCase( SECTION, "\\013", String.fromCharCode(0x000B), "\013" ); - array[item++] = new TestCase( SECTION, "\\014", String.fromCharCode(0x000C), "\014" ); - array[item++] = new TestCase( SECTION, "\\015", String.fromCharCode(0x000D), "\015" ); - array[item++] = new TestCase( SECTION, "\\016", String.fromCharCode(0x000E), "\016" ); - array[item++] = new TestCase( SECTION, "\\017", String.fromCharCode(0x000F), "\017" ); - array[item++] = new TestCase( SECTION, "\\020", String.fromCharCode(0x0010), "\020" ); - array[item++] = new TestCase( SECTION, "\\042", String.fromCharCode(0x0022), "\042" ); +new TestCase( SECTION, "\\10", String.fromCharCode(0x0008), "\10" ); +new TestCase( SECTION, "\\11", String.fromCharCode(0x0009), "\11" ); +new TestCase( SECTION, "\\12", String.fromCharCode(0x000A), "\12" ); +new TestCase( SECTION, "\\13", String.fromCharCode(0x000B), "\13" ); +new TestCase( SECTION, "\\14", String.fromCharCode(0x000C), "\14" ); +new TestCase( SECTION, "\\15", String.fromCharCode(0x000D), "\15" ); +new TestCase( SECTION, "\\16", String.fromCharCode(0x000E), "\16" ); +new TestCase( SECTION, "\\17", String.fromCharCode(0x000F), "\17" ); +new TestCase( SECTION, "\\20", String.fromCharCode(0x0010), "\20" ); +new TestCase( SECTION, "\\42", String.fromCharCode(0x0022), "\42" ); - array[item++] = new TestCase( SECTION, "\\0", String.fromCharCode(0x0000), "\0" ); - array[item++] = new TestCase( SECTION, "\\1", String.fromCharCode(0x0001), "\1" ); - array[item++] = new TestCase( SECTION, "\\2", String.fromCharCode(0x0002), "\2" ); - array[item++] = new TestCase( SECTION, "\\3", String.fromCharCode(0x0003), "\3" ); - array[item++] = new TestCase( SECTION, "\\4", String.fromCharCode(0x0004), "\4" ); - array[item++] = new TestCase( SECTION, "\\5", String.fromCharCode(0x0005), "\5" ); - array[item++] = new TestCase( SECTION, "\\6", String.fromCharCode(0x0006), "\6" ); - array[item++] = new TestCase( SECTION, "\\7", String.fromCharCode(0x0007), "\7" ); - - array[item++] = new TestCase( SECTION, "\\10", String.fromCharCode(0x0008), "\10" ); - array[item++] = new TestCase( SECTION, "\\11", String.fromCharCode(0x0009), "\11" ); - array[item++] = new TestCase( SECTION, "\\12", String.fromCharCode(0x000A), "\12" ); - array[item++] = new TestCase( SECTION, "\\13", String.fromCharCode(0x000B), "\13" ); - array[item++] = new TestCase( SECTION, "\\14", String.fromCharCode(0x000C), "\14" ); - array[item++] = new TestCase( SECTION, "\\15", String.fromCharCode(0x000D), "\15" ); - array[item++] = new TestCase( SECTION, "\\16", String.fromCharCode(0x000E), "\16" ); - array[item++] = new TestCase( SECTION, "\\17", String.fromCharCode(0x000F), "\17" ); - array[item++] = new TestCase( SECTION, "\\20", String.fromCharCode(0x0010), "\20" ); - array[item++] = new TestCase( SECTION, "\\42", String.fromCharCode(0x0022), "\42" ); - - array[item++] = new TestCase( SECTION, "\\000", String.fromCharCode(0), "\000" ); - array[item++] = new TestCase( SECTION, "\\111", String.fromCharCode(73), "\111" ); - array[item++] = new TestCase( SECTION, "\\222", String.fromCharCode(146), "\222" ); - array[item++] = new TestCase( SECTION, "\\333", String.fromCharCode(219), "\333" ); +new TestCase( SECTION, "\\000", String.fromCharCode(0), "\000" ); +new TestCase( SECTION, "\\111", String.fromCharCode(73), "\111" ); +new TestCase( SECTION, "\\222", String.fromCharCode(146), "\222" ); +new TestCase( SECTION, "\\333", String.fromCharCode(219), "\333" ); // following line commented out as it causes a compile time error -// array[item++] = new TestCase( SECTION, "\\444", "444", "\444" ); +// new TestCase( SECTION, "\\444", "444", "\444" ); - // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::HexEscapeSequence +// DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::HexEscapeSequence /* - array[item++] = new TestCase( SECTION, "\\x0", String.fromCharCode(0), "\x0" ); - array[item++] = new TestCase( SECTION, "\\x1", String.fromCharCode(1), "\x1" ); - array[item++] = new TestCase( SECTION, "\\x2", String.fromCharCode(2), "\x2" ); - array[item++] = new TestCase( SECTION, "\\x3", String.fromCharCode(3), "\x3" ); - array[item++] = new TestCase( SECTION, "\\x4", String.fromCharCode(4), "\x4" ); - array[item++] = new TestCase( SECTION, "\\x5", String.fromCharCode(5), "\x5" ); - array[item++] = new TestCase( SECTION, "\\x6", String.fromCharCode(6), "\x6" ); - array[item++] = new TestCase( SECTION, "\\x7", String.fromCharCode(7), "\x7" ); - array[item++] = new TestCase( SECTION, "\\x8", String.fromCharCode(8), "\x8" ); - array[item++] = new TestCase( SECTION, "\\x9", String.fromCharCode(9), "\x9" ); - array[item++] = new TestCase( SECTION, "\\xA", String.fromCharCode(10), "\xA" ); - array[item++] = new TestCase( SECTION, "\\xB", String.fromCharCode(11), "\xB" ); - array[item++] = new TestCase( SECTION, "\\xC", String.fromCharCode(12), "\xC" ); - array[item++] = new TestCase( SECTION, "\\xD", String.fromCharCode(13), "\xD" ); - array[item++] = new TestCase( SECTION, "\\xE", String.fromCharCode(14), "\xE" ); - array[item++] = new TestCase( SECTION, "\\xF", String.fromCharCode(15), "\xF" ); + new TestCase( SECTION, "\\x0", String.fromCharCode(0), "\x0" ); + new TestCase( SECTION, "\\x1", String.fromCharCode(1), "\x1" ); + new TestCase( SECTION, "\\x2", String.fromCharCode(2), "\x2" ); + new TestCase( SECTION, "\\x3", String.fromCharCode(3), "\x3" ); + new TestCase( SECTION, "\\x4", String.fromCharCode(4), "\x4" ); + new TestCase( SECTION, "\\x5", String.fromCharCode(5), "\x5" ); + new TestCase( SECTION, "\\x6", String.fromCharCode(6), "\x6" ); + new TestCase( SECTION, "\\x7", String.fromCharCode(7), "\x7" ); + new TestCase( SECTION, "\\x8", String.fromCharCode(8), "\x8" ); + new TestCase( SECTION, "\\x9", String.fromCharCode(9), "\x9" ); + new TestCase( SECTION, "\\xA", String.fromCharCode(10), "\xA" ); + new TestCase( SECTION, "\\xB", String.fromCharCode(11), "\xB" ); + new TestCase( SECTION, "\\xC", String.fromCharCode(12), "\xC" ); + new TestCase( SECTION, "\\xD", String.fromCharCode(13), "\xD" ); + new TestCase( SECTION, "\\xE", String.fromCharCode(14), "\xE" ); + new TestCase( SECTION, "\\xF", String.fromCharCode(15), "\xF" ); */ - array[item++] = new TestCase( SECTION, "\\xF0", String.fromCharCode(240), "\xF0" ); - array[item++] = new TestCase( SECTION, "\\xE1", String.fromCharCode(225), "\xE1" ); - array[item++] = new TestCase( SECTION, "\\xD2", String.fromCharCode(210), "\xD2" ); - array[item++] = new TestCase( SECTION, "\\xC3", String.fromCharCode(195), "\xC3" ); - array[item++] = new TestCase( SECTION, "\\xB4", String.fromCharCode(180), "\xB4" ); - array[item++] = new TestCase( SECTION, "\\xA5", String.fromCharCode(165), "\xA5" ); - array[item++] = new TestCase( SECTION, "\\x96", String.fromCharCode(150), "\x96" ); - array[item++] = new TestCase( SECTION, "\\x87", String.fromCharCode(135), "\x87" ); - array[item++] = new TestCase( SECTION, "\\x78", String.fromCharCode(120), "\x78" ); - array[item++] = new TestCase( SECTION, "\\x69", String.fromCharCode(105), "\x69" ); - array[item++] = new TestCase( SECTION, "\\x5A", String.fromCharCode(90), "\x5A" ); - array[item++] = new TestCase( SECTION, "\\x4B", String.fromCharCode(75), "\x4B" ); - array[item++] = new TestCase( SECTION, "\\x3C", String.fromCharCode(60), "\x3C" ); - array[item++] = new TestCase( SECTION, "\\x2D", String.fromCharCode(45), "\x2D" ); - array[item++] = new TestCase( SECTION, "\\x1E", String.fromCharCode(30), "\x1E" ); - array[item++] = new TestCase( SECTION, "\\x0F", String.fromCharCode(15), "\x0F" ); +new TestCase( SECTION, "\\xF0", String.fromCharCode(240), "\xF0" ); +new TestCase( SECTION, "\\xE1", String.fromCharCode(225), "\xE1" ); +new TestCase( SECTION, "\\xD2", String.fromCharCode(210), "\xD2" ); +new TestCase( SECTION, "\\xC3", String.fromCharCode(195), "\xC3" ); +new TestCase( SECTION, "\\xB4", String.fromCharCode(180), "\xB4" ); +new TestCase( SECTION, "\\xA5", String.fromCharCode(165), "\xA5" ); +new TestCase( SECTION, "\\x96", String.fromCharCode(150), "\x96" ); +new TestCase( SECTION, "\\x87", String.fromCharCode(135), "\x87" ); +new TestCase( SECTION, "\\x78", String.fromCharCode(120), "\x78" ); +new TestCase( SECTION, "\\x69", String.fromCharCode(105), "\x69" ); +new TestCase( SECTION, "\\x5A", String.fromCharCode(90), "\x5A" ); +new TestCase( SECTION, "\\x4B", String.fromCharCode(75), "\x4B" ); +new TestCase( SECTION, "\\x3C", String.fromCharCode(60), "\x3C" ); +new TestCase( SECTION, "\\x2D", String.fromCharCode(45), "\x2D" ); +new TestCase( SECTION, "\\x1E", String.fromCharCode(30), "\x1E" ); +new TestCase( SECTION, "\\x0F", String.fromCharCode(15), "\x0F" ); - // string literals only take up to two hext digits. therefore, the third character in this string - // should be interpreted as a StringCharacter and not part of the HextEscapeSequence +// string literals only take up to two hext digits. therefore, the third character in this string +// should be interpreted as a StringCharacter and not part of the HextEscapeSequence - array[item++] = new TestCase( SECTION, "\\xF0F", String.fromCharCode(240)+"F", "\xF0F" ); - array[item++] = new TestCase( SECTION, "\\xE1E", String.fromCharCode(225)+"E", "\xE1E" ); - array[item++] = new TestCase( SECTION, "\\xD2D", String.fromCharCode(210)+"D", "\xD2D" ); - array[item++] = new TestCase( SECTION, "\\xC3C", String.fromCharCode(195)+"C", "\xC3C" ); - array[item++] = new TestCase( SECTION, "\\xB4B", String.fromCharCode(180)+"B", "\xB4B" ); - array[item++] = new TestCase( SECTION, "\\xA5A", String.fromCharCode(165)+"A", "\xA5A" ); - array[item++] = new TestCase( SECTION, "\\x969", String.fromCharCode(150)+"9", "\x969" ); - array[item++] = new TestCase( SECTION, "\\x878", String.fromCharCode(135)+"8", "\x878" ); - array[item++] = new TestCase( SECTION, "\\x787", String.fromCharCode(120)+"7", "\x787" ); - array[item++] = new TestCase( SECTION, "\\x696", String.fromCharCode(105)+"6", "\x696" ); - array[item++] = new TestCase( SECTION, "\\x5A5", String.fromCharCode(90)+"5", "\x5A5" ); - array[item++] = new TestCase( SECTION, "\\x4B4", String.fromCharCode(75)+"4", "\x4B4" ); - array[item++] = new TestCase( SECTION, "\\x3C3", String.fromCharCode(60)+"3", "\x3C3" ); - array[item++] = new TestCase( SECTION, "\\x2D2", String.fromCharCode(45)+"2", "\x2D2" ); - array[item++] = new TestCase( SECTION, "\\x1E1", String.fromCharCode(30)+"1", "\x1E1" ); - array[item++] = new TestCase( SECTION, "\\x0F0", String.fromCharCode(15)+"0", "\x0F0" ); +new TestCase( SECTION, "\\xF0F", String.fromCharCode(240)+"F", "\xF0F" ); +new TestCase( SECTION, "\\xE1E", String.fromCharCode(225)+"E", "\xE1E" ); +new TestCase( SECTION, "\\xD2D", String.fromCharCode(210)+"D", "\xD2D" ); +new TestCase( SECTION, "\\xC3C", String.fromCharCode(195)+"C", "\xC3C" ); +new TestCase( SECTION, "\\xB4B", String.fromCharCode(180)+"B", "\xB4B" ); +new TestCase( SECTION, "\\xA5A", String.fromCharCode(165)+"A", "\xA5A" ); +new TestCase( SECTION, "\\x969", String.fromCharCode(150)+"9", "\x969" ); +new TestCase( SECTION, "\\x878", String.fromCharCode(135)+"8", "\x878" ); +new TestCase( SECTION, "\\x787", String.fromCharCode(120)+"7", "\x787" ); +new TestCase( SECTION, "\\x696", String.fromCharCode(105)+"6", "\x696" ); +new TestCase( SECTION, "\\x5A5", String.fromCharCode(90)+"5", "\x5A5" ); +new TestCase( SECTION, "\\x4B4", String.fromCharCode(75)+"4", "\x4B4" ); +new TestCase( SECTION, "\\x3C3", String.fromCharCode(60)+"3", "\x3C3" ); +new TestCase( SECTION, "\\x2D2", String.fromCharCode(45)+"2", "\x2D2" ); +new TestCase( SECTION, "\\x1E1", String.fromCharCode(30)+"1", "\x1E1" ); +new TestCase( SECTION, "\\x0F0", String.fromCharCode(15)+"0", "\x0F0" ); - // G is out of hex range +// G is out of hex range - array[item++] = new TestCase( SECTION, "\\xG", "xG", "\xG" ); - array[item++] = new TestCase( SECTION, "\\xCG", "xCG", "\xCG" ); +new TestCase( SECTION, "\\xG", "xG", "\xG" ); +new TestCase( SECTION, "\\xCG", "xCG", "\xCG" ); - // DoubleStringCharacter::EscapeSequence::CharacterEscapeSequence::\ NonEscapeCharacter - array[item++] = new TestCase( SECTION, "\\a", "a", "\a" ); - array[item++] = new TestCase( SECTION, "\\c", "c", "\c" ); - array[item++] = new TestCase( SECTION, "\\d", "d", "\d" ); - array[item++] = new TestCase( SECTION, "\\e", "e", "\e" ); - array[item++] = new TestCase( SECTION, "\\g", "g", "\g" ); - array[item++] = new TestCase( SECTION, "\\h", "h", "\h" ); - array[item++] = new TestCase( SECTION, "\\i", "i", "\i" ); - array[item++] = new TestCase( SECTION, "\\j", "j", "\j" ); - array[item++] = new TestCase( SECTION, "\\k", "k", "\k" ); - array[item++] = new TestCase( SECTION, "\\l", "l", "\l" ); - array[item++] = new TestCase( SECTION, "\\m", "m", "\m" ); - array[item++] = new TestCase( SECTION, "\\o", "o", "\o" ); - array[item++] = new TestCase( SECTION, "\\p", "p", "\p" ); - array[item++] = new TestCase( SECTION, "\\q", "q", "\q" ); - array[item++] = new TestCase( SECTION, "\\s", "s", "\s" ); - array[item++] = new TestCase( SECTION, "\\u", "u", "\u" ); +// DoubleStringCharacter::EscapeSequence::CharacterEscapeSequence::\ NonEscapeCharacter +new TestCase( SECTION, "\\a", "a", "\a" ); +new TestCase( SECTION, "\\c", "c", "\c" ); +new TestCase( SECTION, "\\d", "d", "\d" ); +new TestCase( SECTION, "\\e", "e", "\e" ); +new TestCase( SECTION, "\\g", "g", "\g" ); +new TestCase( SECTION, "\\h", "h", "\h" ); +new TestCase( SECTION, "\\i", "i", "\i" ); +new TestCase( SECTION, "\\j", "j", "\j" ); +new TestCase( SECTION, "\\k", "k", "\k" ); +new TestCase( SECTION, "\\l", "l", "\l" ); +new TestCase( SECTION, "\\m", "m", "\m" ); +new TestCase( SECTION, "\\o", "o", "\o" ); +new TestCase( SECTION, "\\p", "p", "\p" ); +new TestCase( SECTION, "\\q", "q", "\q" ); +new TestCase( SECTION, "\\s", "s", "\s" ); +new TestCase( SECTION, "\\u", "u", "\u" ); - array[item++] = new TestCase( SECTION, "\\w", "w", "\w" ); - array[item++] = new TestCase( SECTION, "\\x", "x", "\x" ); - array[item++] = new TestCase( SECTION, "\\y", "y", "\y" ); - array[item++] = new TestCase( SECTION, "\\z", "z", "\z" ); - array[item++] = new TestCase( SECTION, "\\9", "9", "\9" ); +new TestCase( SECTION, "\\w", "w", "\w" ); +new TestCase( SECTION, "\\x", "x", "\x" ); +new TestCase( SECTION, "\\y", "y", "\y" ); +new TestCase( SECTION, "\\z", "z", "\z" ); +new TestCase( SECTION, "\\9", "9", "\9" ); - array[item++] = new TestCase( SECTION, "\\A", "A", "\A" ); - array[item++] = new TestCase( SECTION, "\\B", "B", "\B" ); - array[item++] = new TestCase( SECTION, "\\C", "C", "\C" ); - array[item++] = new TestCase( SECTION, "\\D", "D", "\D" ); - array[item++] = new TestCase( SECTION, "\\E", "E", "\E" ); - array[item++] = new TestCase( SECTION, "\\F", "F", "\F" ); - array[item++] = new TestCase( SECTION, "\\G", "G", "\G" ); - array[item++] = new TestCase( SECTION, "\\H", "H", "\H" ); - array[item++] = new TestCase( SECTION, "\\I", "I", "\I" ); - array[item++] = new TestCase( SECTION, "\\J", "J", "\J" ); - array[item++] = new TestCase( SECTION, "\\K", "K", "\K" ); - array[item++] = new TestCase( SECTION, "\\L", "L", "\L" ); - array[item++] = new TestCase( SECTION, "\\M", "M", "\M" ); - array[item++] = new TestCase( SECTION, "\\N", "N", "\N" ); - array[item++] = new TestCase( SECTION, "\\O", "O", "\O" ); - array[item++] = new TestCase( SECTION, "\\P", "P", "\P" ); - array[item++] = new TestCase( SECTION, "\\Q", "Q", "\Q" ); - array[item++] = new TestCase( SECTION, "\\R", "R", "\R" ); - array[item++] = new TestCase( SECTION, "\\S", "S", "\S" ); - array[item++] = new TestCase( SECTION, "\\T", "T", "\T" ); - array[item++] = new TestCase( SECTION, "\\U", "U", "\U" ); - array[item++] = new TestCase( SECTION, "\\V", "V", "\V" ); - array[item++] = new TestCase( SECTION, "\\W", "W", "\W" ); - array[item++] = new TestCase( SECTION, "\\X", "X", "\X" ); - array[item++] = new TestCase( SECTION, "\\Y", "Y", "\Y" ); - array[item++] = new TestCase( SECTION, "\\Z", "Z", "\Z" ); +new TestCase( SECTION, "\\A", "A", "\A" ); +new TestCase( SECTION, "\\B", "B", "\B" ); +new TestCase( SECTION, "\\C", "C", "\C" ); +new TestCase( SECTION, "\\D", "D", "\D" ); +new TestCase( SECTION, "\\E", "E", "\E" ); +new TestCase( SECTION, "\\F", "F", "\F" ); +new TestCase( SECTION, "\\G", "G", "\G" ); +new TestCase( SECTION, "\\H", "H", "\H" ); +new TestCase( SECTION, "\\I", "I", "\I" ); +new TestCase( SECTION, "\\J", "J", "\J" ); +new TestCase( SECTION, "\\K", "K", "\K" ); +new TestCase( SECTION, "\\L", "L", "\L" ); +new TestCase( SECTION, "\\M", "M", "\M" ); +new TestCase( SECTION, "\\N", "N", "\N" ); +new TestCase( SECTION, "\\O", "O", "\O" ); +new TestCase( SECTION, "\\P", "P", "\P" ); +new TestCase( SECTION, "\\Q", "Q", "\Q" ); +new TestCase( SECTION, "\\R", "R", "\R" ); +new TestCase( SECTION, "\\S", "S", "\S" ); +new TestCase( SECTION, "\\T", "T", "\T" ); +new TestCase( SECTION, "\\U", "U", "\U" ); +new TestCase( SECTION, "\\V", "V", "\V" ); +new TestCase( SECTION, "\\W", "W", "\W" ); +new TestCase( SECTION, "\\X", "X", "\X" ); +new TestCase( SECTION, "\\Y", "Y", "\Y" ); +new TestCase( SECTION, "\\Z", "Z", "\Z" ); - // DoubleStringCharacter::EscapeSequence::UnicodeEscapeSequence +// DoubleStringCharacter::EscapeSequence::UnicodeEscapeSequence - array[item++] = new TestCase( SECTION, "\\u0020", " ", "\u0020" ); - array[item++] = new TestCase( SECTION, "\\u0021", "!", "\u0021" ); - array[item++] = new TestCase( SECTION, "\\u0022", "\"", "\u0022" ); - array[item++] = new TestCase( SECTION, "\\u0023", "#", "\u0023" ); - array[item++] = new TestCase( SECTION, "\\u0024", "$", "\u0024" ); - array[item++] = new TestCase( SECTION, "\\u0025", "%", "\u0025" ); - array[item++] = new TestCase( SECTION, "\\u0026", "&", "\u0026" ); - array[item++] = new TestCase( SECTION, "\\u0027", "'", "\u0027" ); - array[item++] = new TestCase( SECTION, "\\u0028", "(", "\u0028" ); - array[item++] = new TestCase( SECTION, "\\u0029", ")", "\u0029" ); - array[item++] = new TestCase( SECTION, "\\u002A", "*", "\u002A" ); - array[item++] = new TestCase( SECTION, "\\u002B", "+", "\u002B" ); - array[item++] = new TestCase( SECTION, "\\u002C", ",", "\u002C" ); - array[item++] = new TestCase( SECTION, "\\u002D", "-", "\u002D" ); - array[item++] = new TestCase( SECTION, "\\u002E", ".", "\u002E" ); - array[item++] = new TestCase( SECTION, "\\u002F", "/", "\u002F" ); - array[item++] = new TestCase( SECTION, "\\u0030", "0", "\u0030" ); - array[item++] = new TestCase( SECTION, "\\u0031", "1", "\u0031" ); - array[item++] = new TestCase( SECTION, "\\u0032", "2", "\u0032" ); - array[item++] = new TestCase( SECTION, "\\u0033", "3", "\u0033" ); - array[item++] = new TestCase( SECTION, "\\u0034", "4", "\u0034" ); - array[item++] = new TestCase( SECTION, "\\u0035", "5", "\u0035" ); - array[item++] = new TestCase( SECTION, "\\u0036", "6", "\u0036" ); - array[item++] = new TestCase( SECTION, "\\u0037", "7", "\u0037" ); - array[item++] = new TestCase( SECTION, "\\u0038", "8", "\u0038" ); - array[item++] = new TestCase( SECTION, "\\u0039", "9", "\u0039" ); +new TestCase( SECTION, "\\u0020", " ", "\u0020" ); +new TestCase( SECTION, "\\u0021", "!", "\u0021" ); +new TestCase( SECTION, "\\u0022", "\"", "\u0022" ); +new TestCase( SECTION, "\\u0023", "#", "\u0023" ); +new TestCase( SECTION, "\\u0024", "$", "\u0024" ); +new TestCase( SECTION, "\\u0025", "%", "\u0025" ); +new TestCase( SECTION, "\\u0026", "&", "\u0026" ); +new TestCase( SECTION, "\\u0027", "'", "\u0027" ); +new TestCase( SECTION, "\\u0028", "(", "\u0028" ); +new TestCase( SECTION, "\\u0029", ")", "\u0029" ); +new TestCase( SECTION, "\\u002A", "*", "\u002A" ); +new TestCase( SECTION, "\\u002B", "+", "\u002B" ); +new TestCase( SECTION, "\\u002C", ",", "\u002C" ); +new TestCase( SECTION, "\\u002D", "-", "\u002D" ); +new TestCase( SECTION, "\\u002E", ".", "\u002E" ); +new TestCase( SECTION, "\\u002F", "/", "\u002F" ); +new TestCase( SECTION, "\\u0030", "0", "\u0030" ); +new TestCase( SECTION, "\\u0031", "1", "\u0031" ); +new TestCase( SECTION, "\\u0032", "2", "\u0032" ); +new TestCase( SECTION, "\\u0033", "3", "\u0033" ); +new TestCase( SECTION, "\\u0034", "4", "\u0034" ); +new TestCase( SECTION, "\\u0035", "5", "\u0035" ); +new TestCase( SECTION, "\\u0036", "6", "\u0036" ); +new TestCase( SECTION, "\\u0037", "7", "\u0037" ); +new TestCase( SECTION, "\\u0038", "8", "\u0038" ); +new TestCase( SECTION, "\\u0039", "9", "\u0039" ); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = testcases[tc].actual; - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/7.8.2-n.js b/mozilla/js/tests/ecma/LexicalConventions/7.8.2-n.js index a7ef5757ea1..b2239b0f68f 100644 --- a/mozilla/js/tests/ecma/LexicalConventions/7.8.2-n.js +++ b/mozilla/js/tests/ecma/LexicalConventions/7.8.2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,29 +36,25 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 7.8.2.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 + File Name: 7.8.2.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION="7.8.2"; - var VERSION="ECMA_1" - startTest(); - writeHeaderToLog(SECTION+" "+"Examples of Semicolon Insertion"); +var SECTION="7.8.2"; +var VERSION="ECMA_1" +startTest(); +writeHeaderToLog(SECTION+" "+"Examples of Semicolon Insertion"); - testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +// new TestCase( "7.8.2", "{ 1 \n 2 } 3", 3, eval("{ 1 \n 2 } 3") ); -// array[item++] = new TestCase( "7.8.2", "{ 1 \n 2 } 3", 3, "{ 1 \n 2 } 3" ); - array[item++] = new TestCase( "7.8.2", "{ 1 2 } 3", "error", eval("{1 2 } 3") ); +DESCRIPTION = "{ 1 2 } 3"; +EXPECTED = "error"; - return ( array ); -} +new TestCase( "7.8.2", "{ 1 2 } 3", "error", eval("{1 2 } 3") ); +test(); diff --git a/mozilla/js/tests/ecma/LexicalConventions/browser.js b/mozilla/js/tests/ecma/LexicalConventions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/LexicalConventions/shell.js b/mozilla/js/tests/ecma/LexicalConventions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Math/15.8-1.js b/mozilla/js/tests/ecma/Math/15.8-1.js index 8e132c8c5ed..646fc548494 100644 --- a/mozilla/js/tests/ecma/Math/15.8-1.js +++ b/mozilla/js/tests/ecma/Math/15.8-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,66 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8-1.js - ECMA Section: 15.8 The Math Object - - Description: - - The Math object is merely a single object that has some named properties, - some of which are functions. - - The value of the internal [[Prototype]] property of the Math object is the - Object prototype object (15.2.3.1). - - The Math object does not have a [[Construct]] property; it is not possible - to use the Math object as a constructor with the new operator. - - The Math object does not have a [[Call]] property; it is not possible to - invoke the Math object as a function. - - Recall that, in this specification, the phrase "the number value for x" has - a technical meaning defined in section 8.5. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ - - var SECTION = "15.8-1"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "The Math Object"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "Math.__proto__ == Object.prototype", - true, - Math.__proto__ == Object.prototype ); - - array[item++] = new TestCase( SECTION, - "Math.__proto__", - Object.prototype, - Math.__proto__ ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8-1.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + +var SECTION = "15.8-1"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "The Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.__proto__ == Object.prototype", + true, + Math.__proto__ == Object.prototype ); + +new TestCase( SECTION, + "Math.__proto__", + Object.prototype, + Math.__proto__ ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8-2-n.js b/mozilla/js/tests/ecma/Math/15.8-2-n.js index b0af8149fec..2aec243ecb6 100644 --- a/mozilla/js/tests/ecma/Math/15.8-2-n.js +++ b/mozilla/js/tests/ecma/Math/15.8-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,45 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8-2.js - ECMA Section: 15.8 The Math Object - - Description: - - The Math object is merely a single object that has some named properties, - some of which are functions. - - The value of the internal [[Prototype]] property of the Math object is the - Object prototype object (15.2.3.1). - - The Math object does not have a [[Construct]] property; it is not possible - to use the Math object as a constructor with the new operator. - - The Math object does not have a [[Call]] property; it is not possible to - invoke the Math object as a function. - - Recall that, in this specification, the phrase "the number value for x" has - a technical meaning defined in section 8.5. - - Author: christine@netscape.com - Date: 12 november 1997 - -*/ - - var SECTION = "15.8-2-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Math Object"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "MYMATH = new Math()", - "error", - "MYMATH = new Math()" ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += "Math does not have the [Construct] property"; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8-2.js + ECMA Section: 15.8 The Math Object + + Description: + + The Math object is merely a single object that has some named properties, + some of which are functions. + + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). + + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. + + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. + + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + +var SECTION = "15.8-2-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Math Object"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "MYMATH = new Math()"; +EXPECTED = "error"; + +new TestCase( SECTION, + "MYMATH = new Math()", + "error", + eval("MYMATH = new Math()") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8-3-n.js b/mozilla/js/tests/ecma/Math/15.8-3-n.js index a532bc26088..8efdcae6f43 100644 --- a/mozilla/js/tests/ecma/Math/15.8-3-n.js +++ b/mozilla/js/tests/ecma/Math/15.8-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,63 +35,45 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8-3.js - ECMA Section: 15.8 The Math Object + File Name: 15.8-3.js + ECMA Section: 15.8 The Math Object - Description: + Description: - The Math object is merely a single object that has some named properties, - some of which are functions. + The Math object is merely a single object that has some named properties, + some of which are functions. - The value of the internal [[Prototype]] property of the Math object is the - Object prototype object (15.2.3.1). + The value of the internal [[Prototype]] property of the Math object is the + Object prototype object (15.2.3.1). - The Math object does not have a [[Construct]] property; it is not possible - to use the Math object as a constructor with the new operator. + The Math object does not have a [[Construct]] property; it is not possible + to use the Math object as a constructor with the new operator. - The Math object does not have a [[Call]] property; it is not possible to - invoke the Math object as a function. + The Math object does not have a [[Call]] property; it is not possible to + invoke the Math object as a function. - Recall that, in this specification, the phrase "the number value for x" has - a technical meaning defined in section 8.5. + Recall that, in this specification, the phrase "the number value for x" has + a technical meaning defined in section 8.5. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.8-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Math Object"; +var SECTION = "15.8-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Math Object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "MYMATH = Math()"; +EXPECTED = "error"; -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "MYMATH = Math()", - "error", - "MYMATH = Math()" ); +new TestCase( SECTION, + "MYMATH = Math()", + "error", + eval("MYMATH = Math()") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += "Math does not have the [Call] property"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.1-1.js b/mozilla/js/tests/ecma/Math/15.8.1.1-1.js index 1df7a75cead..b59d5da183a 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.1-1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,44 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.1-1.js - ECMA Section: 15.8.1.1.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the ReadOnly attribute of Math.E - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - var SECTION = "15.8.1.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.E"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Math.E = 0; Math.E", 2.7182818284590452354, ("Math.E=0;Math.E") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "Math.E should be read-only "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.1.1-1.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.E = 0; Math.E", + 2.7182818284590452354, + eval("Math.E=0;Math.E") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.1-2.js b/mozilla/js/tests/ecma/Math/15.8.1.1-2.js index 7714bed39a1..c0ea39e5889 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.1-2.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.1.1-2.js - ECMA Section: 15.8.1.1.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.8.1.1-2.js + ECMA Section: 15.8.1.1.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Math.E + this test checks the DontDelete attribute of Math.E - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.8.1.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.E"; +var SECTION = "15.8.1.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.E"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var MATH_E = 2.7182818284590452354 +new TestCase( SECTION, + "delete(Math.E)", + false, + eval("delete Math.E") ); +new TestCase( SECTION, + "delete(Math.E); Math.E", + MATH_E, + eval("delete Math.E; Math.E") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - var MATH_E = 2.7182818284590452354 - array[item++] = new TestCase( SECTION, "delete(Math.E)", false, "delete Math.E" ); - array[item++] = new TestCase( SECTION, "delete(Math.E); Math.E", MATH_E, "delete Math.E; Math.E" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "should not be able to delete property"; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.2-1.js b/mozilla/js/tests/ecma/Math/15.8.1.2-1.js index 4469312b74c..5b882c2aaaf 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.2-1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,44 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.2-1.js - ECMA Section: 15.8.2.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the ReadOnly attribute of Math.LN10 - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - var SECTION = "15.8.1.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.LN10"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Math.LN10=0; Math.LN10", 2.302585092994046, "Math.LN10=0; Math.LN10" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN10 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN10"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LN10=0; Math.LN10", + 2.302585092994046, + eval("Math.LN10=0; Math.LN10") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.2-2.js b/mozilla/js/tests/ecma/Math/15.8.1.2-2.js index ff2e5be6986..5ce67a21e3c 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.2-2.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.1.2-1.js - ECMA Section: 15.8.2.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.8.1.2-1.js + ECMA Section: 15.8.2.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Math.LN10 + this test checks the DontDelete attribute of Math.LN10 - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.8.1.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.LN10"; +var SECTION = "15.8.1.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN10"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete( Math.LN10 ); Math.LN10", 2.302585092994046, "delete(Math.LN10); Math.LN10" ); - array[item++] = new TestCase( SECTION, "delete( Math.LN10 ); ", false, "delete(Math.LN10)" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "delete( Math.LN10 ); Math.LN10", + 2.302585092994046, + eval("delete(Math.LN10); Math.LN10") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "delete( Math.LN10 ); ", + false, + eval("delete(Math.LN10)") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.3-1.js b/mozilla/js/tests/ecma/Math/15.8.1.3-1.js index 7cc718c323a..61f30736c59 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.3-1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.3-1.js - ECMA Section: 15.8.1.3.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the ReadOnly attribute of Math.LN2 - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - - var SECTION = "15.8.1.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.LN2"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Math.LN2=0; Math.LN2", 0.6931471805599453, ("Math.LN2=0; Math.LN2") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.1.3-1.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LN2=0; Math.LN2", + 0.6931471805599453, + eval("Math.LN2=0; Math.LN2") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.3-2.js b/mozilla/js/tests/ecma/Math/15.8.1.3-2.js index 23673a112b3..ac4154bb24d 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.3-2.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,51 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.3-3.js - ECMA Section: 15.8.1.3.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the DontDelete attribute of Math.LN2 - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - - var SECTION = "15.8.1.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.LN2"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - - var MATH_LN2 = 0.6931471805599453; - - array[item++] = new TestCase( SECTION, "delete(Math.LN2)", false, "delete(Math.LN2)" ); - array[item++] = new TestCase( SECTION, "delete(Math.LN2); Math.LN2", MATH_LN2, "delete(Math.LN2); Math.LN2" ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.1.3-3.js + ECMA Section: 15.8.1.3.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LN2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LN2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var MATH_LN2 = 0.6931471805599453; + +new TestCase( SECTION, + "delete(Math.LN2)", + false, + eval("delete(Math.LN2)") ); + +new TestCase( SECTION, + "delete(Math.LN2); Math.LN2", + MATH_LN2, + eval("delete(Math.LN2); Math.LN2") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.4-1.js b/mozilla/js/tests/ecma/Math/15.8.1.4-1.js index de9a24d76f2..04286a27192 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.4-1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 15.8.1.4-1.js ECMA Section: 15.8.1.4.js @@ -53,27 +55,9 @@ writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Math.L0G2E=0; Math.LOG2E", 1.4426950408889634, ("Math.LOG2E=0; Math.LOG2E") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.L0G2E=0; Math.LOG2E", + 1.4426950408889634, + eval("Math.LOG2E=0; Math.LOG2E") ); +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.4-2.js b/mozilla/js/tests/ecma/Math/15.8.1.4-2.js index ce23b02e328..001077fc1d1 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.4-2.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.4-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,32 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.4-2.js - ECMA Section: 15.8.1.4.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the DontDelete attribute of Math.LOG2E - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - - var SECTION = "15.8.1.4-2"; - var VERSION = "ECMA_1"; +/** + File Name: 15.8.1.4-2.js + ECMA Section: 15.8.1.4.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.LOG2E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + var SECTION = "15.8.1.4-2"; + var VERSION = "ECMA_1"; startTest(); - var TITLE = "Math.LOG2E"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete(Math.L0G2E);Math.LOG2E", 1.4426950408889634, "delete(Math.LOG2E);Math.LOG2E" ); - array[item++] = new TestCase( SECTION, "delete(Math.L0G2E)", false, "delete(Math.LOG2E)" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} - + var TITLE = "Math.LOG2E"; + + writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete(Math.L0G2E);Math.LOG2E", + 1.4426950408889634, + eval("delete(Math.LOG2E);Math.LOG2E") ); +new TestCase( SECTION, + "delete(Math.L0G2E)", + false, + eval("delete(Math.LOG2E)") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.5-1.js b/mozilla/js/tests/ecma/Math/15.8.1.5-1.js index 5d7379c3f4a..e138e81b031 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.5-1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.5-1.js - ECMA Section: 15.8.1.5.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the ReadOnly attribute of Math.LOG10E - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - - - var SECTION = "15.8.1.5-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.LOG10E"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - - - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Math.LOG10E=0; Math.LOG10E", 0.4342944819032518, ("Math.LOG10E=0; Math.LOG10E") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} - +/** + File Name: 15.8.1.5-1.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.LOG10E + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + + +var SECTION = "15.8.1.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG10E"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.LOG10E=0; Math.LOG10E", + 0.4342944819032518, + eval("Math.LOG10E=0; Math.LOG10E") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.5-2.js b/mozilla/js/tests/ecma/Math/15.8.1.5-2.js index d36a386eda3..d719c033997 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.5-2.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.1.5-2.js - ECMA Section: 15.8.1.5.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.8.1.5-2.js + ECMA Section: 15.8.1.5.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Math.LOG10E + this test checks the DontDelete attribute of Math.LOG10E - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.8.1.5-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.LOG10E"; +var SECTION = "15.8.1.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.LOG10E"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "delete Math.LOG10E; Math.LOG10E", + 0.4342944819032518, + eval("delete Math.LOG10E; Math.LOG10E") ); +new TestCase( SECTION, + "delete Math.LOG10E", + false, + eval("delete Math.LOG10E") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete Math.LOG10E; Math.LOG10E", 0.4342944819032518, "delete Math.LOG10E; Math.LOG10E" ); - array[item++] = new TestCase( SECTION, "delete Math.LOG10E", false, "delete Math.LOG10E" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} - +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.6-1.js b/mozilla/js/tests/ecma/Math/15.8.1.6-1.js index 21b9690d3f9..1da0f911bc9 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.6-1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.6-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.6-1.js - ECMA Section: 15.8.1.6.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the ReadOnly attribute of Math.PI - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - - var SECTION = "15.8.1.6-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.PI"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Math.PI=0; Math.PI", 3.1415926535897923846, "Math.PI=0; Math.PI" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.1.6-1.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.PI + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.PI"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.PI=0; Math.PI", + 3.1415926535897923846, + eval("Math.PI=0; Math.PI") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.6-2.js b/mozilla/js/tests/ecma/Math/15.8.1.6-2.js index 36066de6045..9eb9a5eb1d8 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.6-2.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.6-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.1.6-2.js - ECMA Section: 15.8.1.6.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.8.1.6-2.js + ECMA Section: 15.8.1.6.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Math.PI + this test checks the DontDelete attribute of Math.PI - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.8.1.6-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.PI"; +var SECTION = "15.8.1.6-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.PI"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "delete Math.PI; Math.PI", + 3.1415926535897923846, + eval("delete Math.PI; Math.PI") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete Math.PI; Math.PI", 3.1415926535897923846, "delete Math.PI; Math.PI" ); - array[item++] = new TestCase( SECTION, "delete Math.PI; Math.PI", false, "delete Math.PI" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "delete Math.PI; Math.PI", + false, + eval("delete Math.PI") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.7-1.js b/mozilla/js/tests/ecma/Math/15.8.1.7-1.js index da42bfa1379..0fb244969dc 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.7-1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.7-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.7-1.js - ECMA Section: 15.8.1.7.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the ReadOnly attribute of Math.SQRT1_2 - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - - var SECTION = "15.8.1.7-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.SQRT1_2"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Math.SQRT1_2=0; Math.SQRT1_2", 0.7071067811865476, "Math.SQRT1_2=0; Math.SQRT1_2" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} - +/** + File Name: 15.8.1.7-1.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the ReadOnly attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.7-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT1_2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.SQRT1_2=0; Math.SQRT1_2", + 0.7071067811865476, + eval("Math.SQRT1_2=0; Math.SQRT1_2") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.7-2.js b/mozilla/js/tests/ecma/Math/15.8.1.7-2.js index b376065a2f9..1645afe6442 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.7-2.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.7-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.7-2.js - ECMA Section: 15.8.1.7.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the DontDelete attribute of Math.SQRT1_2 - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - - var SECTION = "15.8.1.7-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.SQRT1_2"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete Math.SQRT1_2; Math.SQRT1_2", 0.7071067811865476, "delete Math.SQRT1_2; Math.SQRT1_2" ); - array[item++] = new TestCase( SECTION, "delete Math.SQRT1_2", false, "delete Math.SQRT1_2" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.1.7-2.js + ECMA Section: 15.8.1.7.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT1_2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.1.7-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT1_2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.SQRT1_2; Math.SQRT1_2", + 0.7071067811865476, + eval("delete Math.SQRT1_2; Math.SQRT1_2") ); + +new TestCase( SECTION, + "delete Math.SQRT1_2", + false, + eval("delete Math.SQRT1_2") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.8-1.js b/mozilla/js/tests/ecma/Math/15.8.1.8-1.js index 13f75b75f17..e741b06f5e1 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.8-1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.8-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.1.8-1.js - ECMA Section: 15.8.1.8.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.8.1.8-1.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the ReadOnly attribute of Math.SQRT2 + this test checks the ReadOnly attribute of Math.SQRT2 - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.8.1.8-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.SQRT2"; +var SECTION = "15.8.1.8-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT2"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Math.SQRT2=0; Math.SQRT2", 1.4142135623730951, ("Math.SQRT2=0; Math.SQRT2") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.SQRT2=0; Math.SQRT2", + 1.4142135623730951, + eval("Math.SQRT2=0; Math.SQRT2") ); +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.8-2.js b/mozilla/js/tests/ecma/Math/15.8.1.8-2.js index 92d2618da1b..96d56ac69c7 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.8-2.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.8-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,32 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.8-2.js - ECMA Section: 15.8.1.8.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the DontDelete attribute of Math.SQRT2 - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - var SECTION = "15.8.1.8-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.SQRT2"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete Math.SQRT2; Math.SQRT2", 1.4142135623730951, "delete Math.SQRT2; Math.SQRT2" ); - array[item++] = new TestCase( SECTION, "delete Math.SQRT2", false, "delete Math.SQRT2" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.1.8-2.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.8-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.SQRT2"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "delete Math.SQRT2; Math.SQRT2", + 1.4142135623730951, + eval("delete Math.SQRT2; Math.SQRT2") ); + +new TestCase( SECTION, + "delete Math.SQRT2", + false, + eval("delete Math.SQRT2") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.8-3.js b/mozilla/js/tests/ecma/Math/15.8.1.8-3.js index 1765c9dcc97..0ccf2390cda 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.8-3.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.8-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,43 +35,26 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.1.8-3.js - ECMA Section: 15.8.1.8.js - Description: All value properties of the Math object should have - the attributes [DontEnum, DontDelete, ReadOnly] - - this test checks the DontDelete attribute of Math.SQRT2 - - Author: christine@netscape.com - Date: 16 september 1997 -*/ - var SECTION = "15.8.1.8-3"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); - - writeHeaderToLog( SECTION + " Math.SQRT2: DontDelete"); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete Math.SQRT2", false, ("delete Math.SQRT2") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "property should be read-only "; - } - stopTest(); - return ( testcases ); -} - +/** + File Name: 15.8.1.8-3.js + ECMA Section: 15.8.1.8.js + Description: All value properties of the Math object should have + the attributes [DontEnum, DontDelete, ReadOnly] + + this test checks the DontDelete attribute of Math.SQRT2 + + Author: christine@netscape.com + Date: 16 september 1997 +*/ +var SECTION = "15.8.1.8-3"; +var VERSION = "ECMA_1"; +startTest(); + +writeHeaderToLog( SECTION + " Math.SQRT2: DontDelete"); + +new TestCase( SECTION, + "delete Math.SQRT2", + false, + eval("delete Math.SQRT2") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.1.js b/mozilla/js/tests/ecma/Math/15.8.1.js index 064cc2e23f6..4947eefd0ec 100644 --- a/mozilla/js/tests/ecma/Math/15.8.1.js +++ b/mozilla/js/tests/ecma/Math/15.8.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,68 +35,113 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.1.js - ECMA Section: 15.8.1.js Value Properties of the Math Object - 15.8.1.1 E - 15.8.1.2 LN10 - 15.8.1.3 LN2 - 15.8.1.4 LOG2E - 15.8.1.5 LOG10E - 15.8.1.6 PI - 15.8.1.7 SQRT1_2 - 15.8.1.8 SQRT2 - Description: verify the values of some math constants - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.1.js + ECMA Section: 15.8.1.js Value Properties of the Math Object + 15.8.1.1 E + 15.8.1.2 LN10 + 15.8.1.3 LN2 + 15.8.1.4 LOG2E + 15.8.1.5 LOG10E + 15.8.1.6 PI + 15.8.1.7 SQRT1_2 + 15.8.1.8 SQRT2 + Description: verify the values of some math constants + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.1" - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Value Properties of the Math Object"; +var SECTION = "15.8.1" +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Value Properties of the Math Object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( "15.8.1.1", "Math.E", + 2.7182818284590452354, + Math.E ); - array[item++] = new TestCase( "15.8.1.1", "Math.E", 2.7182818284590452354, Math.E ); - array[item++] = new TestCase( "15.8.1.1", "typeof Math.E", "number", typeof Math.E ); - array[item++] = new TestCase( "15.8.1.2", "Math.LN10", 2.302585092994046, Math.LN10 ); - array[item++] = new TestCase( "15.8.1.2", "typeof Math.LN10", "number", typeof Math.LN10 ); - array[item++] = new TestCase( "15.8.1.3", "Math.LN2", 0.6931471805599453, Math.LN2 ); - array[item++] = new TestCase( "15.8.1.3", "typeof Math.LN2", "number", typeof Math.LN2 ); - array[item++] = new TestCase( "15.8.1.4", "Math.LOG2E", 1.4426950408889634, Math.LOG2E ); - array[item++] = new TestCase( "15.8.1.4", "typeof Math.LOG2E", "number", typeof Math.LOG2E ); - array[item++] = new TestCase( "15.8.1.5", "Math.LOG10E", 0.4342944819032518, Math.LOG10E); - array[item++] = new TestCase( "15.8.1.5", "typeof Math.LOG10E", "number", typeof Math.LOG10E); - array[item++] = new TestCase( "15.8.1.6", "Math.PI", 3.14159265358979323846, Math.PI ); - array[item++] = new TestCase( "15.8.1.6", "typeof Math.PI", "number", typeof Math.PI ); - array[item++] = new TestCase( "15.8.1.7", "Math.SQRT1_2", 0.7071067811865476, Math.SQRT1_2); - array[item++] = new TestCase( "15.8.1.7", "typeof Math.SQRT1_2", "number", typeof Math.SQRT1_2); - array[item++] = new TestCase( "15.8.1.8", "Math.SQRT2", 1.4142135623730951, Math.SQRT2 ); - array[item++] = new TestCase( "15.8.1.8", "typeof Math.SQRT2", "number", typeof Math.SQRT2 ); +new TestCase( "15.8.1.1", + "typeof Math.E", + "number", + typeof Math.E ); - array[item++] = new TestCase( SECTION, "var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS", - "", - eval("var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS") ); +new TestCase( "15.8.1.2", + "Math.LN10", + 2.302585092994046, + Math.LN10 ); - return ( array ); -} +new TestCase( "15.8.1.2", + "typeof Math.LN10", + "number", + typeof Math.LN10 ); -function test() { - for ( i = 0; i < testcases.length; i++ ) { - testcases[i].passed = writeTestCaseResult( - testcases[i].expect, - testcases[i].actual, - testcases[i].description +" = "+ testcases[i].actual ); - testcases[i].reason += ( testcases[i].passed ) ? "" : "wrong value " - } - stopTest(); - return ( testcases ); -} +new TestCase( "15.8.1.3", + "Math.LN2", + 0.6931471805599453, + Math.LN2 ); + +new TestCase( "15.8.1.3", + "typeof Math.LN2", + "number", + typeof Math.LN2 ); + +new TestCase( "15.8.1.4", + "Math.LOG2E", + 1.4426950408889634, + Math.LOG2E ); + +new TestCase( "15.8.1.4", + "typeof Math.LOG2E", + "number", + typeof Math.LOG2E ); + +new TestCase( "15.8.1.5", + "Math.LOG10E", + 0.4342944819032518, + Math.LOG10E); + +new TestCase( "15.8.1.5", + "typeof Math.LOG10E", + "number", + typeof Math.LOG10E); + +new TestCase( "15.8.1.6", + "Math.PI", + 3.14159265358979323846, + Math.PI ); + +new TestCase( "15.8.1.6", + "typeof Math.PI", + "number", + typeof Math.PI ); + +new TestCase( "15.8.1.7", + "Math.SQRT1_2", + 0.7071067811865476, + Math.SQRT1_2); + +new TestCase( "15.8.1.7", + "typeof Math.SQRT1_2", + "number", + typeof Math.SQRT1_2); + +new TestCase( "15.8.1.8", + "Math.SQRT2", + 1.4142135623730951, + Math.SQRT2 ); + +new TestCase( "15.8.1.8", + "typeof Math.SQRT2", + "number", + typeof Math.SQRT2 ); + +new TestCase( SECTION, + "var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS", + "", + eval("var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS") ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.1.js b/mozilla/js/tests/ecma/Math/15.8.2.1.js index eb03ff72370..9011e62b331 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.1.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,85 +35,190 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.1.js - ECMA Section: 15.8.2.1 abs( x ) - Description: return the absolute value of the argument, - which should be the magnitude of the argument - with a positive sign. - - if x is NaN, return NaN - - if x is -0, result is +0 - - if x is -Infinity, result is +Infinity - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.1.js + ECMA Section: 15.8.2.1 abs( x ) + Description: return the absolute value of the argument, + which should be the magnitude of the argument + with a positive sign. + - if x is NaN, return NaN + - if x is -0, result is +0 + - if x is -Infinity, result is +Infinity + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.abs()"; - var BUGNUMBER = "77391"; +var SECTION = "15.8.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.abs()"; +var BUGNUMBER = "77391"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.abs.length", + 1, + Math.abs.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.abs()", + Number.NaN, + Math.abs() ); - array[item++] = new TestCase( SECTION, "Math.abs.length", 1, Math.abs.length ); +new TestCase( SECTION, + "Math.abs( void 0 )", + Number.NaN, + Math.abs(void 0) ); - array[item++] = new TestCase( SECTION, "Math.abs()", Number.NaN, Math.abs() ); - array[item++] = new TestCase( SECTION, "Math.abs( void 0 )", Number.NaN, Math.abs(void 0) ); - array[item++] = new TestCase( SECTION, "Math.abs( null )", 0, Math.abs(null) ); - array[item++] = new TestCase( SECTION, "Math.abs( true )", 1, Math.abs(true) ); - array[item++] = new TestCase( SECTION, "Math.abs( false )", 0, Math.abs(false) ); - array[item++] = new TestCase( SECTION, "Math.abs( string primitive)", Number.NaN, Math.abs("a string primitive") ); - array[item++] = new TestCase( SECTION, "Math.abs( string object )", Number.NaN, Math.abs(new String( 'a String object' )) ); - array[item++] = new TestCase( SECTION, "Math.abs( Number.NaN )", Number.NaN, Math.abs(Number.NaN) ); +new TestCase( SECTION, + "Math.abs( null )", + 0, + Math.abs(null) ); - array[item++] = new TestCase( SECTION, "Math.abs(0)", 0, Math.abs( 0 ) ); - array[item++] = new TestCase( SECTION, "Math.abs( -0 )", 0, Math.abs(-0) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.abs(-0)", Infinity, Infinity/Math.abs(-0) ); +new TestCase( SECTION, + "Math.abs( true )", + 1, + Math.abs(true) ); - array[item++] = new TestCase( SECTION, "Math.abs( -Infinity )", Number.POSITIVE_INFINITY, Math.abs( Number.NEGATIVE_INFINITY ) ); - array[item++] = new TestCase( SECTION, "Math.abs( Infinity )", Number.POSITIVE_INFINITY, Math.abs( Number.POSITIVE_INFINITY ) ); - array[item++] = new TestCase( SECTION, "Math.abs( - MAX_VALUE )", Number.MAX_VALUE, Math.abs( - Number.MAX_VALUE ) ); - array[item++] = new TestCase( SECTION, "Math.abs( - MIN_VALUE )", Number.MIN_VALUE, Math.abs( -Number.MIN_VALUE ) ); - array[item++] = new TestCase( SECTION, "Math.abs( MAX_VALUE )", Number.MAX_VALUE, Math.abs( Number.MAX_VALUE ) ); - array[item++] = new TestCase( SECTION, "Math.abs( MIN_VALUE )", Number.MIN_VALUE, Math.abs( Number.MIN_VALUE ) ); +new TestCase( SECTION, + "Math.abs( false )", + 0, + Math.abs(false) ); - array[item++] = new TestCase( SECTION, "Math.abs( -1 )", 1, Math.abs( -1 ) ); - array[item++] = new TestCase( SECTION, "Math.abs( new Number( -1 ) )", 1, Math.abs( new Number(-1) ) ); - array[item++] = new TestCase( SECTION, "Math.abs( 1 )", 1, Math.abs( 1 ) ); - array[item++] = new TestCase( SECTION, "Math.abs( Math.PI )", Math.PI, Math.abs( Math.PI ) ); - array[item++] = new TestCase( SECTION, "Math.abs( -Math.PI )", Math.PI, Math.abs( -Math.PI ) ); - array[item++] = new TestCase( SECTION, "Math.abs(-1/100000000)", 1/100000000, Math.abs(-1/100000000) ); - array[item++] = new TestCase( SECTION, "Math.abs(-Math.pow(2,32))", Math.pow(2,32), Math.abs(-Math.pow(2,32)) ); - array[item++] = new TestCase( SECTION, "Math.abs(Math.pow(2,32))", Math.pow(2,32), Math.abs(Math.pow(2,32)) ); - array[item++] = new TestCase( SECTION, "Math.abs( -0xfff )", 4095, Math.abs( -0xfff ) ); - array[item++] = new TestCase( SECTION, "Math.abs( -0777 )", 511, Math.abs(-0777 ) ); +new TestCase( SECTION, + "Math.abs( string primitive)", + Number.NaN, + Math.abs("a string primitive") ); - array[item++] = new TestCase( SECTION, "Math.abs('-1e-1')", 0.1, Math.abs('-1e-1') ); - array[item++] = new TestCase( SECTION, "Math.abs('0xff')", 255, Math.abs('0xff') ); - array[item++] = new TestCase( SECTION, "Math.abs('077')", 77, Math.abs('077') ); - array[item++] = new TestCase( SECTION, "Math.abs( 'Infinity' )", Infinity, Math.abs('Infinity') ); - array[item++] = new TestCase( SECTION, "Math.abs( '-Infinity' )", Infinity, Math.abs('-Infinity') ); +new TestCase( SECTION, + "Math.abs( string object )", + Number.NaN, + Math.abs(new String( 'a String object' )) ); - return ( array ); -} +new TestCase( SECTION, + "Math.abs( Number.NaN )", + Number.NaN, + Math.abs(Number.NaN) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.abs(0)", + 0, + Math.abs( 0 ) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.abs( -0 )", + 0, + Math.abs(-0) ); + +new TestCase( SECTION, + "Infinity/Math.abs(-0)", + Infinity, + Infinity/Math.abs(-0) ); + +new TestCase( SECTION, + "Math.abs( -Infinity )", + Number.POSITIVE_INFINITY, + Math.abs( Number.NEGATIVE_INFINITY ) ); + +new TestCase( SECTION, + "Math.abs( Infinity )", + Number.POSITIVE_INFINITY, + Math.abs( Number.POSITIVE_INFINITY ) ); + +new TestCase( SECTION, + "Math.abs( - MAX_VALUE )", + Number.MAX_VALUE, + Math.abs( - Number.MAX_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( - MIN_VALUE )", + Number.MIN_VALUE, + Math.abs( -Number.MIN_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( MAX_VALUE )", + Number.MAX_VALUE, + Math.abs( Number.MAX_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( MIN_VALUE )", + Number.MIN_VALUE, + Math.abs( Number.MIN_VALUE ) ); + +new TestCase( SECTION, + "Math.abs( -1 )", + 1, + Math.abs( -1 ) ); + +new TestCase( SECTION, + "Math.abs( new Number( -1 ) )", + 1, + Math.abs( new Number(-1) ) ); + +new TestCase( SECTION, + "Math.abs( 1 )", + 1, + Math.abs( 1 ) ); + +new TestCase( SECTION, + "Math.abs( Math.PI )", + Math.PI, + Math.abs( Math.PI ) ); + +new TestCase( SECTION, + "Math.abs( -Math.PI )", + Math.PI, + Math.abs( -Math.PI ) ); + +new TestCase( SECTION, + "Math.abs(-1/100000000)", + 1/100000000, + Math.abs(-1/100000000) ); + +new TestCase( SECTION, + "Math.abs(-Math.pow(2,32))", + Math.pow(2,32), + Math.abs(-Math.pow(2,32)) ); + +new TestCase( SECTION, + "Math.abs(Math.pow(2,32))", + Math.pow(2,32), + Math.abs(Math.pow(2,32)) ); + +new TestCase( SECTION, + "Math.abs( -0xfff )", + 4095, + Math.abs( -0xfff ) ); + +new TestCase( SECTION, + "Math.abs( -0777 )", + 511, + Math.abs(-0777 ) ); + +new TestCase( SECTION, + "Math.abs('-1e-1')", + 0.1, + Math.abs('-1e-1') ); + +new TestCase( SECTION, + "Math.abs('0xff')", + 255, + Math.abs('0xff') ); + +new TestCase( SECTION, + "Math.abs('077')", + 77, + Math.abs('077') ); + +new TestCase( SECTION, + "Math.abs( 'Infinity' )", + Infinity, + Math.abs('Infinity') ); + +new TestCase( SECTION, + "Math.abs( '-Infinity' )", + Infinity, + Math.abs('-Infinity') ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.10.js b/mozilla/js/tests/ecma/Math/15.8.2.10.js index a21b7480c3c..7d9e46449b9 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.10.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.10.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,68 +35,116 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.10.js - ECMA Section: 15.8.2.10 Math.log(x) - Description: return an approximiation to the natural logarithm of - the argument. - special cases: - - if arg is NaN result is NaN - - if arg is <0 result is NaN - - if arg is 0 or -0 result is -Infinity - - if arg is 1 result is 0 - - if arg is Infinity result is Infinity - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.10.js + ECMA Section: 15.8.2.10 Math.log(x) + Description: return an approximiation to the natural logarithm of + the argument. + special cases: + - if arg is NaN result is NaN + - if arg is <0 result is NaN + - if arg is 0 or -0 result is -Infinity + - if arg is 1 result is 0 + - if arg is Infinity result is Infinity + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.log(x)"; - var BUGNUMBER = "77391"; +var SECTION = "15.8.2.10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.log(x)"; +var BUGNUMBER = "77391"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.log.length", + 1, + Math.log.length ); - array[item++] = new TestCase( SECTION, "Math.log.length", 1, Math.log.length ); - array[item++] = new TestCase( SECTION, "Math.log()", Number.NaN, Math.log() ); - array[item++] = new TestCase( SECTION, "Math.log(void 0)", Number.NaN, Math.log(void 0) ); - array[item++] = new TestCase( SECTION, "Math.log(null)", Number.NEGATIVE_INFINITY, Math.log(null) ); - array[item++] = new TestCase( SECTION, "Math.log(true)", 0, Math.log(true) ); - array[item++] = new TestCase( SECTION, "Math.log(false)", -Infinity, Math.log(false) ); - array[item++] = new TestCase( SECTION, "Math.log('0')", -Infinity, Math.log('0') ); - array[item++] = new TestCase( SECTION, "Math.log('1')", 0, Math.log('1') ); - array[item++] = new TestCase( SECTION, "Math.log('Infinity')", Infinity, Math.log("Infinity") ); +new TestCase( SECTION, + "Math.log()", + Number.NaN, + Math.log() ); - array[item++] = new TestCase( SECTION, "Math.log(NaN)", Number.NaN, Math.log(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.log(-0.0000001)", Number.NaN, Math.log(-0.000001) ); - array[item++] = new TestCase( SECTION, "Math.log(-1)", Number.NaN, Math.log(-1) ); - array[item++] = new TestCase( SECTION, "Math.log(0)", Number.NEGATIVE_INFINITY, Math.log(0) ); - array[item++] = new TestCase( SECTION, "Math.log(-0)", Number.NEGATIVE_INFINITY, Math.log(-0)); - array[item++] = new TestCase( SECTION, "Math.log(1)", 0, Math.log(1) ); - array[item++] = new TestCase( SECTION, "Math.log(Infinity)", Number.POSITIVE_INFINITY, Math.log(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.log(-Infinity)", Number.NaN, Math.log(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, + "Math.log(void 0)", + Number.NaN, + Math.log(void 0) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.log(null)", + Number.NEGATIVE_INFINITY, + Math.log(null) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "Math.log(true)", + 0, + Math.log(true) ); + +new TestCase( SECTION, + "Math.log(false)", + -Infinity, + Math.log(false) ); + +new TestCase( SECTION, + "Math.log('0')", + -Infinity, + Math.log('0') ); + +new TestCase( SECTION, + "Math.log('1')", + 0, + Math.log('1') ); + +new TestCase( SECTION, + "Math.log('Infinity')", + Infinity, + Math.log("Infinity") ); + + +new TestCase( SECTION, + "Math.log(NaN)", + Number.NaN, + Math.log(Number.NaN) ); + +new TestCase( SECTION, + "Math.log(-0.0000001)", + Number.NaN, + Math.log(-0.000001) ); + +new TestCase( SECTION, + "Math.log(-1)", + Number.NaN, + Math.log(-1) ); + +new TestCase( SECTION, + "Math.log(0)", + Number.NEGATIVE_INFINITY, + Math.log(0) ); + +new TestCase( SECTION, + "Math.log(-0)", + Number.NEGATIVE_INFINITY, + Math.log(-0)); + +new TestCase( SECTION, + "Math.log(1)", + 0, + Math.log(1) ); + +new TestCase( SECTION, + "Math.log(Infinity)", + Number.POSITIVE_INFINITY, + Math.log(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.log(-Infinity)", + Number.NaN, + Math.log(Number.NEGATIVE_INFINITY) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.11.js b/mozilla/js/tests/ecma/Math/15.8.2.11.js index e1d41f91c78..d624757ad9a 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.11.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.11.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,163 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.11.js - ECMA Section: 15.8.2.11 Math.max(x, y) - Description: return the smaller of the two arguments. - special cases: - - if x is NaN or y is NaN return NaN - - if x < y return x - - if y > x return y - - if x is +0 and y is +0 return +0 - - if x is +0 and y is -0 return -0 - - if x is -0 and y is +0 return -0 - - if x is -0 and y is -0 return -0 - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.11.js + ECMA Section: 15.8.2.11 Math.max(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.max(x, y)"; - var BUGNUMBER="76439"; +var SECTION = "15.8.2.11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.max(x, y)"; +var BUGNUMBER="76439"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.max.length", + 2, + Math.max.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.max()", + -Infinity, + Math.max() ); - array[item++] = new TestCase( SECTION, "Math.max.length", 2, Math.max.length ); +new TestCase( SECTION, + "Math.max(void 0, 1)", + Number.NaN, + Math.max( void 0, 1 ) ); - array[item++] = new TestCase( SECTION, "Math.max()", -Infinity, Math.max() ); - array[item++] = new TestCase( SECTION, "Math.max(void 0, 1)", Number.NaN, Math.max( void 0, 1 ) ); - array[item++] = new TestCase( SECTION, "Math.max(void 0, void 0)", Number.NaN, Math.max( void 0, void 0 ) ); - array[item++] = new TestCase( SECTION, "Math.max(null, 1)", 1, Math.max( null, 1 ) ); - array[item++] = new TestCase( SECTION, "Math.max(-1, null)", 0, Math.max( -1, null ) ); - array[item++] = new TestCase( SECTION, "Math.max(true, false)", 1, Math.max(true,false) ); +new TestCase( SECTION, + "Math.max(void 0, void 0)", + Number.NaN, + Math.max( void 0, void 0 ) ); - array[item++] = new TestCase( SECTION, "Math.max('-99','99')", 99, Math.max( "-99","99") ); +new TestCase( SECTION, + "Math.max(null, 1)", + 1, + Math.max( null, 1 ) ); - array[item++] = new TestCase( SECTION, "Math.max(NaN, Infinity)", Number.NaN, Math.max(Number.NaN,Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.max(NaN, 0)", Number.NaN, Math.max(Number.NaN, 0) ); - array[item++] = new TestCase( SECTION, "Math.max('a string', 0)", Number.NaN, Math.max("a string", 0) ); - array[item++] = new TestCase( SECTION, "Math.max(NaN, 1)", Number.NaN, Math.max(Number.NaN,1) ); - array[item++] = new TestCase( SECTION, "Math.max('a string',Infinity)", Number.NaN, Math.max("a string", Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.max(Infinity, NaN)", Number.NaN, Math.max( Number.POSITIVE_INFINITY, Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.max(NaN, NaN)", Number.NaN, Math.max(Number.NaN, Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.max(0,NaN)", Number.NaN, Math.max(0,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.max(1, NaN)", Number.NaN, Math.max(1, Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.max(0,0)", 0, Math.max(0,0) ); - array[item++] = new TestCase( SECTION, "Math.max(0,-0)", 0, Math.max(0,-0) ); - array[item++] = new TestCase( SECTION, "Math.max(-0,0)", 0, Math.max(-0,0) ); - array[item++] = new TestCase( SECTION, "Math.max(-0,-0)", -0, Math.max(-0,-0) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.max(-0,-0)", -Infinity, Infinity/Math.max(-0,-0) ); - array[item++] = new TestCase( SECTION, "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY, Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) ); - array[item++] = new TestCase( SECTION, "Math.max(Infinity, Infinity)", Number.POSITIVE_INFINITY, Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.max(-Infinity,-Infinity)", Number.NEGATIVE_INFINITY, Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.max(1,.99999999999999)", 1, Math.max(1,.99999999999999) ); - array[item++] = new TestCase( SECTION, "Math.max(-1,-.99999999999999)", -.99999999999999, Math.max(-1,-.99999999999999) ); +new TestCase( SECTION, + "Math.max(-1, null)", + 0, + Math.max( -1, null ) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.max(true, false)", + 1, + Math.max(true,false) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.max('-99','99')", + 99, + Math.max( "-99","99") ); + +new TestCase( SECTION, + "Math.max(NaN, Infinity)", + Number.NaN, + Math.max(Number.NaN,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(NaN, 0)", + Number.NaN, + Math.max(Number.NaN, 0) ); + +new TestCase( SECTION, + "Math.max('a string', 0)", + Number.NaN, + Math.max("a string", 0) ); + +new TestCase( SECTION, + "Math.max(NaN, 1)", + Number.NaN, + Math.max(Number.NaN,1) ); + +new TestCase( SECTION, + "Math.max('a string',Infinity)", + Number.NaN, + Math.max("a string", Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(Infinity, NaN)", + Number.NaN, + Math.max( Number.POSITIVE_INFINITY, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(NaN, NaN)", + Number.NaN, + Math.max(Number.NaN, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(0,NaN)", + Number.NaN, + Math.max(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.max(1, NaN)", + Number.NaN, + Math.max(1, Number.NaN) ); + +new TestCase( SECTION, + "Math.max(0,0)", + 0, + Math.max(0,0) ); + +new TestCase( SECTION, + "Math.max(0,-0)", + 0, + Math.max(0,-0) ); + +new TestCase( SECTION, + "Math.max(-0,0)", + 0, + Math.max(-0,0) ); + +new TestCase( SECTION, + "Math.max(-0,-0)", + -0, + Math.max(-0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.max(-0,-0)", + -Infinity, + Infinity/Math.max(-0,-0) ); + +new TestCase( SECTION, + "Math.max(Infinity, Number.MAX_VALUE)", Number.POSITIVE_INFINITY, + Math.max(Number.POSITIVE_INFINITY, Number.MAX_VALUE) ); + +new TestCase( SECTION, + "Math.max(Infinity, Infinity)", + Number.POSITIVE_INFINITY, + Math.max(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(-Infinity,-Infinity)", + Number.NEGATIVE_INFINITY, + Math.max(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.max(1,.99999999999999)", + 1, + Math.max(1,.99999999999999) ); + +new TestCase( SECTION, + "Math.max(-1,-.99999999999999)", + -.99999999999999, + Math.max(-1,-.99999999999999) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.12.js b/mozilla/js/tests/ecma/Math/15.8.2.12.js index 1fa3091b878..b92706bce91 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.12.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.12.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,140 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.12.js - ECMA Section: 15.8.2.12 Math.min(x, y) - Description: return the smaller of the two arguments. - special cases: - - if x is NaN or y is NaN return NaN - - if x < y return x - - if y > x return y - - if x is +0 and y is +0 return +0 - - if x is +0 and y is -0 return -0 - - if x is -0 and y is +0 return -0 - - if x is -0 and y is -0 return -0 - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.12.js + ECMA Section: 15.8.2.12 Math.min(x, y) + Description: return the smaller of the two arguments. + special cases: + - if x is NaN or y is NaN return NaN + - if x < y return x + - if y > x return y + - if x is +0 and y is +0 return +0 + - if x is +0 and y is -0 return -0 + - if x is -0 and y is +0 return -0 + - if x is -0 and y is -0 return -0 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.min(x, y)"; - var BUGNUMBER="76439"; +var SECTION = "15.8.2.12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.min(x, y)"; +var BUGNUMBER="76439"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.min.length", + 2, + Math.min.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.min()", + Infinity, + Math.min() ); - array[item++] = new TestCase( SECTION, "Math.min.length", 2, Math.min.length ); +new TestCase( SECTION, + "Math.min(void 0, 1)", + Number.NaN, + Math.min( void 0, 1 ) ); - array[item++] = new TestCase( SECTION, "Math.min()", Infinity, Math.min() ); - array[item++] = new TestCase( SECTION, "Math.min(void 0, 1)", Number.NaN, Math.min( void 0, 1 ) ); - array[item++] = new TestCase( SECTION, "Math.min(void 0, void 0)", Number.NaN, Math.min( void 0, void 0 ) ); - array[item++] = new TestCase( SECTION, "Math.min(null, 1)", 0, Math.min( null, 1 ) ); - array[item++] = new TestCase( SECTION, "Math.min(-1, null)", -1, Math.min( -1, null ) ); - array[item++] = new TestCase( SECTION, "Math.min(true, false)", 0, Math.min(true,false) ); +new TestCase( SECTION, + "Math.min(void 0, void 0)", + Number.NaN, + Math.min( void 0, void 0 ) ); - array[item++] = new TestCase( SECTION, "Math.min('-99','99')", -99, Math.min( "-99","99") ); +new TestCase( SECTION, + "Math.min(null, 1)", + 0, + Math.min( null, 1 ) ); - array[item++] = new TestCase( SECTION, "Math.min(NaN,0)", Number.NaN, Math.min(Number.NaN,0) ); - array[item++] = new TestCase( SECTION, "Math.min(NaN,1)", Number.NaN, Math.min(Number.NaN,1) ); - array[item++] = new TestCase( SECTION, "Math.min(NaN,-1)", Number.NaN, Math.min(Number.NaN,-1) ); - array[item++] = new TestCase( SECTION, "Math.min(0,NaN)", Number.NaN, Math.min(0,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.min(1,NaN)", Number.NaN, Math.min(1,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.min(-1,NaN)", Number.NaN, Math.min(-1,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.min(NaN,NaN)", Number.NaN, Math.min(Number.NaN,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.min(1,1.0000000001)", 1, Math.min(1,1.0000000001) ); - array[item++] = new TestCase( SECTION, "Math.min(1.0000000001,1)", 1, Math.min(1.0000000001,1) ); - array[item++] = new TestCase( SECTION, "Math.min(0,0)", 0, Math.min(0,0) ); - array[item++] = new TestCase( SECTION, "Math.min(0,-0)", -0, Math.min(0,-0) ); - array[item++] = new TestCase( SECTION, "Math.min(-0,-0)", -0, Math.min(-0,-0) ); +new TestCase( SECTION, + "Math.min(-1, null)", + -1, + Math.min( -1, null ) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.min(0,-0)", -Infinity, Infinity/Math.min(0,-0) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.min(-0,-0)", -Infinity, Infinity/Math.min(-0,-0) ); +new TestCase( SECTION, + "Math.min(true, false)", + 0, + Math.min(true,false) ); +new TestCase( SECTION, + "Math.min('-99','99')", + -99, + Math.min( "-99","99") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.min(NaN,0)", + Number.NaN, + Math.min(Number.NaN,0) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.min(NaN,1)", + Number.NaN, + Math.min(Number.NaN,1) ); + +new TestCase( SECTION, + "Math.min(NaN,-1)", + Number.NaN, + Math.min(Number.NaN,-1) ); + +new TestCase( SECTION, + "Math.min(0,NaN)", + Number.NaN, + Math.min(0,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(1,NaN)", + Number.NaN, + Math.min(1,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(-1,NaN)", + Number.NaN, + Math.min(-1,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(NaN,NaN)", + Number.NaN, + Math.min(Number.NaN,Number.NaN) ); + +new TestCase( SECTION, + "Math.min(1,1.0000000001)", + 1, + Math.min(1,1.0000000001) ); + +new TestCase( SECTION, + "Math.min(1.0000000001,1)", + 1, + Math.min(1.0000000001,1) ); + +new TestCase( SECTION, + "Math.min(0,0)", + 0, + Math.min(0,0) ); + +new TestCase( SECTION, + "Math.min(0,-0)", + -0, + Math.min(0,-0) ); + +new TestCase( SECTION, + "Math.min(-0,-0)", + -0, + Math.min(-0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.min(0,-0)", + -Infinity, + Infinity/Math.min(0,-0) ); + +new TestCase( SECTION, + "Infinity/Math.min(-0,-0)", + -Infinity, + Infinity/Math.min(-0,-0) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.13.js b/mozilla/js/tests/ecma/Math/15.8.2.13.js index 0c44600fac4..aaaec9bdf40 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.13.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.13.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,114 +35,348 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.13.js - ECMA Section: 15.8.2.13 Math.pow(x, y) - Description: return an approximation to the result of x - to the power of y. there are many special cases; - refer to the spec. - Author: christine@netscape.com - Date: 9 july 1997 + File Name: 15.8.2.13.js + ECMA Section: 15.8.2.13 Math.pow(x, y) + Description: return an approximation to the result of x + to the power of y. there are many special cases; + refer to the spec. + Author: christine@netscape.com + Date: 9 july 1997 */ - var SECTION = "15.8.2.13"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.pow(x, y)"; - var BUGNUMBER="77141"; +var SECTION = "15.8.2.13"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.pow(x, y)"; +var BUGNUMBER="77141"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.pow.length", + 2, + Math.pow.length ); - array[item++] = new TestCase( SECTION, "Math.pow.length", 2, Math.pow.length ); +new TestCase( SECTION, + "Math.pow()", + Number.NaN, + Math.pow() ); - array[item++] = new TestCase( SECTION, "Math.pow()", Number.NaN, Math.pow() ); - array[item++] = new TestCase( SECTION, "Math.pow(null, null)", 1, Math.pow(null,null) ); - array[item++] = new TestCase( SECTION, "Math.pow(void 0, void 0)", Number.NaN, Math.pow(void 0, void 0)); - array[item++] = new TestCase( SECTION, "Math.pow(true, false)", 1, Math.pow(true, false) ); - array[item++] = new TestCase( SECTION, "Math.pow(false,true)", 0, Math.pow(false,true) ); - array[item++] = new TestCase( SECTION, "Math.pow('2','32')", 4294967296, Math.pow('2','32') ); +new TestCase( SECTION, + "Math.pow(null, null)", + 1, + Math.pow(null,null) ); - array[item++] = new TestCase( SECTION, "Math.pow(1,NaN)", Number.NaN, Math.pow(1,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.pow(0,NaN)", Number.NaN, Math.pow(0,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.pow(NaN,0)", 1, Math.pow(Number.NaN,0) ); - array[item++] = new TestCase( SECTION, "Math.pow(NaN,-0)", 1, Math.pow(Number.NaN,-0) ); - array[item++] = new TestCase( SECTION, "Math.pow(NaN,1)", Number.NaN, Math.pow(Number.NaN, 1) ); - array[item++] = new TestCase( SECTION, "Math.pow(NaN,.5)", Number.NaN, Math.pow(Number.NaN, .5) ); - array[item++] = new TestCase( SECTION, "Math.pow(1.00000001, Infinity)", Number.POSITIVE_INFINITY, Math.pow(1.00000001, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(1.00000001, -Infinity)", 0, Math.pow(1.00000001, Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(-1.00000001, Infinity)", Number.POSITIVE_INFINITY, Math.pow(-1.00000001,Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(-1.00000001, -Infinity)", 0, Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(1, Infinity)", Number.NaN, Math.pow(1, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(1, -Infinity)", Number.NaN, Math.pow(1, Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(-1, Infinity)", Number.NaN, Math.pow(-1, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(-1, -Infinity)", Number.NaN, Math.pow(-1, Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(.0000000009, Infinity)", 0, Math.pow(.0000000009, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(-.0000000009, Infinity)", 0, Math.pow(-.0000000009, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(.0000000009, -Infinity)", Number.POSITIVE_INFINITY, Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(Infinity, .00000000001)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY,.00000000001) ); - array[item++] = new TestCase( SECTION, "Math.pow(Infinity, 1)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY, 1) ); - array[item++] = new TestCase( SECTION, "Math.pow(Infinity, -.00000000001)",0, Math.pow(Number.POSITIVE_INFINITY, -.00000000001) ); - array[item++] = new TestCase( SECTION, "Math.pow(Infinity, -1)", 0, Math.pow(Number.POSITIVE_INFINITY, -1) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 1)", Number.NEGATIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 1) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 333)", Number.NEGATIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 333) ); - array[item++] = new TestCase( SECTION, "Math.pow(Infinity, 2)", Number.POSITIVE_INFINITY, Math.pow(Number.POSITIVE_INFINITY, 2) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 666)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 666) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, 0.5)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, 0.5) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, Infinity)", Number.POSITIVE_INFINITY, Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, + "Math.pow(void 0, void 0)", + Number.NaN, + Math.pow(void 0, void 0)); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -1)", -0, Math.pow(Number.NEGATIVE_INFINITY, -1) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-Infinity, -1)", -Infinity, Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) ); +new TestCase( SECTION, + "Math.pow(true, false)", + 1, + Math.pow(true, false) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -3)", -0, Math.pow(Number.NEGATIVE_INFINITY, -3) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -2)", 0, Math.pow(Number.NEGATIVE_INFINITY, -2) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -0.5)", 0, Math.pow(Number.NEGATIVE_INFINITY,-0.5) ); - array[item++] = new TestCase( SECTION, "Math.pow(-Infinity, -Infinity)", 0, Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, 1)", 0, Math.pow(0,1) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, 0)", 1, Math.pow(0,0) ); - array[item++] = new TestCase( SECTION, "Math.pow(1, 0)", 1, Math.pow(1,0) ); - array[item++] = new TestCase( SECTION, "Math.pow(-1, 0)", 1, Math.pow(-1,0) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, 0.5)", 0, Math.pow(0,0.5) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, 1000)", 0, Math.pow(0,1000) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, Infinity)", 0, Math.pow(0, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, -1)", Number.POSITIVE_INFINITY, Math.pow(0, -1) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, -0.5)", Number.POSITIVE_INFINITY, Math.pow(0, -0.5) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, -1000)", Number.POSITIVE_INFINITY, Math.pow(0, -1000) ); - array[item++] = new TestCase( SECTION, "Math.pow(0, -Infinity)", Number.POSITIVE_INFINITY, Math.pow(0, Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, 1)", -0, Math.pow(-0, 1) ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, 3)", -0, Math.pow(-0,3) ); +new TestCase( SECTION, + "Math.pow(false,true)", + 0, + Math.pow(false,true) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-0, 1)", -Infinity, Infinity/Math.pow(-0, 1) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.pow(-0, 3)", -Infinity, Infinity/Math.pow(-0,3) ); +new TestCase( SECTION, + "Math.pow('2','32')", + 4294967296, + Math.pow('2','32') ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, 2)", 0, Math.pow(-0,2) ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, Infinity)", 0, Math.pow(-0, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, -1)", Number.NEGATIVE_INFINITY, Math.pow(-0, -1) ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, -10001)", Number.NEGATIVE_INFINITY, Math.pow(-0, -10001) ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, -2)", Number.POSITIVE_INFINITY, Math.pow(-0, -2) ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, 0.5)", 0, Math.pow(-0, 0.5) ); - array[item++] = new TestCase( SECTION, "Math.pow(-0, Infinity)", 0, Math.pow(-0, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.pow(-1, 0.5)", Number.NaN, Math.pow(-1, 0.5) ); - array[item++] = new TestCase( SECTION, "Math.pow(-1, NaN)", Number.NaN, Math.pow(-1, Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.pow(-1, -0.5)", Number.NaN, Math.pow(-1, -0.5) ); +new TestCase( SECTION, + "Math.pow(1,NaN)", + Number.NaN, + Math.pow(1,Number.NaN) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.pow(0,NaN)", + Number.NaN, + Math.pow(0,Number.NaN) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.pow(NaN,0)", + 1, + Math.pow(Number.NaN,0) ); + +new TestCase( SECTION, + "Math.pow(NaN,-0)", + 1, + Math.pow(Number.NaN,-0) ); + +new TestCase( SECTION, + "Math.pow(NaN,1)", + Number.NaN, + Math.pow(Number.NaN, 1) ); + +new TestCase( SECTION, + "Math.pow(NaN,.5)", + Number.NaN, + Math.pow(Number.NaN, .5) ); + +new TestCase( SECTION, + "Math.pow(1.00000001, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(1.00000001, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1.00000001, -Infinity)", + 0, + Math.pow(1.00000001, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1.00000001, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(-1.00000001,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1.00000001, -Infinity)", + 0, + Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1, Infinity)", + Number.NaN, + Math.pow(1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(1, -Infinity)", + Number.NaN, + Math.pow(1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, Infinity)", + Number.NaN, + Math.pow(-1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, -Infinity)", + Number.NaN, + Math.pow(-1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(.0000000009, Infinity)", + 0, + Math.pow(.0000000009, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-.0000000009, Infinity)", + 0, + Math.pow(-.0000000009, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(.0000000009, -Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(Infinity, .00000000001)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY,.00000000001) ); + +new TestCase( SECTION, + "Math.pow(Infinity, 1)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.pow(Infinity, -.00000000001)", + 0, + Math.pow(Number.POSITIVE_INFINITY, -.00000000001) ); + +new TestCase( SECTION, + "Math.pow(Infinity, -1)", + 0, + Math.pow(Number.POSITIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 1)", + Number.NEGATIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 333)", + Number.NEGATIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 333) ); + +new TestCase( SECTION, + "Math.pow(Infinity, 2)", + Number.POSITIVE_INFINITY, + Math.pow(Number.POSITIVE_INFINITY, 2) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 666)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 666) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, 0.5)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -1)", + -0, + Math.pow(Number.NEGATIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-Infinity, -1)", + -Infinity, + Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -3)", + -0, + Math.pow(Number.NEGATIVE_INFINITY, -3) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -2)", + 0, + Math.pow(Number.NEGATIVE_INFINITY, -2) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -0.5)", + 0, + Math.pow(Number.NEGATIVE_INFINITY,-0.5) ); + +new TestCase( SECTION, + "Math.pow(-Infinity, -Infinity)", + 0, + Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(0, 1)", + 0, + Math.pow(0,1) ); + +new TestCase( SECTION, + "Math.pow(0, 0)", + 1, + Math.pow(0,0) ); + +new TestCase( SECTION, + "Math.pow(1, 0)", + 1, + Math.pow(1,0) ); + +new TestCase( SECTION, + "Math.pow(-1, 0)", + 1, + Math.pow(-1,0) ); + +new TestCase( SECTION, + "Math.pow(0, 0.5)", + 0, + Math.pow(0,0.5) ); + +new TestCase( SECTION, + "Math.pow(0, 1000)", + 0, + Math.pow(0,1000) ); + +new TestCase( SECTION, + "Math.pow(0, Infinity)", + 0, + Math.pow(0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(0, -1)", + Number.POSITIVE_INFINITY, + Math.pow(0, -1) ); + +new TestCase( SECTION, + "Math.pow(0, -0.5)", + Number.POSITIVE_INFINITY, + Math.pow(0, -0.5) ); + +new TestCase( SECTION, + "Math.pow(0, -1000)", + Number.POSITIVE_INFINITY, + Math.pow(0, -1000) ); + +new TestCase( SECTION, + "Math.pow(0, -Infinity)", + Number.POSITIVE_INFINITY, + Math.pow(0, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-0, 1)", + -0, + Math.pow(-0, 1) ); + +new TestCase( SECTION, + "Math.pow(-0, 3)", + -0, + Math.pow(-0,3) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-0, 1)", + -Infinity, + Infinity/Math.pow(-0, 1) ); + +new TestCase( SECTION, + "Infinity/Math.pow(-0, 3)", + -Infinity, + Infinity/Math.pow(-0,3) ); + +new TestCase( SECTION, + "Math.pow(-0, 2)", + 0, + Math.pow(-0,2) ); + +new TestCase( SECTION, + "Math.pow(-0, Infinity)", + 0, + Math.pow(-0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-0, -1)", + Number.NEGATIVE_INFINITY, + Math.pow(-0, -1) ); + +new TestCase( SECTION, + "Math.pow(-0, -10001)", + Number.NEGATIVE_INFINITY, + Math.pow(-0, -10001) ); + +new TestCase( SECTION, + "Math.pow(-0, -2)", + Number.POSITIVE_INFINITY, + Math.pow(-0, -2) ); + +new TestCase( SECTION, + "Math.pow(-0, 0.5)", + 0, + Math.pow(-0, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-0, Infinity)", + 0, + Math.pow(-0, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.pow(-1, 0.5)", + Number.NaN, + Math.pow(-1, 0.5) ); + +new TestCase( SECTION, + "Math.pow(-1, NaN)", + Number.NaN, + Math.pow(-1, Number.NaN) ); + +new TestCase( SECTION, + "Math.pow(-1, -0.5)", + Number.NaN, + Math.pow(-1, -0.5) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.14.js b/mozilla/js/tests/ecma/Math/15.8.2.14.js index 03ef381d197..29148923822 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.14.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.14.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,42 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.2.14.js - ECMA Section: 15.8.2.14 Math.random() - returns a number value x with a positive sign - with 1 > x >= 0 with approximately uniform - distribution over that range, using an - implementation-dependent algorithm or strategy. - This function takes no arguments. - - Description: - Author: christine@netscape.com - Date: 16 september 1997 -*/ - - var SECTION = "15.8.2.14"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.random()"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - - for ( item = 0; item < 100; item++ ) { - array[item] = new TestCase( SECTION, "Math.random()", "pass", null ); - } - - return ( array ); -} -function getRandom( caseno ) { - testcases[caseno].reason = Math.random(); - testcases[caseno].actual = "pass"; - - if ( ! ( testcases[caseno].reason >= 0) ) { - testcases[caseno].actual = "fail"; - } - - if ( ! (testcases[caseno].reason < 1) ) { - testcases[caseno].actual = "fail"; - } -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - getRandom( tc ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.2.14.js + ECMA Section: 15.8.2.14 Math.random() + returns a number value x with a positive sign + with 1 > x >= 0 with approximately uniform + distribution over that range, using an + implementation-dependent algorithm or strategy. + This function takes no arguments. + + Description: + Author: christine@netscape.com + Date: 16 september 1997 +*/ + +var SECTION = "15.8.2.14"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.random()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +for ( var item = 0; item < 100; item++ ) { + var testcase = new TestCase( SECTION, + "Math.random()", + "pass", + null ); + testcase.reason = Math.random(); + testcase.actual = "pass"; + + if ( ! ( testcase.reason >= 0) ) { + testcase.actual = "fail"; + } + + if ( ! (testcase.reason < 1) ) { + testcase.actual = "fail"; + } +} + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.15.js b/mozilla/js/tests/ecma/Math/15.8.2.15.js index 642113b8f36..82a50814389 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.15.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.15.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,95 +35,165 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.15.js - ECMA Section: 15.8.2.15 Math.round(x) - Description: return the greatest number value that is closest to the - argument and is an integer. if two integers are equally - close to the argument. then the result is the number value - that is closer to Infinity. if the argument is an integer, - return the argument. - special cases: - - if x is NaN return NaN - - if x = +0 return +0 - - if x = -0 return -0 - - if x = Infinity return Infinity - - if x = -Infinity return -Infinity - - if 0 < x < 0.5 return 0 - - if -0.5 <= x < 0 return -0 - example: - Math.round( 3.5 ) == 4 - Math.round( -3.5 ) == 3 - also: - - Math.round(x) == Math.floor( x + 0.5 ) - except if x = -0. in that case, Math.round(x) = -0 + File Name: 15.8.2.15.js + ECMA Section: 15.8.2.15 Math.round(x) + Description: return the greatest number value that is closest to the + argument and is an integer. if two integers are equally + close to the argument. then the result is the number value + that is closer to Infinity. if the argument is an integer, + return the argument. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if 0 < x < 0.5 return 0 + - if -0.5 <= x < 0 return -0 + example: + Math.round( 3.5 ) == 4 + Math.round( -3.5 ) == 3 + also: + - Math.round(x) == Math.floor( x + 0.5 ) + except if x = -0. in that case, Math.round(x) = -0 - and Math.floor( x+0.5 ) = +0 + and Math.floor( x+0.5 ) = +0 - Author: christine@netscape.com - Date: 7 july 1997 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.15"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.round(x)"; - var BUGNUMBER="331411"; +var SECTION = "15.8.2.15"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.round(x)"; +var BUGNUMBER="331411"; - var EXCLUDE = "true"; +var EXCLUDE = "true"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.round.length", + 1, + Math.round.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.round()", + Number.NaN, + Math.round() ); - array[item++] = new TestCase( SECTION, "Math.round.length", 1, Math.round.length ); +new TestCase( SECTION, + "Math.round(null)", + 0, + Math.round(0) ); - array[item++] = new TestCase( SECTION, "Math.round()", Number.NaN, Math.round() ); - array[item++] = new TestCase( SECTION, "Math.round(null)", 0, Math.round(0) ); - array[item++] = new TestCase( SECTION, "Math.round(void 0)", Number.NaN, Math.round(void 0) ); - array[item++] = new TestCase( SECTION, "Math.round(true)", 1, Math.round(true) ); - array[item++] = new TestCase( SECTION, "Math.round(false)", 0, Math.round(false) ); - array[item++] = new TestCase( SECTION, "Math.round('.99999')", 1, Math.round('.99999') ); - array[item++] = new TestCase( SECTION, "Math.round('12345e-2')", 123, Math.round('12345e-2') ); +new TestCase( SECTION, + "Math.round(void 0)", + Number.NaN, + Math.round(void 0) ); - array[item++] = new TestCase( SECTION, "Math.round(NaN)", Number.NaN, Math.round(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.round(0)", 0, Math.round(0) ); - array[item++] = new TestCase( SECTION, "Math.round(-0)", -0, Math.round(-0)); - array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0)", -Infinity, Infinity/Math.round(-0) ); +new TestCase( SECTION, + "Math.round(true)", + 1, + Math.round(true) ); - array[item++] = new TestCase( SECTION, "Math.round(Infinity)", Number.POSITIVE_INFINITY, Math.round(Number.POSITIVE_INFINITY)); - array[item++] = new TestCase( SECTION, "Math.round(-Infinity)",Number.NEGATIVE_INFINITY, Math.round(Number.NEGATIVE_INFINITY)); - array[item++] = new TestCase( SECTION, "Math.round(0.49)", 0, Math.round(0.49)); - array[item++] = new TestCase( SECTION, "Math.round(0.5)", 1, Math.round(0.5)); - array[item++] = new TestCase( SECTION, "Math.round(0.51)", 1, Math.round(0.51)); +new TestCase( SECTION, + "Math.round(false)", + 0, + Math.round(false) ); - array[item++] = new TestCase( SECTION, "Math.round(-0.49)", -0, Math.round(-0.49)); - array[item++] = new TestCase( SECTION, "Math.round(-0.5)", -0, Math.round(-0.5)); - array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0.49)", -Infinity, Infinity/Math.round(-0.49)); - array[item++] = new TestCase( SECTION, "Infinity/Math.round(-0.5)", -Infinity, Infinity/Math.round(-0.5)); +new TestCase( SECTION, + "Math.round('.99999')", + 1, + Math.round('.99999') ); - array[item++] = new TestCase( SECTION, "Math.round(-0.51)", -1, Math.round(-0.51)); - array[item++] = new TestCase( SECTION, "Math.round(3.5)", 4, Math.round(3.5)); - array[item++] = new TestCase( SECTION, "Math.round(-3.5)", -3, Math.round(-3)); +new TestCase( SECTION, + "Math.round('12345e-2')", + 123, + Math.round('12345e-2') ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.round(NaN)", + Number.NaN, + Math.round(Number.NaN) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "Math.round(0)", + 0, + Math.round(0) ); + +new TestCase( SECTION, + "Math.round(-0)", + -0, + Math.round(-0)); + +new TestCase( SECTION, + "Infinity/Math.round(-0)", + -Infinity, + Infinity/Math.round(-0) ); + +new TestCase( SECTION, + "Math.round(Infinity)", + Number.POSITIVE_INFINITY, + Math.round(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.round(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.round(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.round(0.49)", + 0, + Math.round(0.49)); + +new TestCase( SECTION, + "Math.round(0.5)", + 1, + Math.round(0.5)); + +new TestCase( SECTION, + "Math.round(0.51)", + 1, + Math.round(0.51)); + +new TestCase( SECTION, + "Math.round(-0.49)", + -0, + Math.round(-0.49)); + +new TestCase( SECTION, + "Math.round(-0.5)", + -0, + Math.round(-0.5)); + +new TestCase( SECTION, + "Infinity/Math.round(-0.49)", + -Infinity, + Infinity/Math.round(-0.49)); + +new TestCase( SECTION, + "Infinity/Math.round(-0.5)", + -Infinity, + Infinity/Math.round(-0.5)); + +new TestCase( SECTION, + "Math.round(-0.51)", + -1, + Math.round(-0.51)); + +new TestCase( SECTION, + "Math.round(3.5)", + 4, + Math.round(3.5)); + +new TestCase( SECTION, + "Math.round(-3.5)", + -3, + Math.round(-3)); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.16.js b/mozilla/js/tests/ecma/Math/15.8.2.16.js index a80c95ad661..e79aab8051d 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.16.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.16.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,60 +35,96 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.16.js - ECMA Section: 15.8.2.16 sin( x ) - Description: return an approximation to the sine of the - argument. argument is expressed in radians - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.16.js + ECMA Section: 15.8.2.16 sin( x ) + Description: return an approximation to the sine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.16"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.sin(x)"; +var SECTION = "15.8.2.16"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.sin(x)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.sin.length", + 1, + Math.sin.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.sin()", + Number.NaN, + Math.sin() ); - array[item++] = new TestCase( SECTION, "Math.sin.length", 1, Math.sin.length ); +new TestCase( SECTION, + "Math.sin(null)", + 0, + Math.sin(null) ); - array[item++] = new TestCase( SECTION, "Math.sin()", Number.NaN, Math.sin() ); - array[item++] = new TestCase( SECTION, "Math.sin(null)", 0, Math.sin(null) ); - array[item++] = new TestCase( SECTION, "Math.sin(void 0)", Number.NaN, Math.sin(void 0) ); - array[item++] = new TestCase( SECTION, "Math.sin(false)", 0, Math.sin(false) ); - array[item++] = new TestCase( SECTION, "Math.sin('2.356194490192')", 0.7071067811865, Math.sin('2.356194490192') ); +new TestCase( SECTION, + "Math.sin(void 0)", + Number.NaN, + Math.sin(void 0) ); - array[item++] = new TestCase( SECTION, "Math.sin(NaN)", Number.NaN, Math.sin(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.sin(0)", 0, Math.sin(0) ); - array[item++] = new TestCase( SECTION, "Math.sin(-0)", -0, Math.sin(-0)); - array[item++] = new TestCase( SECTION, "Math.sin(Infinity)", Number.NaN, Math.sin(Number.POSITIVE_INFINITY)); - array[item++] = new TestCase( SECTION, "Math.sin(-Infinity)", Number.NaN, Math.sin(Number.NEGATIVE_INFINITY)); - array[item++] = new TestCase( SECTION, "Math.sin(0.7853981633974)", 0.7071067811865, Math.sin(0.7853981633974)); - array[item++] = new TestCase( SECTION, "Math.sin(1.570796326795)", 1, Math.sin(1.570796326795)); - array[item++] = new TestCase( SECTION, "Math.sin(2.356194490192)", 0.7071067811865, Math.sin(2.356194490192)); - array[item++] = new TestCase( SECTION, "Math.sin(3.14159265359)", 0, Math.sin(3.14159265359)); +new TestCase( SECTION, + "Math.sin(false)", + 0, + Math.sin(false) ); - return ( array ); -} +new TestCase( SECTION, + "Math.sin('2.356194490192')", + 0.7071067811865, + Math.sin('2.356194490192') ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.sin(NaN)", + Number.NaN, + Math.sin(Number.NaN) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "Math.sin(0)", + 0, + Math.sin(0) ); + +new TestCase( SECTION, + "Math.sin(-0)", + -0, + Math.sin(-0)); + +new TestCase( SECTION, + "Math.sin(Infinity)", + Number.NaN, + Math.sin(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sin(-Infinity)", + Number.NaN, + Math.sin(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sin(0.7853981633974)", + 0.7071067811865, + Math.sin(0.7853981633974)); + +new TestCase( SECTION, + "Math.sin(1.570796326795)", + 1, + Math.sin(1.570796326795)); + +new TestCase( SECTION, + "Math.sin(2.356194490192)", + 0.7071067811865, + Math.sin(2.356194490192)); + +new TestCase( SECTION, + "Math.sin(3.14159265359)", + 0, + Math.sin(3.14159265359)); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.17.js b/mozilla/js/tests/ecma/Math/15.8.2.17.js index e1b17412961..46ef565d059 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.17.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.17.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,181 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.17.js - ECMA Section: 15.8.2.17 Math.sqrt(x) - Description: return an approximation to the squareroot of the argument. - special cases: - - if x is NaN return NaN - - if x < 0 return NaN - - if x == 0 return 0 - - if x == -0 return -0 - - if x == Infinity return Infinity - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.17.js + ECMA Section: 15.8.2.17 Math.sqrt(x) + Description: return an approximation to the squareroot of the argument. + special cases: + - if x is NaN return NaN + - if x < 0 return NaN + - if x == 0 return 0 + - if x == -0 return -0 + - if x == Infinity return Infinity + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.17"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.sqrt(x)"; +var SECTION = "15.8.2.17"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.sqrt(x)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.sqrt.length", + 1, + Math.sqrt.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.sqrt()", + Number.NaN, + Math.sqrt() ); - array[item++] = new TestCase( SECTION, "Math.sqrt.length", 1, Math.sqrt.length ); +new TestCase( SECTION, + "Math.sqrt(void 0)", + Number.NaN, + Math.sqrt(void 0) ); - array[item++] = new TestCase( SECTION, "Math.sqrt()", Number.NaN, Math.sqrt() ); - array[item++] = new TestCase( SECTION, "Math.sqrt(void 0)", Number.NaN, Math.sqrt(void 0) ); - array[item++] = new TestCase( SECTION, "Math.sqrt(null)", 0, Math.sqrt(null) ); - array[item++] = new TestCase( SECTION, "Math.sqrt(true)", 1, Math.sqrt(1) ); - array[item++] = new TestCase( SECTION, "Math.sqrt(false)", 0, Math.sqrt(false) ); - array[item++] = new TestCase( SECTION, "Math.sqrt('225')", 15, Math.sqrt('225') ); +new TestCase( SECTION, + "Math.sqrt(null)", + 0, + Math.sqrt(null) ); - array[item++] = new TestCase( SECTION, "Math.sqrt(NaN)", Number.NaN, Math.sqrt(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.sqrt(-Infinity)", Number.NaN, Math.sqrt(Number.NEGATIVE_INFINITY)); - array[item++] = new TestCase( SECTION, "Math.sqrt(-1)", Number.NaN, Math.sqrt(-1)); - array[item++] = new TestCase( SECTION, "Math.sqrt(-0.5)", Number.NaN, Math.sqrt(-0.5)); - array[item++] = new TestCase( SECTION, "Math.sqrt(0)", 0, Math.sqrt(0)); - array[item++] = new TestCase( SECTION, "Math.sqrt(-0)", -0, Math.sqrt(-0)); - array[item++] = new TestCase( SECTION, "Infinity/Math.sqrt(-0)", -Infinity, Infinity/Math.sqrt(-0) ); - array[item++] = new TestCase( SECTION, "Math.sqrt(Infinity)", Number.POSITIVE_INFINITY, Math.sqrt(Number.POSITIVE_INFINITY)); - array[item++] = new TestCase( SECTION, "Math.sqrt(1)", 1, Math.sqrt(1)); - array[item++] = new TestCase( SECTION, "Math.sqrt(2)", Math.SQRT2, Math.sqrt(2)); - array[item++] = new TestCase( SECTION, "Math.sqrt(0.5)", Math.SQRT1_2, Math.sqrt(0.5)); - array[item++] = new TestCase( SECTION, "Math.sqrt(4)", 2, Math.sqrt(4)); - array[item++] = new TestCase( SECTION, "Math.sqrt(9)", 3, Math.sqrt(9)); - array[item++] = new TestCase( SECTION, "Math.sqrt(16)", 4, Math.sqrt(16)); - array[item++] = new TestCase( SECTION, "Math.sqrt(25)", 5, Math.sqrt(25)); - array[item++] = new TestCase( SECTION, "Math.sqrt(36)", 6, Math.sqrt(36)); - array[item++] = new TestCase( SECTION, "Math.sqrt(49)", 7, Math.sqrt(49)); - array[item++] = new TestCase( SECTION, "Math.sqrt(64)", 8, Math.sqrt(64)); - array[item++] = new TestCase( SECTION, "Math.sqrt(256)", 16, Math.sqrt(256)); - array[item++] = new TestCase( SECTION, "Math.sqrt(10000)", 100, Math.sqrt(10000)); - array[item++] = new TestCase( SECTION, "Math.sqrt(65536)", 256, Math.sqrt(65536)); - array[item++] = new TestCase( SECTION, "Math.sqrt(0.09)", 0.3, Math.sqrt(0.09)); - array[item++] = new TestCase( SECTION, "Math.sqrt(0.01)", 0.1, Math.sqrt(0.01)); - array[item++] = new TestCase( SECTION, "Math.sqrt(0.00000001)",0.0001, Math.sqrt(0.00000001)); +new TestCase( SECTION, + "Math.sqrt(true)", + 1, + Math.sqrt(1) ); - return ( array ); -} +new TestCase( SECTION, + "Math.sqrt(false)", + 0, + Math.sqrt(false) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.sqrt('225')", + 15, + Math.sqrt('225') ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "Math.sqrt(NaN)", + Number.NaN, + Math.sqrt(Number.NaN) ); + +new TestCase( SECTION, + "Math.sqrt(-Infinity)", + Number.NaN, + Math.sqrt(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sqrt(-1)", + Number.NaN, + Math.sqrt(-1)); + +new TestCase( SECTION, + "Math.sqrt(-0.5)", + Number.NaN, + Math.sqrt(-0.5)); + +new TestCase( SECTION, + "Math.sqrt(0)", + 0, + Math.sqrt(0)); + +new TestCase( SECTION, + "Math.sqrt(-0)", + -0, + Math.sqrt(-0)); + +new TestCase( SECTION, + "Infinity/Math.sqrt(-0)", + -Infinity, + Infinity/Math.sqrt(-0) ); + +new TestCase( SECTION, + "Math.sqrt(Infinity)", + Number.POSITIVE_INFINITY, + Math.sqrt(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.sqrt(1)", + 1, + Math.sqrt(1)); + +new TestCase( SECTION, + "Math.sqrt(2)", + Math.SQRT2, + Math.sqrt(2)); + +new TestCase( SECTION, + "Math.sqrt(0.5)", + Math.SQRT1_2, + Math.sqrt(0.5)); + +new TestCase( SECTION, + "Math.sqrt(4)", + 2, + Math.sqrt(4)); + +new TestCase( SECTION, + "Math.sqrt(9)", + 3, + Math.sqrt(9)); + +new TestCase( SECTION, + "Math.sqrt(16)", + 4, + Math.sqrt(16)); + +new TestCase( SECTION, + "Math.sqrt(25)", + 5, + Math.sqrt(25)); + +new TestCase( SECTION, + "Math.sqrt(36)", + 6, + Math.sqrt(36)); + +new TestCase( SECTION, + "Math.sqrt(49)", + 7, + Math.sqrt(49)); + +new TestCase( SECTION, + "Math.sqrt(64)", + 8, + Math.sqrt(64)); + +new TestCase( SECTION, + "Math.sqrt(256)", + 16, + Math.sqrt(256)); + +new TestCase( SECTION, + "Math.sqrt(10000)", + 100, + Math.sqrt(10000)); + +new TestCase( SECTION, + "Math.sqrt(65536)", + 256, + Math.sqrt(65536)); + +new TestCase( SECTION, + "Math.sqrt(0.09)", + 0.3, + Math.sqrt(0.09)); + +new TestCase( SECTION, + "Math.sqrt(0.01)", + 0.1, + Math.sqrt(0.01)); + +new TestCase( SECTION, + "Math.sqrt(0.00000001)", + 0.0001, + Math.sqrt(0.00000001)); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.18.js b/mozilla/js/tests/ecma/Math/15.8.2.18.js index 4efac16be9b..994eab8a6eb 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.18.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.18.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,129 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.18.js - ECMA Section: 15.8.2.18 tan( x ) - Description: return an approximation to the tan of the - argument. argument is expressed in radians - special cases: - - if x is NaN result is NaN - - if x is 0 result is 0 - - if x is -0 result is -0 - - if x is Infinity or -Infinity result is NaN - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.18.js + ECMA Section: 15.8.2.18 tan( x ) + Description: return an approximation to the tan of the + argument. argument is expressed in radians + special cases: + - if x is NaN result is NaN + - if x is 0 result is 0 + - if x is -0 result is -0 + - if x is Infinity or -Infinity result is NaN + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.18"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.tan(x)"; - var EXCLUDE = "true"; +var SECTION = "15.8.2.18"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.tan(x)"; +var EXCLUDE = "true"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.tan.length", + 1, + Math.tan.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.tan()", + Number.NaN, + Math.tan() ); - array[item++] = new TestCase( SECTION, "Math.tan.length", 1, Math.tan.length ); +new TestCase( SECTION, + "Math.tan(void 0)", + Number.NaN, + Math.tan(void 0)); - array[item++] = new TestCase( SECTION, "Math.tan()", Number.NaN, Math.tan() ); - array[item++] = new TestCase( SECTION, "Math.tan(void 0)", Number.NaN, Math.tan(void 0)); - array[item++] = new TestCase( SECTION, "Math.tan(null)", 0, Math.tan(null) ); - array[item++] = new TestCase( SECTION, "Math.tan(false)", 0, Math.tan(false) ); +new TestCase( SECTION, + "Math.tan(null)", + 0, + Math.tan(null) ); - array[item++] = new TestCase( SECTION, "Math.tan(NaN)", Number.NaN, Math.tan(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.tan(0)", 0, Math.tan(0)); - array[item++] = new TestCase( SECTION, "Math.tan(-0)", -0, Math.tan(-0)); - array[item++] = new TestCase( SECTION, "Math.tan(Infinity)", Number.NaN, Math.tan(Number.POSITIVE_INFINITY)); - array[item++] = new TestCase( SECTION, "Math.tan(-Infinity)", Number.NaN, Math.tan(Number.NEGATIVE_INFINITY)); - array[item++] = new TestCase( SECTION, "Math.tan(Math.PI/4)", 1, Math.tan(Math.PI/4)); - array[item++] = new TestCase( SECTION, "Math.tan(3*Math.PI/4)", -1, Math.tan(3*Math.PI/4)); - array[item++] = new TestCase( SECTION, "Math.tan(Math.PI)", -0, Math.tan(Math.PI)); - array[item++] = new TestCase( SECTION, "Math.tan(5*Math.PI/4)", 1, Math.tan(5*Math.PI/4)); - array[item++] = new TestCase( SECTION, "Math.tan(7*Math.PI/4)", -1, Math.tan(7*Math.PI/4)); - array[item++] = new TestCase( SECTION, "Infinity/Math.tan(-0)", -Infinity, Infinity/Math.tan(-0) ); +new TestCase( SECTION, + "Math.tan(false)", + 0, + Math.tan(false) ); + +new TestCase( SECTION, + "Math.tan(NaN)", + Number.NaN, + Math.tan(Number.NaN) ); + +new TestCase( SECTION, + "Math.tan(0)", + 0, + Math.tan(0)); + +new TestCase( SECTION, + "Math.tan(-0)", + -0, + Math.tan(-0)); + +new TestCase( SECTION, + "Math.tan(Infinity)", + Number.NaN, + Math.tan(Number.POSITIVE_INFINITY)); + +new TestCase( SECTION, + "Math.tan(-Infinity)", + Number.NaN, + Math.tan(Number.NEGATIVE_INFINITY)); + +new TestCase( SECTION, + "Math.tan(Math.PI/4)", + 1, + Math.tan(Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(3*Math.PI/4)", + -1, + Math.tan(3*Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(Math.PI)", + -0, + Math.tan(Math.PI)); + +new TestCase( SECTION, + "Math.tan(5*Math.PI/4)", + 1, + Math.tan(5*Math.PI/4)); + +new TestCase( SECTION, + "Math.tan(7*Math.PI/4)", + -1, + Math.tan(7*Math.PI/4)); + +new TestCase( SECTION, + "Infinity/Math.tan(-0)", + -Infinity, + Infinity/Math.tan(-0) ); /* - Arctan (x) ~ PI/2 - 1/x for large x. For x = 1.6x10^16, 1/x is about the last binary digit of double precision PI/2. - That is to say, perturbing PI/2 by this much is about the smallest rounding error possible. + Arctan (x) ~ PI/2 - 1/x for large x. For x = 1.6x10^16, 1/x is about the last binary digit of double precision PI/2. + That is to say, perturbing PI/2 by this much is about the smallest rounding error possible. - This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I - suspect that tan (PI/2 + one ulp) is a negative result about the same size as tan (PI/2) and that this pair are the closest - results to infinity that the algorithm can deliver. + This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I + suspect that tan (PI/2 + one ulp) is a negative result about the same size as tan (PI/2) and that this pair are the closest + results to infinity that the algorithm can deliver. - In any case, my call is that the answer we're seeing is "right". I suggest the test pass on any result this size or larger. - = C = + In any case, my call is that the answer we're seeing is "right". I suggest the test pass on any result this size or larger. + = C = */ - array[item++] = new TestCase( SECTION, "Math.tan(3*Math.PI/2) >= 5443000000000000", true, Math.tan(3*Math.PI/2) >= 5443000000000000 ); - array[item++] = new TestCase( SECTION, "Math.tan(Math.PI/2) >= 5443000000000000", true, Math.tan(Math.PI/2) >= 5443000000000000 ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.tan(3*Math.PI/2) >= 5443000000000000", + true, + Math.tan(3*Math.PI/2) >= 5443000000000000 ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.tan(Math.PI/2) >= 5443000000000000", + true, + Math.tan(Math.PI/2) >= 5443000000000000 ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.2.js b/mozilla/js/tests/ecma/Math/15.8.2.2.js index e59b5ef66c1..3e4d6851bb5 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.2.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,68 +35,114 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.2.2.js - ECMA Section: 15.8.2.2 acos( x ) - Description: return an approximation to the arc cosine of the - argument. the result is expressed in radians and - range is from +0 to +PI. special cases: - - if x is NaN, return NaN - - if x > 1, the result is NaN - - if x < -1, the result is NaN - - if x == 1, the result is +0 - Author: christine@netscape.com - Date: 7 july 1997 -*/ - var SECTION = "15.8.2.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.acos()"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "Math.acos.length", 1, Math.acos.length ); - - array[item++] = new TestCase( SECTION, "Math.acos(void 0)", Number.NaN, Math.acos(void 0) ); - array[item++] = new TestCase( SECTION, "Math.acos()", Number.NaN, Math.acos() ); - array[item++] = new TestCase( SECTION, "Math.acos(null)", Math.PI/2, Math.acos(null) ); - array[item++] = new TestCase( SECTION, "Math.acos(NaN)", Number.NaN, Math.acos(Number.NaN) ); - - array[item++] = new TestCase( SECTION, "Math.acos(a string)", Number.NaN, Math.acos("a string") ); - array[item++] = new TestCase( SECTION, "Math.acos('0')", Math.PI/2, Math.acos('0') ); - array[item++] = new TestCase( SECTION, "Math.acos('1')", 0, Math.acos('1') ); - array[item++] = new TestCase( SECTION, "Math.acos('-1')", Math.PI, Math.acos('-1') ); - - array[item++] = new TestCase( SECTION, "Math.acos(1.00000001)", Number.NaN, Math.acos(1.00000001) ); - array[item++] = new TestCase( SECTION, "Math.acos(11.00000001)", Number.NaN, Math.acos(-1.00000001) ); - array[item++] = new TestCase( SECTION, "Math.acos(1)", 0, Math.acos(1) ); - array[item++] = new TestCase( SECTION, "Math.acos(-1)", Math.PI, Math.acos(-1) ); - array[item++] = new TestCase( SECTION, "Math.acos(0)", Math.PI/2, Math.acos(0) ); - array[item++] = new TestCase( SECTION, "Math.acos(-0)", Math.PI/2, Math.acos(-0) ); - array[item++] = new TestCase( SECTION, "Math.acos(Math.SQRT1_2)", Math.PI/4, Math.acos(Math.SQRT1_2)); - array[item++] = new TestCase( SECTION, "Math.acos(-Math.SQRT1_2)", Math.PI/4*3, Math.acos(-Math.SQRT1_2)); - array[item++] = new TestCase( SECTION, "Math.acos(0.9999619230642)", Math.PI/360, Math.acos(0.9999619230642)); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.2.2.js + ECMA Section: 15.8.2.2 acos( x ) + Description: return an approximation to the arc cosine of the + argument. the result is expressed in radians and + range is from +0 to +PI. special cases: + - if x is NaN, return NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == 1, the result is +0 + Author: christine@netscape.com + Date: 7 july 1997 +*/ +var SECTION = "15.8.2.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.acos()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.acos.length", + 1, + Math.acos.length ); + +new TestCase( SECTION, + "Math.acos(void 0)", + Number.NaN, + Math.acos(void 0) ); + +new TestCase( SECTION, + "Math.acos()", + Number.NaN, + Math.acos() ); + +new TestCase( SECTION, + "Math.acos(null)", + Math.PI/2, + Math.acos(null) ); + +new TestCase( SECTION, + "Math.acos(NaN)", + Number.NaN, + Math.acos(Number.NaN) ); + +new TestCase( SECTION, + "Math.acos(a string)", + Number.NaN, + Math.acos("a string") ); + +new TestCase( SECTION, + "Math.acos('0')", + Math.PI/2, + Math.acos('0') ); + +new TestCase( SECTION, + "Math.acos('1')", + 0, + Math.acos('1') ); + +new TestCase( SECTION, + "Math.acos('-1')", + Math.PI, + Math.acos('-1') ); + +new TestCase( SECTION, + "Math.acos(1.00000001)", + Number.NaN, + Math.acos(1.00000001) ); + +new TestCase( SECTION, + "Math.acos(11.00000001)", + Number.NaN, + Math.acos(-1.00000001) ); + +new TestCase( SECTION, + "Math.acos(1)", + 0, + Math.acos(1) ); + +new TestCase( SECTION, + "Math.acos(-1)", + Math.PI, + Math.acos(-1) ); + +new TestCase( SECTION, + "Math.acos(0)", + Math.PI/2, + Math.acos(0) ); + +new TestCase( SECTION, + "Math.acos(-0)", + Math.PI/2, + Math.acos(-0) ); + +new TestCase( SECTION, + "Math.acos(Math.SQRT1_2)", + Math.PI/4, + Math.acos(Math.SQRT1_2)); + +new TestCase( SECTION, + "Math.acos(-Math.SQRT1_2)", + Math.PI/4*3, + Math.acos(-Math.SQRT1_2)); + +new TestCase( SECTION, + "Math.acos(0.9999619230642)", + Math.PI/360, + Math.acos(0.9999619230642)); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.3.js b/mozilla/js/tests/ecma/Math/15.8.2.3.js index f9b751608e1..2e9e1a68660 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.3.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,122 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.3.js - ECMA Section: 15.8.2.3 asin( x ) - Description: return an approximation to the arc sine of the - argument. the result is expressed in radians and - range is from -PI/2 to +PI/2. special cases: - - if x is NaN, the result is NaN - - if x > 1, the result is NaN - - if x < -1, the result is NaN - - if x == +0, the result is +0 - - if x == -0, the result is -0 - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.3.js + ECMA Section: 15.8.2.3 asin( x ) + Description: return an approximation to the arc sine of the + argument. the result is expressed in radians and + range is from -PI/2 to +PI/2. special cases: + - if x is NaN, the result is NaN + - if x > 1, the result is NaN + - if x < -1, the result is NaN + - if x == +0, the result is +0 + - if x == -0, the result is -0 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.asin()"; +var SECTION = "15.8.2.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.asin()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.asin()", + Number.NaN, + Math.asin() ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.asin(void 0)", + Number.NaN, + Math.asin(void 0) ); - array[item++] = new TestCase( SECTION, "Math.asin()", Number.NaN, Math.asin() ); - array[item++] = new TestCase( SECTION, "Math.asin(void 0)", Number.NaN, Math.asin(void 0) ); - array[item++] = new TestCase( SECTION, "Math.asin(null)", 0, Math.asin(null) ); - array[item++] = new TestCase( SECTION, "Math.asin(NaN)", Number.NaN, Math.asin(Number.NaN) ); +new TestCase( SECTION, + "Math.asin(null)", + 0, + Math.asin(null) ); - array[item++] = new TestCase( SECTION, "Math.asin('string')", Number.NaN, Math.asin("string") ); - array[item++] = new TestCase( SECTION, "Math.asin('0')", 0, Math.asin("0") ); - array[item++] = new TestCase( SECTION, "Math.asin('1')", Math.PI/2, Math.asin("1") ); - array[item++] = new TestCase( SECTION, "Math.asin('-1')", -Math.PI/2, Math.asin("-1") ); - array[item++] = new TestCase( SECTION, "Math.asin(Math.SQRT1_2+'')", Math.PI/4, Math.asin(Math.SQRT1_2+'') ); - array[item++] = new TestCase( SECTION, "Math.asin(-Math.SQRT1_2+'')", -Math.PI/4, Math.asin(-Math.SQRT1_2+'') ); +new TestCase( SECTION, + "Math.asin(NaN)", + Number.NaN, + Math.asin(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.asin(1.000001)", Number.NaN, Math.asin(1.000001) ); - array[item++] = new TestCase( SECTION, "Math.asin(-1.000001)", Number.NaN, Math.asin(-1.000001) ); - array[item++] = new TestCase( SECTION, "Math.asin(0)", 0, Math.asin(0) ); - array[item++] = new TestCase( SECTION, "Math.asin(-0)", -0, Math.asin(-0) ); +new TestCase( SECTION, + "Math.asin('string')", + Number.NaN, + Math.asin("string") ); - array[item++] = new TestCase( SECTION, "Infinity/Math.asin(-0)", -Infinity, Infinity/Math.asin(-0) ); +new TestCase( SECTION, + "Math.asin('0')", + 0, + Math.asin("0") ); - array[item++] = new TestCase( SECTION, "Math.asin(1)", Math.PI/2, Math.asin(1) ); - array[item++] = new TestCase( SECTION, "Math.asin(-1)", -Math.PI/2, Math.asin(-1) ); - array[item++] = new TestCase( SECTION, "Math.asin(Math.SQRT1_2))", Math.PI/4, Math.asin(Math.SQRT1_2) ); - array[item++] = new TestCase( SECTION, "Math.asin(-Math.SQRT1_2))", -Math.PI/4, Math.asin(-Math.SQRT1_2)); +new TestCase( SECTION, + "Math.asin('1')", + Math.PI/2, + Math.asin("1") ); - return ( array ); -} +new TestCase( SECTION, + "Math.asin('-1')", + -Math.PI/2, + Math.asin("-1") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.asin(Math.SQRT1_2+'')", + Math.PI/4, + Math.asin(Math.SQRT1_2+'') ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "Math.asin(-Math.SQRT1_2+'')", + -Math.PI/4, + Math.asin(-Math.SQRT1_2+'') ); + +new TestCase( SECTION, + "Math.asin(1.000001)", + Number.NaN, + Math.asin(1.000001) ); + +new TestCase( SECTION, + "Math.asin(-1.000001)", + Number.NaN, + Math.asin(-1.000001) ); + +new TestCase( SECTION, + "Math.asin(0)", + 0, + Math.asin(0) ); + +new TestCase( SECTION, + "Math.asin(-0)", + -0, + Math.asin(-0) ); + +new TestCase( SECTION, + "Infinity/Math.asin(-0)", + -Infinity, + Infinity/Math.asin(-0) ); + +new TestCase( SECTION, + "Math.asin(1)", + Math.PI/2, + Math.asin(1) ); + +new TestCase( SECTION, + "Math.asin(-1)", + -Math.PI/2, + Math.asin(-1) ); + +new TestCase( SECTION, + "Math.asin(Math.SQRT1_2))", + Math.PI/4, + Math.asin(Math.SQRT1_2) ); + +new TestCase( SECTION, + "Math.asin(-Math.SQRT1_2))", + -Math.PI/4, + Math.asin(-Math.SQRT1_2)); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.4.js b/mozilla/js/tests/ecma/Math/15.8.2.4.js index 0643ba76e20..043ebaf5b68 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.4.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -50,54 +51,102 @@ */ - var SECTION = "15.8.2.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.atan()"; - var BUGNUMBER="77391"; +var SECTION = "15.8.2.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.atan()"; +var BUGNUMBER="77391"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.atan.length", + 1, + Math.atan.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.atan()", + Number.NaN, + Math.atan() ); - array[item++] = new TestCase( SECTION, "Math.atan.length", 1, Math.atan.length ); +new TestCase( SECTION, + "Math.atan(void 0)", + Number.NaN, + Math.atan(void 0) ); - array[item++] = new TestCase( SECTION, "Math.atan()", Number.NaN, Math.atan() ); - array[item++] = new TestCase( SECTION, "Math.atan(void 0)", Number.NaN, Math.atan(void 0) ); - array[item++] = new TestCase( SECTION, "Math.atan(null)", 0, Math.atan(null) ); - array[item++] = new TestCase( SECTION, "Math.atan(NaN)", Number.NaN, Math.atan(Number.NaN) ); +new TestCase( SECTION, + "Math.atan(null)", + 0, + Math.atan(null) ); - array[item++] = new TestCase( SECTION, "Math.atan('a string')", Number.NaN, Math.atan("a string") ); - array[item++] = new TestCase( SECTION, "Math.atan('0')", 0, Math.atan('0') ); - array[item++] = new TestCase( SECTION, "Math.atan('1')", Math.PI/4, Math.atan('1') ); - array[item++] = new TestCase( SECTION, "Math.atan('-1')", -Math.PI/4, Math.atan('-1') ); - array[item++] = new TestCase( SECTION, "Math.atan('Infinity)", Math.PI/2, Math.atan('Infinity') ); - array[item++] = new TestCase( SECTION, "Math.atan('-Infinity)", -Math.PI/2, Math.atan('-Infinity') ); +new TestCase( SECTION, + "Math.atan(NaN)", + Number.NaN, + Math.atan(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.atan(0)", 0, Math.atan(0) ); - array[item++] = new TestCase( SECTION, "Math.atan(-0)", -0, Math.atan(-0) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.atan(-0)", -Infinity, Infinity/Math.atan(-0) ); - array[item++] = new TestCase( SECTION, "Math.atan(Infinity)", Math.PI/2, Math.atan(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.atan(-Infinity)", -Math.PI/2, Math.atan(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.atan(1)", Math.PI/4, Math.atan(1) ); - array[item++] = new TestCase( SECTION, "Math.atan(-1)", -Math.PI/4, Math.atan(-1) ); - return array; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.atan('a string')", + Number.NaN, + Math.atan("a string") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "Math.atan('0')", + 0, + Math.atan('0') ); + +new TestCase( SECTION, + "Math.atan('1')", + Math.PI/4, + Math.atan('1') ); + +new TestCase( SECTION, + "Math.atan('-1')", + -Math.PI/4, + Math.atan('-1') ); + +new TestCase( SECTION, + "Math.atan('Infinity)", + Math.PI/2, + Math.atan('Infinity') ); + +new TestCase( SECTION, + "Math.atan('-Infinity)", + -Math.PI/2, + Math.atan('-Infinity') ); + +new TestCase( SECTION, + "Math.atan(0)", + 0, + Math.atan(0) ); + +new TestCase( SECTION, + "Math.atan(-0)", + -0, + Math.atan(-0) ); + +new TestCase( SECTION, + "Infinity/Math.atan(-0)", + -Infinity, + Infinity/Math.atan(-0) ); + +new TestCase( SECTION, + "Math.atan(Infinity)", + Math.PI/2, + Math.atan(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan(-Infinity)", + -Math.PI/2, + Math.atan(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan(1)", + Math.PI/4, + Math.atan(1) ); + +new TestCase( SECTION, + "Math.atan(-1)", + -Math.PI/4, + Math.atan(-1) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.5.js b/mozilla/js/tests/ecma/Math/15.8.2.5.js index 84ced54cbd0..a89c729a9ed 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.5.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,87 +35,207 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.2.5.js - ECMA Section: 15.8.2.5 atan2( y, x ) - Description: - Author: christine@netscape.com - Date: 7 july 1997 +/** + File Name: 15.8.2.5.js + ECMA Section: 15.8.2.5 atan2( y, x ) + Description: + + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.atan2(x,y)"; - var BUGNUMBER="76111"; +var SECTION = "15.8.2.5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.atan2(x,y)"; +var BUGNUMBER="76111"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.atan2.length", + 2, + Math.atan2.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.atan2(NaN, 0)", + Number.NaN, + Math.atan2(Number.NaN,0) ); - array[item++] = new TestCase( SECTION, "Math.atan2.length", 2, Math.atan2.length ); +new TestCase( SECTION, + "Math.atan2(null, null)", + 0, + Math.atan2(null, null) ); - array[item++] = new TestCase( SECTION, "Math.atan2(NaN, 0)", Number.NaN, Math.atan2(Number.NaN,0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(null, null)", 0, Math.atan2(null, null) ); - array[item++] = new TestCase( SECTION, "Math.atan2(void 0, void 0)", Number.NaN, Math.atan2(void 0, void 0) ); - array[item++] = new TestCase( SECTION, "Math.atan2()", Number.NaN, Math.atan2() ); +new TestCase( SECTION, + "Math.atan2(void 0, void 0)", + Number.NaN, + Math.atan2(void 0, void 0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(0, NaN)", Number.NaN, Math.atan2(0,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.atan2(1, 0)", Math.PI/2, Math.atan2(1,0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(1,-0)", Math.PI/2, Math.atan2(1,-0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(0,0.001)", 0, Math.atan2(0,0.001) ); - array[item++] = new TestCase( SECTION, "Math.atan2(0,0)", 0, Math.atan2(0,0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(0, -0)", Math.PI, Math.atan2(0,-0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(0, -1)", Math.PI, Math.atan2(0, -1) ); +new TestCase( SECTION, + "Math.atan2()", + Number.NaN, + Math.atan2() ); - array[item++] = new TestCase( SECTION, "Math.atan2(-0, 1)", -0, Math.atan2(-0, 1) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.atan2(-0, 1)", -Infinity, Infinity/Math.atan2(-0,1) ); +new TestCase( SECTION, + "Math.atan2(0, NaN)", + Number.NaN, + Math.atan2(0,Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-0, 0)", -0, Math.atan2(-0,0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-0, -0)", -Math.PI, Math.atan2(-0, -0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-0, -1)", -Math.PI, Math.atan2(-0, -1) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-1, 0)", -Math.PI/2, Math.atan2(-1, 0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-1, -0)", -Math.PI/2, Math.atan2(-1, -0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(1, Infinity)", 0, Math.atan2(1, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.atan2(1,-Infinity)", Math.PI, Math.atan2(1, Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, + "Math.atan2(1, 0)", + Math.PI/2, + Math.atan2(1,0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-1, Infinity)", -0, Math.atan2(-1,Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.atan2(-1, Infinity)", -Infinity, Infinity/Math.atan2(-1,Infinity) ); +new TestCase( SECTION, + "Math.atan2(1,-0)", + Math.PI/2, + Math.atan2(1,-0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-1,-Infinity)", -Math.PI, Math.atan2(-1,Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, 0)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY, 0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, 1)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY, 1) ); - array[item++] = new TestCase( SECTION, "Math.atan2(Infinity,-1)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY,-1) ); - array[item++] = new TestCase( SECTION, "Math.atan2(Infinity,-0)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY,-0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, 0)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY, 0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity,-0)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY,-0) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, 1)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY, 1) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, -1)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY,-1) ); - array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, Infinity)", Math.PI/4, Math.atan2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, -Infinity)", 3*Math.PI/4, Math.atan2(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, Infinity)", -Math.PI/4, Math.atan2(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, -Infinity)", -3*Math.PI/4, Math.atan2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.atan2(-1, 1)", -Math.PI/4, Math.atan2( -1, 1) ); +new TestCase( SECTION, + "Math.atan2(0,0.001)", + 0, + Math.atan2(0,0.001) ); - return array; -} +new TestCase( SECTION, + "Math.atan2(0,0)", + 0, + Math.atan2(0,0) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.atan2(0, -0)", + Math.PI, + Math.atan2(0,-0) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.atan2(0, -1)", + Math.PI, + Math.atan2(0, -1) ); + +new TestCase( SECTION, + "Math.atan2(-0, 1)", + -0, + Math.atan2(-0, 1) ); + +new TestCase( SECTION, + "Infinity/Math.atan2(-0, 1)", + -Infinity, + Infinity/Math.atan2(-0,1) ); + +new TestCase( SECTION, + "Math.atan2(-0, 0)", + -0, + Math.atan2(-0,0) ); + +new TestCase( SECTION, + "Math.atan2(-0, -0)", + -Math.PI, + Math.atan2(-0, -0) ); + +new TestCase( SECTION, + "Math.atan2(-0, -1)", + -Math.PI, + Math.atan2(-0, -1) ); + +new TestCase( SECTION, + "Math.atan2(-1, 0)", + -Math.PI/2, + Math.atan2(-1, 0) ); + +new TestCase( SECTION, + "Math.atan2(-1, -0)", + -Math.PI/2, + Math.atan2(-1, -0) ); + +new TestCase( SECTION, + "Math.atan2(1, Infinity)", + 0, + Math.atan2(1, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(1,-Infinity)", + Math.PI, + Math.atan2(1, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-1, Infinity)", + -0, + Math.atan2(-1,Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Infinity/Math.atan2(-1, Infinity)", + -Infinity, + Infinity/Math.atan2(-1,Infinity) ); + +new TestCase( SECTION, + "Math.atan2(-1,-Infinity)", + -Math.PI, + Math.atan2(-1,Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, 0)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY, 0) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, 1)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity,-1)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY,-1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity,-0)", + Math.PI/2, + Math.atan2(Number.POSITIVE_INFINITY,-0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, 0)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY, 0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity,-0)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY,-0) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, 1)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY, 1) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, -1)", + -Math.PI/2, + Math.atan2(Number.NEGATIVE_INFINITY,-1) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, Infinity)", + Math.PI/4, + Math.atan2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(Infinity, -Infinity)", + 3*Math.PI/4, + Math.atan2(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, Infinity)", + -Math.PI/4, + Math.atan2(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-Infinity, -Infinity)", + -3*Math.PI/4, + Math.atan2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.atan2(-1, 1)", + -Math.PI/4, + Math.atan2( -1, 1) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.6.js b/mozilla/js/tests/ecma/Math/15.8.2.6.js index 48a6578dd93..1353c022b3e 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.6.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,90 +35,195 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.8.2.6.js - ECMA Section: 15.8.2.6 Math.ceil(x) - Description: return the smallest number value that is not less than the - argument and is equal to a mathematical integer. if the - number is already an integer, return the number itself. - special cases: - - if x is NaN return NaN - - if x = +0 return +0 - - if x = 0 return -0 - - if x = Infinity return Infinity - - if x = -Infinity return -Infinity - - if ( -1 < x < 0 ) return -0 - also: - - the value of Math.ceil(x) == -Math.ceil(-x) - Author: christine@netscape.com - Date: 7 july 1997 -*/ - var SECTION = "15.8.2.6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.ceil(x)"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "Math.ceil.length", 1, Math.ceil.length ); - - array[item++] = new TestCase( SECTION, "Math.ceil(NaN)", Number.NaN, Math.ceil(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.ceil(null)", 0, Math.ceil(null) ); - array[item++] = new TestCase( SECTION, "Math.ceil()", Number.NaN, Math.ceil() ); - array[item++] = new TestCase( SECTION, "Math.ceil(void 0)", Number.NaN, Math.ceil(void 0) ); - - array[item++] = new TestCase( SECTION, "Math.ceil('0')", 0, Math.ceil('0') ); - array[item++] = new TestCase( SECTION, "Math.ceil('-0')", -0, Math.ceil('-0') ); - array[item++] = new TestCase( SECTION, "Infinity/Math.ceil('0')", Infinity, Infinity/Math.ceil('0')); - array[item++] = new TestCase( SECTION, "Infinity/Math.ceil('-0')", -Infinity, Infinity/Math.ceil('-0')); - - array[item++] = new TestCase( SECTION, "Math.ceil(0)", 0, Math.ceil(0) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-0)", -0, Math.ceil(-0) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(0)", Infinity, Infinity/Math.ceil(0)); - array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-0)", -Infinity, Infinity/Math.ceil(-0)); - - array[item++] = new TestCase( SECTION, "Math.ceil(Infinity)", Number.POSITIVE_INFINITY, Math.ceil(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-Infinity)", Number.NEGATIVE_INFINITY, Math.ceil(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-Number.MIN_VALUE)", -0, Math.ceil(-Number.MIN_VALUE) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-Number.MIN_VALUE)", -Infinity, Infinity/Math.ceil(-Number.MIN_VALUE) ); - array[item++] = new TestCase( SECTION, "Math.ceil(1)", 1, Math.ceil(1) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-1)", -1, Math.ceil(-1) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-0.9)", -0, Math.ceil(-0.9) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.ceil(-0.9)", -Infinity, Infinity/Math.ceil(-0.9) ); - array[item++] = new TestCase( SECTION, "Math.ceil(0.9 )", 1, Math.ceil( 0.9) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-1.1)", -1, Math.ceil( -1.1)); - array[item++] = new TestCase( SECTION, "Math.ceil( 1.1)", 2, Math.ceil( 1.1)); - - array[item++] = new TestCase( SECTION, "Math.ceil(Infinity)", -Math.floor(-Infinity), Math.ceil(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-Infinity)", -Math.floor(Infinity), Math.ceil(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-Number.MIN_VALUE)", -Math.floor(Number.MIN_VALUE), Math.ceil(-Number.MIN_VALUE) ); - array[item++] = new TestCase( SECTION, "Math.ceil(1)", -Math.floor(-1), Math.ceil(1) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-1)", -Math.floor(1), Math.ceil(-1) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-0.9)", -Math.floor(0.9), Math.ceil(-0.9) ); - array[item++] = new TestCase( SECTION, "Math.ceil(0.9 )", -Math.floor(-0.9), Math.ceil( 0.9) ); - array[item++] = new TestCase( SECTION, "Math.ceil(-1.1)", -Math.floor(1.1), Math.ceil( -1.1)); - array[item++] = new TestCase( SECTION, "Math.ceil( 1.1)", -Math.floor(-1.1), Math.ceil( 1.1)); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.8.2.6.js + ECMA Section: 15.8.2.6 Math.ceil(x) + Description: return the smallest number value that is not less than the + argument and is equal to a mathematical integer. if the + number is already an integer, return the number itself. + special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = 0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.ceil(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 +*/ +var SECTION = "15.8.2.6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.ceil(x)"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "Math.ceil.length", + 1, + Math.ceil.length ); + +new TestCase( SECTION, + "Math.ceil(NaN)", + Number.NaN, + Math.ceil(Number.NaN) ); + +new TestCase( SECTION, + "Math.ceil(null)", + 0, + Math.ceil(null) ); + +new TestCase( SECTION, + "Math.ceil()", + Number.NaN, + Math.ceil() ); + +new TestCase( SECTION, + "Math.ceil(void 0)", + Number.NaN, + Math.ceil(void 0) ); + +new TestCase( SECTION, + "Math.ceil('0')", + 0, + Math.ceil('0') ); + +new TestCase( SECTION, + "Math.ceil('-0')", + -0, + Math.ceil('-0') ); + +new TestCase( SECTION, + "Infinity/Math.ceil('0')", + Infinity, + Infinity/Math.ceil('0')); + +new TestCase( SECTION, + "Infinity/Math.ceil('-0')", + -Infinity, + Infinity/Math.ceil('-0')); + +new TestCase( SECTION, + "Math.ceil(0)", + 0, + Math.ceil(0) ); + +new TestCase( SECTION, + "Math.ceil(-0)", + -0, + Math.ceil(-0) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(0)", + Infinity, + Infinity/Math.ceil(0)); + +new TestCase( SECTION, + "Infinity/Math.ceil(-0)", + -Infinity, + Infinity/Math.ceil(-0)); + + +new TestCase( SECTION, + "Math.ceil(Infinity)", + Number.POSITIVE_INFINITY, + Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Number.MIN_VALUE)", + -0, + Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(-Number.MIN_VALUE)", + -Infinity, + Infinity/Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Math.ceil(1)", + 1, + Math.ceil(1) ); + +new TestCase( SECTION, + "Math.ceil(-1)", + -1, + Math.ceil(-1) ); + +new TestCase( SECTION, + "Math.ceil(-0.9)", + -0, + Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Infinity/Math.ceil(-0.9)", + -Infinity, + Infinity/Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Math.ceil(0.9 )", + 1, + Math.ceil( 0.9) ); + +new TestCase( SECTION, + "Math.ceil(-1.1)", + -1, + Math.ceil( -1.1)); + +new TestCase( SECTION, + "Math.ceil( 1.1)", + 2, + Math.ceil( 1.1)); + +new TestCase( SECTION, + "Math.ceil(Infinity)", + -Math.floor(-Infinity), + Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Infinity)", + -Math.floor(Infinity), + Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.ceil(-Number.MIN_VALUE)", + -Math.floor(Number.MIN_VALUE), + Math.ceil(-Number.MIN_VALUE) ); + +new TestCase( SECTION, + "Math.ceil(1)", + -Math.floor(-1), + Math.ceil(1) ); + +new TestCase( SECTION, + "Math.ceil(-1)", + -Math.floor(1), + Math.ceil(-1) ); + +new TestCase( SECTION, + "Math.ceil(-0.9)", + -Math.floor(0.9), + Math.ceil(-0.9) ); + +new TestCase( SECTION, + "Math.ceil(0.9 )", + -Math.floor(-0.9), + Math.ceil( 0.9) ); + +new TestCase( SECTION, + "Math.ceil(-1.1)", + -Math.floor(1.1), + Math.ceil( -1.1)); + +new TestCase( SECTION, + "Math.ceil( 1.1)", + -Math.floor(-1.1), + Math.ceil( 1.1)); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.7.js b/mozilla/js/tests/ecma/Math/15.8.2.7.js index 3b1d0fe8cd1..89b1f98d43d 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.7.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,247 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.7.js - ECMA Section: 15.8.2.7 cos( x ) - Description: return an approximation to the cosine of the - argument. argument is expressed in radians - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.7.js + ECMA Section: 15.8.2.7 cos( x ) + Description: return an approximation to the cosine of the + argument. argument is expressed in radians + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.7"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.cos(x)"; +var SECTION = "15.8.2.7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.cos(x)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.cos.length", + 1, + Math.cos.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.cos()", + Number.NaN, + Math.cos() ); - array[item++] = new TestCase( SECTION, "Math.cos.length", 1, Math.cos.length ); +new TestCase( SECTION, + "Math.cos(void 0)", + Number.NaN, + Math.cos(void 0) ); - array[item++] = new TestCase( SECTION, "Math.cos()", Number.NaN, Math.cos() ); - array[item++] = new TestCase( SECTION, "Math.cos(void 0)", Number.NaN, Math.cos(void 0) ); - array[item++] = new TestCase( SECTION, "Math.cos(false)", 1, Math.cos(false) ); - array[item++] = new TestCase( SECTION, "Math.cos(null)", 1, Math.cos(null) ); +new TestCase( SECTION, + "Math.cos(false)", + 1, + Math.cos(false) ); - array[item++] = new TestCase( SECTION, "Math.cos('0')", 1, Math.cos('0') ); - array[item++] = new TestCase( SECTION, "Math.cos('Infinity')", Number.NaN, Math.cos("Infinity") ); - array[item++] = new TestCase( SECTION, "Math.cos('3.14159265359')", -1, Math.cos('3.14159265359') ); +new TestCase( SECTION, + "Math.cos(null)", + 1, + Math.cos(null) ); - array[item++] = new TestCase( SECTION, "Math.cos(NaN)", Number.NaN, Math.cos(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.cos(0)", 1, Math.cos(0) ); - array[item++] = new TestCase( SECTION, "Math.cos(-0)", 1, Math.cos(-0) ); - array[item++] = new TestCase( SECTION, "Math.cos(Infinity)", Number.NaN, Math.cos(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.cos(-Infinity)", Number.NaN, Math.cos(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.cos(0.7853981633974)", 0.7071067811865, Math.cos(0.7853981633974) ); - array[item++] = new TestCase( SECTION, "Math.cos(1.570796326795)", 0, Math.cos(1.570796326795) ); - array[item++] = new TestCase( SECTION, "Math.cos(2.356194490192)", -0.7071067811865, Math.cos(2.356194490192) ); - array[item++] = new TestCase( SECTION, "Math.cos(3.14159265359)", -1, Math.cos(3.14159265359) ); - array[item++] = new TestCase( SECTION, "Math.cos(3.926990816987)", -0.7071067811865, Math.cos(3.926990816987) ); - array[item++] = new TestCase( SECTION, "Math.cos(4.712388980385)", 0, Math.cos(4.712388980385) ); - array[item++] = new TestCase( SECTION, "Math.cos(5.497787143782)", 0.7071067811865, Math.cos(5.497787143782) ); - array[item++] = new TestCase( SECTION, "Math.cos(Math.PI*2)", 1, Math.cos(Math.PI*2) ); - array[item++] = new TestCase( SECTION, "Math.cos(Math.PI/4)", Math.SQRT2/2, Math.cos(Math.PI/4) ); - array[item++] = new TestCase( SECTION, "Math.cos(Math.PI/2)", 0, Math.cos(Math.PI/2) ); - array[item++] = new TestCase( SECTION, "Math.cos(3*Math.PI/4)", -Math.SQRT2/2, Math.cos(3*Math.PI/4) ); - array[item++] = new TestCase( SECTION, "Math.cos(Math.PI)", -1, Math.cos(Math.PI) ); - array[item++] = new TestCase( SECTION, "Math.cos(5*Math.PI/4)", -Math.SQRT2/2, Math.cos(5*Math.PI/4) ); - array[item++] = new TestCase( SECTION, "Math.cos(3*Math.PI/2)", 0, Math.cos(3*Math.PI/2) ); - array[item++] = new TestCase( SECTION, "Math.cos(7*Math.PI/4)", Math.SQRT2/2, Math.cos(7*Math.PI/4) ); - array[item++] = new TestCase( SECTION, "Math.cos(Math.PI*2)", 1, Math.cos(2*Math.PI) ); - array[item++] = new TestCase( SECTION, "Math.cos(-0.7853981633974)", 0.7071067811865, Math.cos(-0.7853981633974) ); - array[item++] = new TestCase( SECTION, "Math.cos(-1.570796326795)", 0, Math.cos(-1.570796326795) ); - array[item++] = new TestCase( SECTION, "Math.cos(-2.3561944901920)", -.7071067811865, Math.cos(2.3561944901920) ); - array[item++] = new TestCase( SECTION, "Math.cos(-3.14159265359)", -1, Math.cos(3.14159265359) ); - array[item++] = new TestCase( SECTION, "Math.cos(-3.926990816987)", -0.7071067811865, Math.cos(3.926990816987) ); - array[item++] = new TestCase( SECTION, "Math.cos(-4.712388980385)", 0, Math.cos(4.712388980385) ); - array[item++] = new TestCase( SECTION, "Math.cos(-5.497787143782)", 0.7071067811865, Math.cos(5.497787143782) ); - array[item++] = new TestCase( SECTION, "Math.cos(-6.28318530718)", 1, Math.cos(6.28318530718) ); - array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI/4)", Math.SQRT2/2, Math.cos(-Math.PI/4) ); - array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI/2)", 0, Math.cos(-Math.PI/2) ); - array[item++] = new TestCase( SECTION, "Math.cos(-3*Math.PI/4)", -Math.SQRT2/2, Math.cos(-3*Math.PI/4) ); - array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI)", -1, Math.cos(-Math.PI) ); - array[item++] = new TestCase( SECTION, "Math.cos(-5*Math.PI/4)", -Math.SQRT2/2, Math.cos(-5*Math.PI/4) ); - array[item++] = new TestCase( SECTION, "Math.cos(-3*Math.PI/2)", 0, Math.cos(-3*Math.PI/2) ); - array[item++] = new TestCase( SECTION, "Math.cos(-7*Math.PI/4)", Math.SQRT2/2, Math.cos(-7*Math.PI/4) ); - array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI*2)", 1, Math.cos(-Math.PI*2) ); +new TestCase( SECTION, + "Math.cos('0')", + 1, + Math.cos('0') ); - return ( array ); -} +new TestCase( SECTION, + "Math.cos('Infinity')", + Number.NaN, + Math.cos("Infinity") ); +new TestCase( SECTION, + "Math.cos('3.14159265359')", + -1, + Math.cos('3.14159265359') ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.cos(NaN)", + Number.NaN, + Math.cos(Number.NaN) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.cos(0)", + 1, + Math.cos(0) ); + +new TestCase( SECTION, + "Math.cos(-0)", + 1, + Math.cos(-0) ); + +new TestCase( SECTION, + "Math.cos(Infinity)", + Number.NaN, + Math.cos(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.cos(-Infinity)", + Number.NaN, + Math.cos(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.cos(0.7853981633974)", + 0.7071067811865, + Math.cos(0.7853981633974) ); + +new TestCase( SECTION, + "Math.cos(1.570796326795)", + 0, + Math.cos(1.570796326795) ); + +new TestCase( SECTION, + "Math.cos(2.356194490192)", + -0.7071067811865, + Math.cos(2.356194490192) ); + +new TestCase( SECTION, + "Math.cos(3.14159265359)", + -1, + Math.cos(3.14159265359) ); + +new TestCase( SECTION, + "Math.cos(3.926990816987)", + -0.7071067811865, + Math.cos(3.926990816987) ); + +new TestCase( SECTION, + "Math.cos(4.712388980385)", + 0, + Math.cos(4.712388980385) ); + +new TestCase( SECTION, + "Math.cos(5.497787143782)", + 0.7071067811865, + Math.cos(5.497787143782) ); + +new TestCase( SECTION, + "Math.cos(Math.PI*2)", + 1, + Math.cos(Math.PI*2) ); + +new TestCase( SECTION, + "Math.cos(Math.PI/4)", + Math.SQRT2/2, + Math.cos(Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI/2)", + 0, + Math.cos(Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(3*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(3*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI)", + -1, + Math.cos(Math.PI) ); + +new TestCase( SECTION, + "Math.cos(5*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(5*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(3*Math.PI/2)", + 0, + Math.cos(3*Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(7*Math.PI/4)", + Math.SQRT2/2, + Math.cos(7*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(Math.PI*2)", + 1, + Math.cos(2*Math.PI) ); + +new TestCase( SECTION, + "Math.cos(-0.7853981633974)", + 0.7071067811865, + Math.cos(-0.7853981633974) ); + +new TestCase( SECTION, + "Math.cos(-1.570796326795)", + 0, + Math.cos(-1.570796326795) ); + +new TestCase( SECTION, + "Math.cos(-2.3561944901920)", + -.7071067811865, + Math.cos(2.3561944901920) ); + +new TestCase( SECTION, + "Math.cos(-3.14159265359)", + -1, + Math.cos(3.14159265359) ); + +new TestCase( SECTION, + "Math.cos(-3.926990816987)", + -0.7071067811865, + Math.cos(3.926990816987) ); + +new TestCase( SECTION, + "Math.cos(-4.712388980385)", + 0, + Math.cos(4.712388980385) ); + +new TestCase( SECTION, + "Math.cos(-5.497787143782)", + 0.7071067811865, + Math.cos(5.497787143782) ); + +new TestCase( SECTION, + "Math.cos(-6.28318530718)", + 1, + Math.cos(6.28318530718) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI/4)", + Math.SQRT2/2, + Math.cos(-Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI/2)", + 0, + Math.cos(-Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(-3*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(-3*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI)", + -1, + Math.cos(-Math.PI) ); + +new TestCase( SECTION, + "Math.cos(-5*Math.PI/4)", + -Math.SQRT2/2, + Math.cos(-5*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-3*Math.PI/2)", + 0, + Math.cos(-3*Math.PI/2) ); + +new TestCase( SECTION, + "Math.cos(-7*Math.PI/4)", + Math.SQRT2/2, + Math.cos(-7*Math.PI/4) ); + +new TestCase( SECTION, + "Math.cos(-Math.PI*2)", + 1, + Math.cos(-Math.PI*2) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.8.js b/mozilla/js/tests/ecma/Math/15.8.2.8.js index d3d20bc937f..79cc451cec6 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.8.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,66 +35,98 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.8.js - ECMA Section: 15.8.2.8 Math.exp(x) - Description: return an approximation to the exponential function of - the argument (e raised to the power of the argument) - special cases: - - if x is NaN return NaN - - if x is 0 return 1 - - if x is -0 return 1 - - if x is Infinity return Infinity - - if x is -Infinity return 0 - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.8.js + ECMA Section: 15.8.2.8 Math.exp(x) + Description: return an approximation to the exponential function of + the argument (e raised to the power of the argument) + special cases: + - if x is NaN return NaN + - if x is 0 return 1 + - if x is -0 return 1 + - if x is Infinity return Infinity + - if x is -Infinity return 0 + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.8"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.exp(x)"; +var SECTION = "15.8.2.8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.exp(x)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.exp.length", + 1, + Math.exp.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.exp()", + Number.NaN, + Math.exp() ); - array[item++] = new TestCase( SECTION, "Math.exp.length", 1, Math.exp.length ); +new TestCase( SECTION, + "Math.exp(null)", + 1, + Math.exp(null) ); - array[item++] = new TestCase( SECTION, "Math.exp()", Number.NaN, Math.exp() ); - array[item++] = new TestCase( SECTION, "Math.exp(null)", 1, Math.exp(null) ); - array[item++] = new TestCase( SECTION, "Math.exp(void 0)", Number.NaN, Math.exp(void 0) ); - array[item++] = new TestCase( SECTION, "Math.exp(1)", Math.E, Math.exp(1) ); - array[item++] = new TestCase( SECTION, "Math.exp(true)", Math.E, Math.exp(true) ); - array[item++] = new TestCase( SECTION, "Math.exp(false)", 1, Math.exp(false) ); +new TestCase( SECTION, + "Math.exp(void 0)", + Number.NaN, + Math.exp(void 0) ); - array[item++] = new TestCase( SECTION, "Math.exp('1')", Math.E, Math.exp('1') ); - array[item++] = new TestCase( SECTION, "Math.exp('0')", 1, Math.exp('0') ); +new TestCase( SECTION, + "Math.exp(1)", + Math.E, + Math.exp(1) ); - array[item++] = new TestCase( SECTION, "Math.exp(NaN)", Number.NaN, Math.exp(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.exp(0)", 1, Math.exp(0) ); - array[item++] = new TestCase( SECTION, "Math.exp(-0)", 1, Math.exp(-0) ); - array[item++] = new TestCase( SECTION, "Math.exp(Infinity)", Number.POSITIVE_INFINITY, Math.exp(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.exp(-Infinity)", 0, Math.exp(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, + "Math.exp(true)", + Math.E, + Math.exp(true) ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.exp(false)", + 1, + Math.exp(false) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Math.exp('1')", + Math.E, + Math.exp('1') ); + +new TestCase( SECTION, + "Math.exp('0')", + 1, + Math.exp('0') ); + +new TestCase( SECTION, + "Math.exp(NaN)", + Number.NaN, + Math.exp(Number.NaN) ); + +new TestCase( SECTION, + "Math.exp(0)", + 1, + Math.exp(0) ); + +new TestCase( SECTION, + "Math.exp(-0)", + 1, + Math.exp(-0) ); + +new TestCase( SECTION, + "Math.exp(Infinity)", + Number.POSITIVE_INFINITY, + Math.exp(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.exp(-Infinity)", + 0, + Math.exp(Number.NEGATIVE_INFINITY) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/15.8.2.9.js b/mozilla/js/tests/ecma/Math/15.8.2.9.js index 7edec78994c..11afe3cc527 100644 --- a/mozilla/js/tests/ecma/Math/15.8.2.9.js +++ b/mozilla/js/tests/ecma/Math/15.8.2.9.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,87 +35,155 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.8.2.9.js - ECMA Section: 15.8.2.9 Math.floor(x) - Description: return the greatest number value that is not greater - than the argument and is equal to a mathematical integer. - if the number is already an integer, return the number - itself. special cases: - - if x is NaN return NaN - - if x = +0 return +0 - - if x = -0 return -0 - - if x = Infinity return Infinity - - if x = -Infinity return -Infinity - - if ( -1 < x < 0 ) return -0 - also: - - the value of Math.floor(x) == -Math.ceil(-x) - Author: christine@netscape.com - Date: 7 july 1997 + File Name: 15.8.2.9.js + ECMA Section: 15.8.2.9 Math.floor(x) + Description: return the greatest number value that is not greater + than the argument and is equal to a mathematical integer. + if the number is already an integer, return the number + itself. special cases: + - if x is NaN return NaN + - if x = +0 return +0 + - if x = -0 return -0 + - if x = Infinity return Infinity + - if x = -Infinity return -Infinity + - if ( -1 < x < 0 ) return -0 + also: + - the value of Math.floor(x) == -Math.ceil(-x) + Author: christine@netscape.com + Date: 7 july 1997 */ - var SECTION = "15.8.2.9"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Math.floor(x)"; +var SECTION = "15.8.2.9"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Math.floor(x)"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Math.floor.length", + 1, + Math.floor.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Math.floor()", + Number.NaN, + Math.floor() ); - array[item++] = new TestCase( SECTION, "Math.floor.length", 1, Math.floor.length ); +new TestCase( SECTION, + "Math.floor(void 0)", + Number.NaN, + Math.floor(void 0) ); - array[item++] = new TestCase( SECTION, "Math.floor()", Number.NaN, Math.floor() ); - array[item++] = new TestCase( SECTION, "Math.floor(void 0)", Number.NaN, Math.floor(void 0) ); - array[item++] = new TestCase( SECTION, "Math.floor(null)", 0, Math.floor(null) ); - array[item++] = new TestCase( SECTION, "Math.floor(true)", 1, Math.floor(true) ); - array[item++] = new TestCase( SECTION, "Math.floor(false)", 0, Math.floor(false) ); +new TestCase( SECTION, + "Math.floor(null)", + 0, + Math.floor(null) ); - array[item++] = new TestCase( SECTION, "Math.floor('1.1')", 1, Math.floor("1.1") ); - array[item++] = new TestCase( SECTION, "Math.floor('-1.1')", -2, Math.floor("-1.1") ); - array[item++] = new TestCase( SECTION, "Math.floor('0.1')", 0, Math.floor("0.1") ); - array[item++] = new TestCase( SECTION, "Math.floor('-0.1')", -1, Math.floor("-0.1") ); +new TestCase( SECTION, + "Math.floor(true)", + 1, + Math.floor(true) ); - array[item++] = new TestCase( SECTION, "Math.floor(NaN)", Number.NaN, Math.floor(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.floor(NaN)==-Math.ceil(-NaN)", false, Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) ); +new TestCase( SECTION, + "Math.floor(false)", + 0, + Math.floor(false) ); - array[item++] = new TestCase( SECTION, "Math.floor(0)", 0, Math.floor(0) ); - array[item++] = new TestCase( SECTION, "Math.floor(0)==-Math.ceil(-0)", true, Math.floor(0) == -Math.ceil(-0) ); +new TestCase( SECTION, + "Math.floor('1.1')", + 1, + Math.floor("1.1") ); - array[item++] = new TestCase( SECTION, "Math.floor(-0)", -0, Math.floor(-0) ); - array[item++] = new TestCase( SECTION, "Infinity/Math.floor(-0)", -Infinity, Infinity/Math.floor(-0) ); - array[item++] = new TestCase( SECTION, "Math.floor(-0)==-Math.ceil(0)", true, Math.floor(-0)== -Math.ceil(0) ); +new TestCase( SECTION, + "Math.floor('-1.1')", + -2, + Math.floor("-1.1") ); - array[item++] = new TestCase( SECTION, "Math.floor(Infinity)", Number.POSITIVE_INFINITY, Math.floor(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.floor(Infinity)==-Math.ceil(-Infinity)", true, Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, + "Math.floor('0.1')", + 0, + Math.floor("0.1") ); - array[item++] = new TestCase( SECTION, "Math.floor(-Infinity)", Number.NEGATIVE_INFINITY, Math.floor(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Math.floor(-Infinity)==-Math.ceil(Infinity)", true, Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, + "Math.floor('-0.1')", + -1, + Math.floor("-0.1") ); - array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)", 0, Math.floor(0.0000001) ); - array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, Math.floor(0.0000001)==-Math.ceil(-0.0000001) ); +new TestCase( SECTION, + "Math.floor(NaN)", + Number.NaN, + Math.floor(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Math.floor(-0.0000001)", -1, Math.floor(-0.0000001) ); - array[item++] = new TestCase( SECTION, "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, Math.floor(-0.0000001)==-Math.ceil(0.0000001) ); +new TestCase( SECTION, + "Math.floor(NaN)==-Math.ceil(-NaN)", + false, + Math.floor(Number.NaN) == -Math.ceil(-Number.NaN) ); - return ( array ); -} +new TestCase( SECTION, + "Math.floor(0)", + 0, + Math.floor(0) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "Math.floor(0)==-Math.ceil(-0)", + true, + Math.floor(0) == -Math.ceil(-0) ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +new TestCase( SECTION, + "Math.floor(-0)", + -0, + Math.floor(-0) ); + +new TestCase( SECTION, + "Infinity/Math.floor(-0)", + -Infinity, + Infinity/Math.floor(-0) ); + +new TestCase( SECTION, + "Math.floor(-0)==-Math.ceil(0)", + true, + Math.floor(-0)== -Math.ceil(0) ); + +new TestCase( SECTION, + "Math.floor(Infinity)", + Number.POSITIVE_INFINITY, + Math.floor(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(Infinity)==-Math.ceil(-Infinity)", + true, + Math.floor(Number.POSITIVE_INFINITY) == -Math.ceil(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(-Infinity)", + Number.NEGATIVE_INFINITY, + Math.floor(Number.NEGATIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(-Infinity)==-Math.ceil(Infinity)", + true, + Math.floor(Number.NEGATIVE_INFINITY) == -Math.ceil(Number.POSITIVE_INFINITY) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)", + 0, + Math.floor(0.0000001) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)==-Math.ceil(0.0000001)", true, + Math.floor(0.0000001)==-Math.ceil(-0.0000001) ); + +new TestCase( SECTION, + "Math.floor(-0.0000001)", + -1, + Math.floor(-0.0000001) ); + +new TestCase( SECTION, + "Math.floor(0.0000001)==-Math.ceil(0.0000001)", + true, + Math.floor(-0.0000001)==-Math.ceil(0.0000001) ); + +test(); diff --git a/mozilla/js/tests/ecma/Math/browser.js b/mozilla/js/tests/ecma/Math/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Math/shell.js b/mozilla/js/tests/ecma/Math/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/NativeObjects/15-1.js b/mozilla/js/tests/ecma/NativeObjects/15-1.js index 504526a6137..5c3c093f7ea 100644 --- a/mozilla/js/tests/ecma/NativeObjects/15-1.js +++ b/mozilla/js/tests/ecma/NativeObjects/15-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,77 +35,58 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.js - ECMA Section: 15 Native ECMAScript Objects - Description: Every built-in prototype object has the Object prototype - object, which is the value of the expression - Object.prototype (15.2.3.1) as the value of its internal - [[Prototype]] property, except the Object prototype - object itself. + File Name: 15.js + ECMA Section: 15 Native ECMAScript Objects + Description: Every built-in prototype object has the Object prototype + object, which is the value of the expression + Object.prototype (15.2.3.1) as the value of its internal + [[Prototype]] property, except the Object prototype + object itself. - Every native object associated with a program-created - function also has the Object prototype object as the - value of its internal [[Prototype]] property. + Every native object associated with a program-created + function also has the Object prototype object as the + value of its internal [[Prototype]] property. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Native ECMAScript Objects"; +var SECTION = "15-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Native ECMAScript Objects"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; +writeHeaderToLog( SECTION + " "+ TITLE); /* - array[item++] = new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); -// array[item++] = new TestCase( SECTION, "Math.prototype.__proto__", Object.prototype, Math.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "Date.prototype.__proto__", Object.prototype, Date.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "TestCase.prototype.__proto__", Object.prototype, TestCase.prototype.__proto__ ); + new TestCase( SECTION, "Function.prototype.__proto__", Object.prototype, Function.prototype.__proto__ ); + new TestCase( SECTION, "Array.prototype.__proto__", Object.prototype, Array.prototype.__proto__ ); + new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); + new TestCase( SECTION, "Boolean.prototype.__proto__", Object.prototype, Boolean.prototype.__proto__ ); + new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); +// new TestCase( SECTION, "Math.prototype.__proto__", Object.prototype, Math.prototype.__proto__ ); +new TestCase( SECTION, "Date.prototype.__proto__", Object.prototype, Date.prototype.__proto__ ); +new TestCase( SECTION, "TestCase.prototype.__proto__", Object.prototype, TestCase.prototype.__proto__ ); - array[item++] = new TestCase( SECTION, "MyObject.prototype.__proto__", Object.prototype, MyObject.prototype.__proto__ ); +new TestCase( SECTION, "MyObject.prototype.__proto__", Object.prototype, MyObject.prototype.__proto__ ); */ - array[item++] = new TestCase( SECTION, "Function.prototype.__proto__ == Object.prototype", true, Function.prototype.__proto__ == Object.prototype ); - array[item++] = new TestCase( SECTION, "Array.prototype.__proto__ == Object.prototype", true, Array.prototype.__proto__ == Object.prototype ); - array[item++] = new TestCase( SECTION, "String.prototype.__proto__ == Object.prototype", true, String.prototype.__proto__ == Object.prototype ); - array[item++] = new TestCase( SECTION, "Boolean.prototype.__proto__ == Object.prototype", true, Boolean.prototype.__proto__ == Object.prototype ); - array[item++] = new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); -// array[item++] = new TestCase( SECTION, "Math.prototype.__proto__ == Object.prototype", true, Math.prototype.__proto__ == Object.prototype ); - array[item++] = new TestCase( SECTION, "Date.prototype.__proto__ == Object.prototype", true, Date.prototype.__proto__ == Object.prototype ); - array[item++] = new TestCase( SECTION, "TestCase.prototype.__proto__ == Object.prototype", true, TestCase.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Function.prototype.__proto__ == Object.prototype", true, Function.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Array.prototype.__proto__ == Object.prototype", true, Array.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "String.prototype.__proto__ == Object.prototype", true, String.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Boolean.prototype.__proto__ == Object.prototype", true, Boolean.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); +// new TestCase( SECTION, "Math.prototype.__proto__ == Object.prototype", true, Math.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "Date.prototype.__proto__ == Object.prototype", true, Date.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "TestCase.prototype.__proto__ == Object.prototype", true, TestCase.prototype.__proto__ == Object.prototype ); - array[item++] = new TestCase( SECTION, "MyObject.prototype.__proto__ == Object.prototype", true, MyObject.prototype.__proto__ == Object.prototype ); +new TestCase( SECTION, "MyObject.prototype.__proto__ == Object.prototype", true, MyObject.prototype.__proto__ == Object.prototype ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { +test(); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - - stopTest(); - return ( testcases ); -} function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); + this.value = value; + this.valueOf = new Function( "return this.value" ); } diff --git a/mozilla/js/tests/ecma/NativeObjects/15-2.js b/mozilla/js/tests/ecma/NativeObjects/15-2.js index 64a092ae611..d9811358813 100644 --- a/mozilla/js/tests/ecma/NativeObjects/15-2.js +++ b/mozilla/js/tests/ecma/NativeObjects/15-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 15-2.js ECMA Section: 15 Native ECMAScript Objects @@ -58,36 +60,16 @@ writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; + new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); + new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ ); + new TestCase( SECTION, "String.__proto__", Function.prototype, String.__proto__ ); + new TestCase( SECTION, "Boolean.__proto__", Function.prototype, Boolean.__proto__ ); + new TestCase( SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); + new TestCase( SECTION, "Date.__proto__", Function.prototype, Date.__proto__ ); + new TestCase( SECTION, "TestCase.__proto__", Function.prototype, TestCase.__proto__ ); - array[item++] = new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); - array[item++] = new TestCase( SECTION, "Array.__proto__", Function.prototype, Array.__proto__ ); - array[item++] = new TestCase( SECTION, "String.__proto__", Function.prototype, String.__proto__ ); - array[item++] = new TestCase( SECTION, "Boolean.__proto__", Function.prototype, Boolean.__proto__ ); - array[item++] = new TestCase( SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); - array[item++] = new TestCase( SECTION, "Date.__proto__", Function.prototype, Date.__proto__ ); - array[item++] = new TestCase( SECTION, "TestCase.__proto__", Function.prototype, TestCase.__proto__ ); + new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); + new TestCase( SECTION, "Math.pow.__proto__", Function.prototype, Math.pow.__proto__ ); + new TestCase( SECTION, "String.prototype.indexOf.__proto__", Function.prototype, String.prototype.indexOf.__proto__ ); - array[item++] = new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ ); - array[item++] = new TestCase( SECTION, "Math.pow.__proto__", Function.prototype, Math.pow.__proto__ ); - array[item++] = new TestCase( SECTION, "String.prototype.indexOf.__proto__", Function.prototype, String.prototype.indexOf.__proto__ ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/NativeObjects/browser.js b/mozilla/js/tests/ecma/NativeObjects/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/NativeObjects/shell.js b/mozilla/js/tests/ecma/NativeObjects/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Number/15.7.1.js b/mozilla/js/tests/ecma/Number/15.7.1.js index ae33b8a7d49..fd5e652621d 100644 --- a/mozilla/js/tests/ecma/Number/15.7.1.js +++ b/mozilla/js/tests/ecma/Number/15.7.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.1.js - ECMA Section: 15.7.1 The Number Constructor Called as a Function - 15.7.1.1 - 15.7.1.2 + File Name: 15.7.1.js + ECMA Section: 15.7.1 The Number Constructor Called as a Function + 15.7.1.1 + 15.7.1.2 - Description: When Number is called as a function rather than as a - constructor, it performs a type conversion. - 15.7.1.1 Return a number value (not a Number object) - computed by ToNumber( value ) - 15.7.1.2 Number() returns 0. + Description: When Number is called as a function rather than as a + constructor, it performs a type conversion. + 15.7.1.1 Return a number value (not a Number object) + computed by ToNumber( value ) + 15.7.1.2 Number() returns 0. - need to add more test cases. see the testcases for - TypeConversion ToNumber. + need to add more test cases. see the testcases for + TypeConversion ToNumber. - Author: christine@netscape.com - Date: 29 september 1997 + Author: christine@netscape.com + Date: 29 september 1997 */ - var SECTION = "15.7.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The Number Constructor Called as a Function"; +var SECTION = "15.7.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The Number Constructor Called as a Function"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase(SECTION, "Number()", 0, Number() ); +new TestCase(SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); +new TestCase(SECTION, "Number(null)", 0, Number(null) ); +new TestCase(SECTION, "Number()", 0, Number() ); +new TestCase(SECTION, "Number(new Number())", 0, Number( new Number() ) ); +new TestCase(SECTION, "Number(0)", 0, Number(0) ); +new TestCase(SECTION, "Number(1)", 1, Number(1) ); +new TestCase(SECTION, "Number(-1)", -1, Number(-1) ); +new TestCase(SECTION, "Number(NaN)", Number.NaN, Number( Number.NaN ) ); +new TestCase(SECTION, "Number('string')", Number.NaN, Number( "string") ); +new TestCase(SECTION, "Number(new String())", 0, Number( new String() ) ); +new TestCase(SECTION, "Number('')", 0, Number( "" ) ); +new TestCase(SECTION, "Number(Infinity)", Number.POSITIVE_INFINITY, Number("Infinity") ); +new TestCase(SECTION, "Number(new MyObject(100))", 100, Number(new MyObject(100)) ); -function getTestCases() { - var array = new Array(); - var item = 0; +test(); - array[item++] = new TestCase(SECTION, "Number()", 0, Number() ); - array[item++] = new TestCase(SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); - array[item++] = new TestCase(SECTION, "Number(null)", 0, Number(null) ); - array[item++] = new TestCase(SECTION, "Number()", 0, Number() ); - array[item++] = new TestCase(SECTION, "Number(new Number())", 0, Number( new Number() ) ); - array[item++] = new TestCase(SECTION, "Number(0)", 0, Number(0) ); - array[item++] = new TestCase(SECTION, "Number(1)", 1, Number(1) ); - array[item++] = new TestCase(SECTION, "Number(-1)", -1, Number(-1) ); - array[item++] = new TestCase(SECTION, "Number(NaN)", Number.NaN, Number( Number.NaN ) ); - array[item++] = new TestCase(SECTION, "Number('string')", Number.NaN, Number( "string") ); - array[item++] = new TestCase(SECTION, "Number(new String())", 0, Number( new String() ) ); - array[item++] = new TestCase(SECTION, "Number('')", 0, Number( "" ) ); - array[item++] = new TestCase(SECTION, "Number(Infinity)", Number.POSITIVE_INFINITY, Number("Infinity") ); - - array[item++] = new TestCase(SECTION, "Number(new MyObject(100))", 100, Number(new MyObject(100)) ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); -} \ No newline at end of file + this.value = value; + this.valueOf = new Function( "return this.value" ); +} diff --git a/mozilla/js/tests/ecma/Number/15.7.2.js b/mozilla/js/tests/ecma/Number/15.7.2.js index 85b7e3b5b55..487f69f8894 100644 --- a/mozilla/js/tests/ecma/Number/15.7.2.js +++ b/mozilla/js/tests/ecma/Number/15.7.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 15.7.2.js ECMA Section: 15.7.2 The Number Constructor @@ -68,121 +70,97 @@ writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - // To verify that the object's prototype is the Number.prototype, check to see if the object's // constructor property is the same as Number.prototype.constructor. - array[item++] = new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); + new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); - array[item++] = new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); + new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); + new TestCase(SECTION, "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number(0)).constructor", Number.prototype.constructor, (new Number(0)).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number(0))", "object", typeof (new Number(0)) ); - array[item++] = new TestCase(SECTION, "(new Number(0)).valueOf()", 0, (new Number(0)).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number(0)).constructor", Number.prototype.constructor, (new Number(0)).constructor ); + new TestCase(SECTION, "typeof (new Number(0))", "object", typeof (new Number(0)) ); + new TestCase(SECTION, "(new Number(0)).valueOf()", 0, (new Number(0)).valueOf() ); + new TestCase(SECTION, "NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number(0);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number(1)).constructor", Number.prototype.constructor, (new Number(1)).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number(1))", "object", typeof (new Number(1)) ); - array[item++] = new TestCase(SECTION, "(new Number(1)).valueOf()", 1, (new Number(1)).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number(1)).constructor", Number.prototype.constructor, (new Number(1)).constructor ); + new TestCase(SECTION, "typeof (new Number(1))", "object", typeof (new Number(1)) ); + new TestCase(SECTION, "(new Number(1)).valueOf()", 1, (new Number(1)).valueOf() ); + new TestCase(SECTION, "NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number(1);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number(-1)).constructor", Number.prototype.constructor, (new Number(-1)).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number(-1))", "object", typeof (new Number(-1)) ); - array[item++] = new TestCase(SECTION, "(new Number(-1)).valueOf()", -1, (new Number(-1)).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number(-1)).constructor", Number.prototype.constructor, (new Number(-1)).constructor ); + new TestCase(SECTION, "typeof (new Number(-1))", "object", typeof (new Number(-1)) ); + new TestCase(SECTION, "(new Number(-1)).valueOf()", -1, (new Number(-1)).valueOf() ); + new TestCase(SECTION, "NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number(-1);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number(Number.NaN)).constructor", Number.prototype.constructor, (new Number(Number.NaN)).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number(Number.NaN))", "object", typeof (new Number(Number.NaN)) ); - array[item++] = new TestCase(SECTION, "(new Number(Number.NaN)).valueOf()", Number.NaN, (new Number(Number.NaN)).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number(Number.NaN)).constructor", Number.prototype.constructor, (new Number(Number.NaN)).constructor ); + new TestCase(SECTION, "typeof (new Number(Number.NaN))", "object", typeof (new Number(Number.NaN)) ); + new TestCase(SECTION, "(new Number(Number.NaN)).valueOf()", Number.NaN, (new Number(Number.NaN)).valueOf() ); + new TestCase(SECTION, "NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number(Number.NaN);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number('string')).constructor", Number.prototype.constructor, (new Number('string')).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number('string'))", "object", typeof (new Number('string')) ); - array[item++] = new TestCase(SECTION, "(new Number('string')).valueOf()", Number.NaN, (new Number('string')).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number('string')).constructor", Number.prototype.constructor, (new Number('string')).constructor ); + new TestCase(SECTION, "typeof (new Number('string'))", "object", typeof (new Number('string')) ); + new TestCase(SECTION, "(new Number('string')).valueOf()", Number.NaN, (new Number('string')).valueOf() ); + new TestCase(SECTION, "NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number('string');NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number(new String())).constructor", Number.prototype.constructor, (new Number(new String())).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number(new String()))", "object", typeof (new Number(new String())) ); - array[item++] = new TestCase(SECTION, "(new Number(new String())).valueOf()", 0, (new Number(new String())).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number(new String())).constructor", Number.prototype.constructor, (new Number(new String())).constructor ); + new TestCase(SECTION, "typeof (new Number(new String()))", "object", typeof (new Number(new String())) ); + new TestCase(SECTION, "(new Number(new String())).valueOf()", 0, (new Number(new String())).valueOf() ); + new TestCase(SECTION, "NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number(new String());NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number('')).constructor", Number.prototype.constructor, (new Number('')).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number(''))", "object", typeof (new Number('')) ); - array[item++] = new TestCase(SECTION, "(new Number('')).valueOf()", 0, (new Number('')).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number('')).constructor", Number.prototype.constructor, (new Number('')).constructor ); + new TestCase(SECTION, "typeof (new Number(''))", "object", typeof (new Number('')) ); + new TestCase(SECTION, "(new Number('')).valueOf()", 0, (new Number('')).valueOf() ); + new TestCase(SECTION, "NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number('');NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.POSITIVE_INFINITY)).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number(Number.POSITIVE_INFINITY))", "object", typeof (new Number(Number.POSITIVE_INFINITY)) ); - array[item++] = new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, (new Number(Number.POSITIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.POSITIVE_INFINITY)).constructor ); + new TestCase(SECTION, "typeof (new Number(Number.POSITIVE_INFINITY))", "object", typeof (new Number(Number.POSITIVE_INFINITY)) ); + new TestCase(SECTION, "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, (new Number(Number.POSITIVE_INFINITY)).valueOf() ); + new TestCase(SECTION, "NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number(Number.POSITIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.NEGATIVE_INFINITY)).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number(Number.NEGATIVE_INFINITY))", "object", typeof (new Number(Number.NEGATIVE_INFINITY)) ); - array[item++] = new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).valueOf()", Number.NEGATIVE_INFINITY, (new Number(Number.NEGATIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).constructor", Number.prototype.constructor, (new Number(Number.NEGATIVE_INFINITY)).constructor ); + new TestCase(SECTION, "typeof (new Number(Number.NEGATIVE_INFINITY))", "object", typeof (new Number(Number.NEGATIVE_INFINITY)) ); + new TestCase(SECTION, "(new Number(Number.NEGATIVE_INFINITY)).valueOf()", Number.NEGATIVE_INFINITY, (new Number(Number.NEGATIVE_INFINITY)).valueOf() ); + new TestCase(SECTION, "NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number(Number.NEGATIVE_INFINITY);NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - array[item++] = new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); - array[item++] = new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); - array[item++] = new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); - array[item++] = new TestCase(SECTION, + new TestCase(SECTION, "(new Number()).constructor", Number.prototype.constructor, (new Number()).constructor ); + new TestCase(SECTION, "typeof (new Number())", "object", typeof (new Number()) ); + new TestCase(SECTION, "(new Number()).valueOf()", 0, (new Number()).valueOf() ); + new TestCase(SECTION, "NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()", "[object Number]", eval("NUMB = new Number();NUMB.toString=Object.prototype.toString;NUMB.toString()") ); - return ( array ); -} - - - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.1-1.js b/mozilla/js/tests/ecma/Number/15.7.3.1-1.js index f3b14acbb3b..e1bc78e28c5 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.1-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.1-2.js - ECMA Section: 15.7.3.1 Number.prototype - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.1-2.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Number.prototype + this test checks the DontDelete attribute of Number.prototype - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ var SECTION = "15.7.3.1-1"; var VERSION = "ECMA_1"; - startTest(); +startTest(); var TITLE = "Number.prototype"; writeHeaderToLog( SECTION +" "+ TITLE); -var testcases = getTestCases(); +new TestCase(SECTION, + "var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype", + true, + eval("var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype") ); + +new TestCase(SECTION, + "delete( Number.prototype )", + false, + eval("delete( Number.prototype )") ); + test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase(SECTION, "var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype", true, "var NUM_PROT = Number.prototype; delete( Number.prototype ); NUM_PROT == Number.prototype" ); - array[item++] = new TestCase(SECTION, "delete( Number.prototype )", false, "delete( Number.prototype )" ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed "; - } - stopTest(); - return ( testcases ); -} - diff --git a/mozilla/js/tests/ecma/Number/15.7.3.1-2.js b/mozilla/js/tests/ecma/Number/15.7.3.1-2.js index 0b143833f4e..27d988b896d 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.1-2.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.1-2.js - ECMA Section: 15.7.3.1 Number.prototype - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.1-2.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the ReadOnly attribute of Number.prototype + this test checks the ReadOnly attribute of Number.prototype - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.prototype"; +var SECTION = "15.7.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, + "var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT", + true, + eval("var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT") ); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT", - true, - eval("var NUM_PROT = Number.prototype; Number.prototype = null; Number.prototype == NUM_PROT") ); - - array[item++] = new TestCase( SECTION, - "Number.prototype=0; Number.prototype", - Number.prototype, - eval("Number.prototype=0; Number.prototype") ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Number.prototype=0; Number.prototype", + Number.prototype, + eval("Number.prototype=0; Number.prototype") ); +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.1-3.js b/mozilla/js/tests/ecma/Number/15.7.3.1-3.js index 267f865a878..45d14f175db 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.1-3.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,31 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.1-4.js - ECMA Section: 15.7.3.1 Number.prototype - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.1-4.js + ECMA Section: 15.7.3.1 Number.prototype + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontEnum attribute of Number.prototype + this test checks the DontEnum attribute of Number.prototype - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "15.7.3.1-3"; - var TITLE = "Number.prototype"; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "15.7.3.1-3"; +var TITLE = "Number.prototype"; - writeHeaderToLog( SECTION + " Number.prototype: DontEnum Attribute"); +writeHeaderToLog( SECTION + " Number.prototype: DontEnum Attribute"); - var testcases = getTestCases(); +new TestCase( + SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop: '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop : '' } string;") + ); - test( testcases ); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( - SECTION, - "var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop: '' } string;", - "", - eval("var string = ''; for ( prop in Number ) { string += ( prop == 'prototype' ) ? prop : '' } string;") - ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += "property should not be enumerated "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.2-1.js b/mozilla/js/tests/ecma/Number/15.7.3.2-1.js index 2463ddfe4c9..78fdee124ca 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.2-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.2-1.js - ECMA Section: 15.7.3.2 Number.MAX_VALUE - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.2-1.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the value of MAX_VALUE + this test checks the value of MAX_VALUE - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.MAX_VALUE"; +var SECTION = "15.7.3.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MAX_VALUE"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "Number.MAX_VALUE", + 1.7976931348623157e308, + Number.MAX_VALUE ); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "Number.MAX_VALUE", 1.7976931348623157e308, Number.MAX_VALUE ); - - - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.2-2.js b/mozilla/js/tests/ecma/Number/15.7.3.2-2.js index 771896faa54..ece98559141 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.2-2.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.2-2.js - ECMA Section: 15.7.3.2 Number.MAX_VALUE - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.2-2.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Number.MAX_VALUE + this test checks the DontDelete attribute of Number.MAX_VALUE - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.MAX_VALUE: DontDelete Attribute"; +var SECTION = "15.7.3.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MAX_VALUE: DontDelete Attribute"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "delete( Number.MAX_VALUE ); Number.MAX_VALUE", + 1.7976931348623157e308, + eval("delete( Number.MAX_VALUE );Number.MAX_VALUE") ); +new TestCase( SECTION, + "delete( Number.MAX_VALUE )", + false, + eval("delete( Number.MAX_VALUE )") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "delete( Number.MAX_VALUE ); Number.MAX_VALUE", 1.7976931348623157e308, "delete( Number.MAX_VALUE );Number.MAX_VALUE" ); - array[item++] = new TestCase( SECTION, "delete( Number.MAX_VALUE )", false, "delete( Number.MAX_VALUE )" ); - - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.2-3.js b/mozilla/js/tests/ecma/Number/15.7.3.2-3.js index 765b6cce1e6..1ea2aff2897 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.2-3.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.2-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,31 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.2-3.js - ECMA Section: 15.7.3.2 Number.MAX_VALUE - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.2-3.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the ReadOnly attribute of Number.MAX_VALUE + this test checks the ReadOnly attribute of Number.MAX_VALUE - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.2-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.MAX_VALUE"; +var SECTION = "15.7.3.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MAX_VALUE"; - writeHeaderToLog( SECTION + " "+ TITLE ); +writeHeaderToLog( SECTION + " "+ TITLE ); - var testcases = getTestCases(); - test(); +var MAX_VAL = 1.7976931348623157e308; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Number.MAX_VALUE=0; Number.MAX_VALUE", + MAX_VAL, + eval("Number.MAX_VALUE=0; Number.MAX_VALUE") ); - var MAX_VAL = 1.7976931348623157e308; - - array[item++] = new TestCase( SECTION, - "Number.MAX_VALUE=0; Number.MAX_VALUE", - MAX_VAL, - eval("Number.MAX_VALUE=0; Number.MAX_VALUE") ); - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.2-4.js b/mozilla/js/tests/ecma/Number/15.7.3.2-4.js index ef432e31dc1..5110e6e0f2b 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.2-4.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.2-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.2-4.js - ECMA Section: 15.7.3.2 Number.MAX_VALUE - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.2-4.js + ECMA Section: 15.7.3.2 Number.MAX_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontEnum attribute of Number.MAX_VALUE + this test checks the DontEnum attribute of Number.MAX_VALUE - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.2-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.MAX_VALUE: DontEnum Attribute"; - writeHeaderToLog( SECTION + " "+ TITLE); +var SECTION = "15.7.3.2-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MAX_VALUE: DontEnum Attribute"; +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;") + ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( - SECTION, - "var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;", - "", - eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MAX_VALUE' ) ? prop : '' } string;") - ); - - return ( array ); -} -function test( testcases ) { - for ( tc = 0; tc < testcases.length; tc++ ) { - writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += "property should not be enumerated "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.3-1.js b/mozilla/js/tests/ecma/Number/15.7.3.3-1.js index d751462344c..9fc37a3c4aa 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.3-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,32 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.3-1.js - ECMA Section: 15.7.3.3 Number.MIN_VALUE - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.3-1.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the value of Number.MIN_VALUE + this test checks the value of Number.MIN_VALUE - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.MIN_VALUE"; +var SECTION = "15.7.3.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MIN_VALUE"; - writeHeaderToLog( SECTION + " "+ TITLE ); +writeHeaderToLog( SECTION + " "+ TITLE ); - var testcases = getTestCases(); - test( testcases ); +var MIN_VAL = 5e-324; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "Number.MIN_VALUE", + MIN_VAL, + Number.MIN_VALUE ); - var MIN_VAL = 5e-324; - - array[item++] = new TestCase( SECTION, "Number.MIN_VALUE", MIN_VAL, Number.MIN_VALUE ); - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.3-2.js b/mozilla/js/tests/ecma/Number/15.7.3.3-2.js index dd41a2b7596..5d69926cf75 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.3-2.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.3-2.js - ECMA Section: 15.7.3.3 Number.MIN_VALUE - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.3-2.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Number.MIN_VALUE + this test checks the DontDelete attribute of Number.MIN_VALUE - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.MIN_VALUE"; +var SECTION = "15.7.3.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MIN_VALUE"; - writeHeaderToLog( SECTION + " "+ TITLE ); +writeHeaderToLog( SECTION + " "+ TITLE ); - var testcases = getTestCases(); - test( testcases ); +var MIN_VAL = 5e-324; -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "delete( Number.MIN_VALUE )", + false, + eval("delete( Number.MIN_VALUE )") ); - var MIN_VAL = 5e-324; +new TestCase( SECTION, + "delete( Number.MIN_VALUE ); Number.MIN_VALUE", + MIN_VAL, + eval("delete( Number.MIN_VALUE );Number.MIN_VALUE") ); - array[item++] = new TestCase( SECTION, "delete( Number.MIN_VALUE )", false, "delete( Number.MIN_VALUE )" ); - array[item++] = new TestCase( SECTION, "delete( Number.MIN_VALUE ); Number.MIN_VALUE", MIN_VAL, "delete( Number.MIN_VALUE );Number.MIN_VALUE" ); - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.3-3.js b/mozilla/js/tests/ecma/Number/15.7.3.3-3.js index 2f9a92ce6b9..6faaec35547 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.3-3.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.3-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.3-3.js - ECMA Section: 15.7.3.3 Number.MIN_VALUE - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.3-3.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the ReadOnly attribute of Number.MIN_VALUE + this test checks the ReadOnly attribute of Number.MIN_VALUE - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.3-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.MIN_VALUE: ReadOnly Attribute"; +var SECTION = "15.7.3.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.MIN_VALUE: ReadOnly Attribute"; - writeHeaderToLog( SECTION + " "+TITLE ); +writeHeaderToLog( SECTION + " "+TITLE ); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Number.MIN_VALUE=0; Number.MIN_VALUE", + Number.MIN_VALUE, + eval("Number.MIN_VALUE=0; Number.MIN_VALUE" )); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( - SECTION, - "Number.MIN_VALUE=0; Number.MIN_VALUE", - Number.MIN_VALUE, - "Number.MIN_VALUE=0; Number.MIN_VALUE" ); - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += "property should be readonly "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.3-4.js b/mozilla/js/tests/ecma/Number/15.7.3.3-4.js index fc1e7a06e90..fe978efb976 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.3-4.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.3-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,51 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.3-4.js - ECMA Section: 15.7.3.3 Number.MIN_VALUE - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.3-4.js + ECMA Section: 15.7.3.3 Number.MIN_VALUE + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontEnum attribute of Number.MIN_VALUE + this test checks the DontEnum attribute of Number.MIN_VALUE - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.3-4"; - var VERSION = "ECMA_1"; - startTest(); +var SECTION = "15.7.3.3-4"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Number.MIN_VALUE: DontEnum Attribute"); +writeHeaderToLog( SECTION + " Number.MIN_VALUE: DontEnum Attribute"); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;") + ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( - SECTION, - "var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;", - "", - eval("var string = ''; for ( prop in Number ) { string += ( prop == 'MIN_VALUE' ) ? prop : '' } string;") - ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += "property should not be enumerated "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.4-1.js b/mozilla/js/tests/ecma/Number/15.7.3.4-1.js index 13faefcae86..11e00207760 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.4-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.4-1.js - ECMA Section: 15.7.3.4 Number.NaN - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.4-1.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the value of Number.NaN + this test checks the value of Number.NaN - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.NaN"; +var SECTION = "15.7.3.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NaN"; - writeHeaderToLog( SECTION + " "+ TITLE ); +writeHeaderToLog( SECTION + " "+ TITLE ); - var testcases = getTestCases(); - test(); +new TestCase(SECTION, + "NaN", + NaN, + Number.NaN ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase(SECTION, "NaN", NaN, Number.NaN ); - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.4-2.js b/mozilla/js/tests/ecma/Number/15.7.3.4-2.js index dafadbaf360..c6b5711c587 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.4-2.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.4-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.4-2.js - ECMA Section: 15.7.3.4 Number.NaN - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.4-2.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Number.NaN + this test checks the DontDelete attribute of Number.NaN - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.4-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.NaN"; +var SECTION = "15.7.3.4-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NaN"; - writeHeaderToLog( SECTION + " "+ TITLE ); +writeHeaderToLog( SECTION + " "+ TITLE ); - var testcases = getTestCases(); - test(); +new TestCase(SECTION, + "delete( Number.NaN ); Number.NaN", + NaN, + eval("delete( Number.NaN );Number.NaN" )); +new TestCase( SECTION, + "delete( Number.NaN )", + false, + eval("delete( Number.NaN )") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase(SECTION, "delete( Number.NaN ); Number.NaN", NaN, "delete( Number.NaN );Number.NaN" ); - array[item++] = new TestCase( SECTION, "delete( Number.NaN )", false, "delete( Number.NaN )" ); - - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.4-3.js b/mozilla/js/tests/ecma/Number/15.7.3.4-3.js index b1dab709f0d..993efcbd8a8 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.4-3.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.4-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.4-3.js - ECMA Section: 15.7.3.4 Number.NaN - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.4-3.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the ReadOnly attribute of Number.NaN + this test checks the ReadOnly attribute of Number.NaN - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.4-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.NaN"; +var SECTION = "15.7.3.4-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NaN"; - writeHeaderToLog( SECTION + " "+ TITLE ); +writeHeaderToLog( SECTION + " "+ TITLE ); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Number.NaN=0; Number.NaN", + Number.NaN, + eval("Number.NaN=0; Number.NaN") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( - SECTION, - "Number.NaN=0; Number.NaN", - Number.NaN, - "Number.NaN=0; Number.NaN" ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += "property should be readonly "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.4-4.js b/mozilla/js/tests/ecma/Number/15.7.3.4-4.js index d0480445576..56005834ac2 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.4-4.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.4-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.4-4.js - ECMA Section: 15.7.3.4 Number.NaN - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.4-4.js + ECMA Section: 15.7.3.4 Number.NaN + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontEnum attribute of Number.NaN + this test checks the DontEnum attribute of Number.NaN - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.4-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.NaN"; +var SECTION = "15.7.3.4-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NaN"; - writeHeaderToLog( SECTION + " " + TITLE); +writeHeaderToLog( SECTION + " " + TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;") + ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( - SECTION, - "var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;", - "", - eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NaN' ) ? prop : '' } string;") - ); - - return ( array ); -} - -function test( testcases ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += "property should not be enumerated "; - passed = false; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.5-1.js b/mozilla/js/tests/ecma/Number/15.7.3.5-1.js index fe1ba845aba..798c1ca91ec 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.5-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,43 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.5-1.js - ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.5-1.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the value of Number.NEGATIVE_INFINITY + this test checks the value of Number.NEGATIVE_INFINITY - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.5-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.NEGATIVE_INFINITY"; +var SECTION = "15.7.3.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NEGATIVE_INFINITY"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase(SECTION, + "Number.NEGATIVE_INFINITY", + -Infinity, + Number.NEGATIVE_INFINITY ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase(SECTION, "Number.NEGATIVE_INFINITY", -Infinity, Number.NEGATIVE_INFINITY ); - - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.5-2.js b/mozilla/js/tests/ecma/Number/15.7.3.5-2.js index 7898c244d62..c085d5527d4 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.5-2.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.5-2.js - ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.5-2.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Number.NEGATIVE_INFINITY + this test checks the DontDelete attribute of Number.NEGATIVE_INFINITY - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.5-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.NEGATIVE_INFINITY"; +var SECTION = "15.7.3.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NEGATIVE_INFINITY"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "delete( Number.NEGATIVE_INFINITY )", + false, + eval("delete( Number.NEGATIVE_INFINITY )") ); +new TestCase( SECTION, + "delete( Number.NEGATIVE_INFINITY ); Number.NEGATIVE_INFINITY", + -Infinity, + eval("delete( Number.NEGATIVE_INFINITY );Number.NEGATIVE_INFINITY") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "delete( Number.NEGATIVE_INFINITY )", - false, - "delete( Number.NEGATIVE_INFINITY )" ); - - array[item++] = new TestCase( SECTION, - "delete( Number.NEGATIVE_INFINITY ); Number.NEGATIVE_INFINITY", - -Infinity, - "delete( Number.NEGATIVE_INFINITY );Number.NEGATIVE_INFINITY" ); - return ( array ); -} -function test( testcases ) { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.5-3.js b/mozilla/js/tests/ecma/Number/15.7.3.5-3.js index 883b4487a08..37db8e93fc3 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.5-3.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.5-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.5-3.js - ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.5-3.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the ReadOnly attribute of Number.NEGATIVE_INFINITY + this test checks the ReadOnly attribute of Number.NEGATIVE_INFINITY - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.5-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.NEGATIVE_INFINITY"; +var SECTION = "15.7.3.5-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NEGATIVE_INFINITY"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY", + -Infinity, + eval("Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( - SECTION, - "Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY", - -Infinity, - "Number.NEGATIVE_INFINITY=0; Number.NEGATIVE_INFINITY" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += "property should be readonly "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.5-4.js b/mozilla/js/tests/ecma/Number/15.7.3.5-4.js index 1aada3ab9de..5c7c8164ed2 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.5-4.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.5-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.5-4.js - ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.5-4.js + ECMA Section: 15.7.3.5 Number.NEGATIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontEnum attribute of Number.NEGATIVE_INFINITY + this test checks the DontEnum attribute of Number.NEGATIVE_INFINITY - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.5-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.NEGATIVE_INFINITY"; +var SECTION = "15.7.3.5-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.NEGATIVE_INFINITY"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;") + ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( - SECTION, - "var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;", - "", - eval("var string = ''; for ( prop in Number ) { string += ( prop == 'NEGATIVE_INFINITY' ) ? prop : '' } string;") - ); - return ( array ); -} - -function test( testcases ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += "property should not be enumerated "; - - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.6-1.js b/mozilla/js/tests/ecma/Number/15.7.3.6-1.js index 56d21e88a4f..a9b3c688edb 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.6-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.6-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,42 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.6-1.js - ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.6-1.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the value of Number.POSITIVE_INFINITY + this test checks the value of Number.POSITIVE_INFINITY - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.6-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.POSITIVE_INFINITY"; +var SECTION = "15.7.3.6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.POSITIVE_INFINITY"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY", Infinity, Number.POSITIVE_INFINITY ); - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase( SECTION, + "Number.POSITIVE_INFINITY", + Infinity, + Number.POSITIVE_INFINITY ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.6-2.js b/mozilla/js/tests/ecma/Number/15.7.3.6-2.js index 1433470983a..43f2a8d9058 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.6-2.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.6-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.6-2.js - ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.6-2.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontDelete attribute of Number.POSITIVE_INFINITY + this test checks the DontDelete attribute of Number.POSITIVE_INFINITY - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.6-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.POSITIVE_INFINITY"; +var SECTION = "15.7.3.6-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.POSITIVE_INFINITY"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase(SECTION, + "delete( Number.POSITIVE_INFINITY )", + false, + eval("delete( Number.POSITIVE_INFINITY )") ); +new TestCase(SECTION, + "delete( Number.POSITIVE_INFINITY ); Number.POSITIVE_INFINITY", + Infinity, + eval("delete( Number.POSITIVE_INFINITY );Number.POSITIVE_INFINITY") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase(SECTION, "delete( Number.POSITIVE_INFINITY )", false, "delete( Number.POSITIVE_INFINITY )" ); - array[item++] = new TestCase(SECTION, "delete( Number.POSITIVE_INFINITY ); Number.POSITIVE_INFINITY", Infinity, "delete( Number.POSITIVE_INFINITY );Number.POSITIVE_INFINITY" ); - return ( array ); -} - -function test( testcases ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "delete should not be allowed " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.6-3.js b/mozilla/js/tests/ecma/Number/15.7.3.6-3.js index d5fb82ef3e8..409f6960d8a 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.6-3.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.6-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.6-3.js - ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.6-3.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the ReadOnly attribute of Number.POSITIVE_INFINITY + this test checks the ReadOnly attribute of Number.POSITIVE_INFINITY - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.6-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.POSITIVE_INFINITY"; +var SECTION = "15.7.3.6-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.POSITIVE_INFINITY"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY", + Number.POSITIVE_INFINITY, + eval("Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( - SECTION, - "Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY", - Number.POSITIVE_INFINITY, - "Number.POSITIVE_INFINITY=0; Number.POSITIVE_INFINITY" ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += "property should be readonly "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.6-4.js b/mozilla/js/tests/ecma/Number/15.7.3.6-4.js index e51cd7c89ff..62614116e10 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.6-4.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.6-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.6-4.js - ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY - Description: All value properties of the Number object should have - the attributes [DontEnum, DontDelete, ReadOnly] + File Name: 15.7.3.6-4.js + ECMA Section: 15.7.3.6 Number.POSITIVE_INFINITY + Description: All value properties of the Number object should have + the attributes [DontEnum, DontDelete, ReadOnly] - this test checks the DontEnum attribute of Number.POSITIVE_INFINITY + this test checks the DontEnum attribute of Number.POSITIVE_INFINITY - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.3.6-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.POSITIVE_INFINITY"; +var SECTION = "15.7.3.6-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.POSITIVE_INFINITY"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;", + "", + eval("var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;") + ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( - SECTION, - "var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;", - "", - eval("var string = ''; for ( prop in Number ) { string += ( prop == 'POSITIVE_INFINITY' ) ? prop : '' } string;") - ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += "property should not be enumerated "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.3.js b/mozilla/js/tests/ecma/Number/15.7.3.js index c71deb431ef..93738df8378 100644 --- a/mozilla/js/tests/ecma/Number/15.7.3.js +++ b/mozilla/js/tests/ecma/Number/15.7.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.3.js - 15.7.3 Properties of the Number Constructor + File Name: 15.7.3.js + 15.7.3 Properties of the Number Constructor - Description: The value of the internal [[Prototype]] property - of the Number constructor is the Function prototype - object. The Number constructor also has the internal - [[Call]] and [[Construct]] properties, and the length - property. + Description: The value of the internal [[Prototype]] property + of the Number constructor is the Function prototype + object. The Number constructor also has the internal + [[Call]] and [[Construct]] properties, and the length + property. - Other properties are in subsequent tests. + Other properties are in subsequent tests. - Author: christine@netscape.com - Date: 29 september 1997 + Author: christine@netscape.com + Date: 29 september 1997 */ - var SECTION = "15.7.3"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "Properties of the Number Constructor"; +var SECTION = "15.7.3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Number Constructor"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase(SECTION, + "Number.__proto__", + Function.prototype, + Number.__proto__ ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase(SECTION, "Number.__proto__", Function.prototype, Number.__proto__ ); - array[item++] = new TestCase(SECTION, "Number.length", 1, Number.length ); +new TestCase(SECTION, + "Number.length", + 1, + Number.length ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4-1.js b/mozilla/js/tests/ecma/Number/15.7.4-1.js index 9ccf571f32c..1d2fceac129 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** File Name: 15.7.4-1.js ECMA Section: 15.7.4.1 Properties of the Number Prototype Object @@ -48,31 +50,9 @@ startTest(); writeHeaderToLog( SECTION + "Properties of the Number prototype object"); - var testcases = getTestCases(); + new TestCase(SECTION, "Number.prototype.valueOf()", 0, Number.prototype.valueOf() ); + new TestCase(SECTION, "typeof(Number.prototype)", "object", typeof(Number.prototype) ); + new TestCase(SECTION, "Number.prototype.constructor == Number", true, Number.prototype.constructor == Number ); +// new TestCase(SECTION, "Number.prototype == Number.__proto__", true, Number.prototype == Number.__proto__ ); - test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase(SECTION, "Number.prototype.valueOf()", 0, Number.prototype.valueOf() ); - array[item++] = new TestCase(SECTION, "typeof(Number.prototype)", "object", typeof(Number.prototype) ); - array[item++] = new TestCase(SECTION, "Number.prototype.constructor == Number", true, Number.prototype.constructor == Number ); -// array[item++] = new TestCase(SECTION, "Number.prototype == Number.__proto__", true, Number.prototype == Number.__proto__ ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.1.js b/mozilla/js/tests/ecma/Number/15.7.4.1.js index 59be37c81c1..d833c249c35 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.1.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,26 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.1.js - ECMA Section: 15.7.4.1.1 Number.prototype.constructor + File Name: 15.7.4.1.js + ECMA Section: 15.7.4.1.1 Number.prototype.constructor - Number.prototype.constructor is the built-in Number constructor. + Number.prototype.constructor is the built-in Number constructor. - Description: - Author: christine@netscape.com - Date: 16 september 1997 + Description: + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.4.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Number.prototype.constructor"; +var SECTION = "15.7.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Number.prototype.constructor"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "Number.prototype.constructor", - Number, - Number.prototype.constructor ); - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "Number.prototype.constructor", + Number, + Number.prototype.constructor ); +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.2-1.js b/mozilla/js/tests/ecma/Number/15.7.4.2-1.js index 406a22e34af..92117294716 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.2-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.2.js - ECMA Section: 15.7.4.2.1 Number.prototype.toString() - Description: - If the radix is the number 10 or not supplied, then this number value is - given as an argument to the ToString operator; the resulting string value - is returned. + File Name: 15.7.4.2.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. - If the radix is supplied and is an integer from 2 to 36, but not 10, the - result is a string, the choice of which is implementation dependent. + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. - The toString function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.4.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); - - writeHeaderToLog( SECTION + " Number.prototype.toString()"); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; +var SECTION = "15.7.4.2-1"; +var VERSION = "ECMA_1"; +startTest(); +writeHeaderToLog( SECTION + " Number.prototype.toString()"); + // the following two lines cause navigator to crash -- cmb 9/16/97 - array[item++] = new TestCase(SECTION, "Number.prototype.toString()", "0", "Number.prototype.toString()" ); - array[item++] = new TestCase(SECTION, "typeof(Number.prototype.toString())", "string", "typeof(Number.prototype.toString())" ); +new TestCase(SECTION, + "Number.prototype.toString()", + "0", + eval("Number.prototype.toString()") ); - array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()", "0", "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()" ); - array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()", "1", "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()" ); - array[item++] = new TestCase(SECTION, "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()", "-1", "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()" ); +new TestCase(SECTION, + "typeof(Number.prototype.toString())", + "string", + eval("typeof(Number.prototype.toString())") ); - array[item++] = new TestCase(SECTION, "var MYNUM = new Number(255); MYNUM.toString(10)", "255", "var MYNUM = new Number(255); MYNUM.toString(10)" ); - array[item++] = new TestCase(SECTION, "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)", "NaN", "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)" ); - array[item++] = new TestCase(SECTION, "var MYNUM = new Number(Infinity); MYNUM.toString(10)", "Infinity", "var MYNUM = new Number(Infinity); MYNUM.toString(10)" ); - array[item++] = new TestCase(SECTION, "var MYNUM = new Number(-Infinity); MYNUM.toString(10)", "-Infinity", "var MYNUM = new Number(-Infinity); MYNUM.toString(10)" ); +new TestCase(SECTION, + "s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()", + "0", + eval("s = Number.prototype.toString; o = new Number(); o.toString = s; o.toString()") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual= eval(testcases[tc].actual ); +new TestCase(SECTION, + "s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()", + "1", + eval("s = Number.prototype.toString; o = new Number(1); o.toString = s; o.toString()") ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase(SECTION, + "s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()", + "-1", + eval("s = Number.prototype.toString; o = new Number(-1); o.toString = s; o.toString()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase(SECTION, + "var MYNUM = new Number(255); MYNUM.toString(10)", + "255", + eval("var MYNUM = new Number(255); MYNUM.toString(10)") ); + +new TestCase(SECTION, + "var MYNUM = new Number(Number.NaN); MYNUM.toString(10)", + "NaN", + eval("var MYNUM = new Number(Number.NaN); MYNUM.toString(10)") ); + +new TestCase(SECTION, + "var MYNUM = new Number(Infinity); MYNUM.toString(10)", + "Infinity", + eval("var MYNUM = new Number(Infinity); MYNUM.toString(10)") ); + +new TestCase(SECTION, + "var MYNUM = new Number(-Infinity); MYNUM.toString(10)", + "-Infinity", + eval("var MYNUM = new Number(-Infinity); MYNUM.toString(10)") ); + +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.2-2-n.js b/mozilla/js/tests/ecma/Number/15.7.4.2-2-n.js index defe8a1c3c2..d23b795121c 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.2-2-n.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.2-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,40 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.2-2-n.js - ECMA Section: 15.7.4.2.1 Number.prototype.toString() - Description: - If the radix is the number 10 or not supplied, then this number value is - given as an argument to the ToString operator; the resulting string value - is returned. + File Name: 15.7.4.2-2-n.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. - If the radix is supplied and is an integer from 2 to 36, but not 10, the - result is a string, the choice of which is implementation dependent. + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. - The toString function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.4.2-2-n"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "15.7.4.2-2-n"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Number.prototype.toString()"); - test(); +writeHeaderToLog( SECTION + " Number.prototype.toString()"); -function getTestCases() { - var array = new Array(); - var item = 0; +DESCRIPTION = "o = new Object(); o.toString = Number.prototype.toString; o.toString()"; +EXPECTED = "error"; - array[item++] = new TestCase(SECTION, "o = new Object(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new Object(); o.toString = Number.prototype.toString; o.toString()" ); -// array[item++] = new TestCase(SECTION, "o = new String(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new String(); o.toString = Number.prototype.toString; o.toString()" ); -// array[item++] = new TestCase(SECTION, "o = 3; o.toString = Number.prototype.toString; o.toString()", "error", "o = 3; o.toString = Number.prototype.toString; o.toString()" ); +new TestCase(SECTION, + "o = new Object(); o.toString = Number.prototype.toString; o.toString()", + "error", + eval("o = new Object(); o.toString = Number.prototype.toString; o.toString()") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +// new TestCase(SECTION, "o = new String(); o.toString = Number.prototype.toString; o.toString()", "error", eval("o = new String(); o.toString = Number.prototype.toString; o.toString()") ); +// new TestCase(SECTION, "o = 3; o.toString = Number.prototype.toString; o.toString()", "error", eval("o = 3; o.toString = Number.prototype.toString; o.toString()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.2-3-n.js b/mozilla/js/tests/ecma/Number/15.7.4.2-3-n.js index 726051f78a1..85e30a1583a 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.2-3-n.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.2-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.2-3-n.js - ECMA Section: 15.7.4.2.1 Number.prototype.toString() - Description: - If the radix is the number 10 or not supplied, then this number value is - given as an argument to the ToString operator; the resulting string value - is returned. + File Name: 15.7.4.2-3-n.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. - If the radix is supplied and is an integer from 2 to 36, but not 10, the - result is a string, the choice of which is implementation dependent. + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. - The toString function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.4.2-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "15.7.4.2-3-n"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Number.prototype.toString()"); - test(); +writeHeaderToLog( SECTION + " Number.prototype.toString()"); -function getTestCases() { - var array = new Array(); - var item = 0; +DESCRIPTION = "o = new String(); o.toString = Number.prototype.toString; o.toString()"; +EXPECTED = "error"; - array[item++] = new TestCase(SECTION, "o = new String(); o.toString = Number.prototype.toString; o.toString()", "error", "o = new String(); o.toString = Number.prototype.toString; o.toString()" ); +new TestCase(SECTION, + "o = new String(); o.toString = Number.prototype.toString; o.toString()", + "error", + eval("o = new String(); o.toString = Number.prototype.toString; o.toString()") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.2-4.js b/mozilla/js/tests/ecma/Number/15.7.4.2-4.js index b37ceb7e16d..12690b1ea4d 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.2-4.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.2-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.2-4.js - ECMA Section: 15.7.4.2.1 Number.prototype.toString() - Description: - If the radix is the number 10 or not supplied, then this number value is - given as an argument to the ToString operator; the resulting string value - is returned. + File Name: 15.7.4.2-4.js + ECMA Section: 15.7.4.2.1 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. - If the radix is supplied and is an integer from 2 to 36, but not 10, the - result is a string, the choice of which is implementation dependent. + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. - The toString function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.4.2-4"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "15.7.4.2-4"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Number.prototype.toString()"); - test(); +writeHeaderToLog( SECTION + " Number.prototype.toString()"); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase(SECTION, + "o = 3; o.toString = Number.prototype.toString; o.toString()", + "3", + eval("o = 3; o.toString = Number.prototype.toString; o.toString()") ); - array[item++] = new TestCase(SECTION, "o = 3; o.toString = Number.prototype.toString; o.toString()", "3", "o = 3; o.toString = Number.prototype.toString; o.toString()" ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.3-1.js b/mozilla/js/tests/ecma/Number/15.7.4.3-1.js index 59c625c30e7..1ccff42c5a5 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.3-1.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,61 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.3-1.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. + File Name: 15.7.4.3-1.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.4.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); - - writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - test(); +var SECTION = "15.7.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); -function getTestCases() { - var array = new Array(); - var item = 0; +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); // the following two line causes navigator to crash -- cmb 9/16/97 - array[item++] = new TestCase("15.7.4.1", "Number.prototype.valueOf()", 0, "Number.prototype.valueOf()" ); +new TestCase("SECTION", + "Number.prototype.valueOf()", + 0, + eval("Number.prototype.valueOf()") ); - array[item++] = new TestCase("15.7.4.1", "(new Number(1)).valueOf()", 1, "(new Number(1)).valueOf()" ); - array[item++] = new TestCase("15.7.4.1", "(new Number(-1)).valueOf()", -1, "(new Number(-1)).valueOf()" ); - array[item++] = new TestCase("15.7.4.1", "(new Number(0)).valueOf()", 0, "(new Number(0)).valueOf()" ); - array[item++] = new TestCase("15.7.4.1", "(new Number(Number.POSITIVE_INFINITY)).valueOf()", Number.POSITIVE_INFINITY, "(new Number(Number.POSITIVE_INFINITY)).valueOf()" ); - array[item++] = new TestCase("15.7.4.1", "(new Number(Number.NaN)).valueOf()", Number.NaN, "(new Number(Number.NaN)).valueOf()" ); - array[item++] = new TestCase("15.7.4.1", "(new Number()).valueOf()", 0, "(new Number()).valueOf()" ); +new TestCase("SECTION", + "(new Number(1)).valueOf()", + 1, + eval("(new Number(1)).valueOf()") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase("SECTION", + "(new Number(-1)).valueOf()", + -1, + eval("(new Number(-1)).valueOf()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase("SECTION", + "(new Number(0)).valueOf()", + 0, + eval("(new Number(0)).valueOf()") ); + +new TestCase("SECTION", + "(new Number(Number.POSITIVE_INFINITY)).valueOf()", + Number.POSITIVE_INFINITY, + eval("(new Number(Number.POSITIVE_INFINITY)).valueOf()") ); + +new TestCase("SECTION", + "(new Number(Number.NaN)).valueOf()", + Number.NaN, + eval("(new Number(Number.NaN)).valueOf()") ); + +new TestCase("SECTION", + "(new Number()).valueOf()", + 0, + eval("(new Number()).valueOf()") ); + +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.3-2.js b/mozilla/js/tests/ecma/Number/15.7.4.3-2.js index 78a05e2d551..de7e21ca863 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.3-2.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.3-2.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. + File Name: 15.7.4.3-2.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.4.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "15.7.4.3-2"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - test(); +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase(SECTION, + "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", + 3, + eval("v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()") ); - array[item++] = new TestCase(SECTION, "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", 3, "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()" ); - - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.3-3-n.js b/mozilla/js/tests/ecma/Number/15.7.4.3-3-n.js index cfeaa4b2be8..5ad17fa0ea7 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.3-3-n.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.3-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.3-3.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. + File Name: 15.7.4.3-3.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "15.7.4.3-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "15.7.4.3-3-n"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - test(); +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); +// new TestCase("15.7.4.1", "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", "error", eval("v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()") ); -function getTestCases() { - var array = new Array(); - var item = 0; +DESCRIPTION = "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()"; +EXPECTED = "error"; -// array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()", "error", "v = Number.prototype.valueOf; num = 3; num.valueOf = v; num.valueOf()" ); - array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()", "error", "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()" ); -// array[item++] = new TestCase("15.7.4.1", "v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()", "error", "v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()" ); +new TestCase("15.7.4.1", + "v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()", + "error", + eval("v = Number.prototype.valueOf; o = new String('Infinity'); o.valueOf = v; o.valueOf()") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +// new TestCase("15.7.4.1", "v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()", "error", eval("v = Number.prototype.valueOf; o = new Object(); o.valueOf = v; o.valueOf()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/15.7.4.js b/mozilla/js/tests/ecma/Number/15.7.4.js index 5d1d3a63a3c..baee2bac151 100644 --- a/mozilla/js/tests/ecma/Number/15.7.4.js +++ b/mozilla/js/tests/ecma/Number/15.7.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,68 +35,54 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.7.4.js - ECMA Section: 15.7.4 + File Name: 15.7.4.js + ECMA Section: 15.7.4 - Description: + Description: - The Number prototype object is itself a Number object (its [[Class]] is - "Number") whose value is +0. + The Number prototype object is itself a Number object (its [[Class]] is + "Number") whose value is +0. - The value of the internal [[Prototype]] property of the Number prototype - object is the Object prototype object (15.2.3.1). + The value of the internal [[Prototype]] property of the Number prototype + object is the Object prototype object (15.2.3.1). - In following descriptions of functions that are properties of the Number - prototype object, the phrase "this Number object" refers to the object - that is the this value for the invocation of the function; it is an error - if this does not refer to an object for which the value of the internal - [[Class]] property is "Number". Also, the phrase "this number value" refers - to the number value represented by this Number object, that is, the value - of the internal [[Value]] property of this Number object. + In following descriptions of functions that are properties of the Number + prototype object, the phrase "this Number object" refers to the object + that is the this value for the invocation of the function; it is an error + if this does not refer to an object for which the value of the internal + [[Class]] property is "Number". Also, the phrase "this number value" refers + to the number value represented by this Number object, that is, the value + of the internal [[Value]] property of this Number object. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.7.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the Number Prototype Object"; +var SECTION = "15.7.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Number Prototype Object"; - writeHeaderToLog( SECTION + " "+TITLE); +writeHeaderToLog( SECTION + " "+TITLE); - var testcases = getTestCases(); - test( testcases ); +new TestCase( SECTION, + "Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()", + "[object Number]", + eval("Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, - "Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()", - "[object Number]", - eval("Number.prototype.toString=Object.prototype.toString;Number.prototype.toString()") ); - array[item++] = new TestCase( SECTION, "typeof Number.prototype", "object", typeof Number.prototype ); - array[item++] = new TestCase( SECTION, "Number.prototype.valueOf()", 0, Number.prototype.valueOf() ); +new TestCase( SECTION, + "typeof Number.prototype", + "object", + typeof Number.prototype ); +new TestCase( SECTION, + "Number.prototype.valueOf()", + 0, + Number.prototype.valueOf() ); // The __proto__ property cannot be used in ECMA_1 tests. -// array[item++] = new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); -// array[item++] = new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); +// new TestCase( SECTION, "Number.prototype.__proto__", Object.prototype, Number.prototype.__proto__ ); +// new TestCase( SECTION, "Number.prototype.__proto__ == Object.prototype", true, Number.prototype.__proto__ == Object.prototype ); - - return ( array ); -} -function test( ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - - } - - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Number/browser.js b/mozilla/js/tests/ecma/Number/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Number/shell.js b/mozilla/js/tests/ecma/Number/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.1.1.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.1.1.js index 30c0040e462..ba647d8dc27 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.1.1.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.1.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,133 +35,112 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.1.1.js - ECMA Section: 15.2.1.1 The Object Constructor Called as a Function: - Object(value) - Description: When Object is called as a function rather than as a - constructor, the following steps are taken: + File Name: 15.2.1.1.js + ECMA Section: 15.2.1.1 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: - 1. If value is null or undefined, create and return a - new object with no properties other than internal - properties exactly as if the object constructor - had been called on that same value (15.2.2.1). - 2. Return ToObject (value), whose rules are: + 1. If value is null or undefined, create and return a + new object with no properties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: - undefined generate a runtime error - null generate a runtime error - boolean create a new Boolean object whose default - value is the value of the boolean. - number Create a new Number object whose default - value is the value of the number. - string Create a new String object whose default - value is the value of the string. - object Return the input argument (no conversion). + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). - Author: christine@netscape.com - Date: 17 july 1997 + Author: christine@netscape.com + Date: 17 july 1997 */ - var SECTION = "15.2.1.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object( value )"; +var SECTION = "15.2.1.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object( value )"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +var NULL_OBJECT = Object(null); - var NULL_OBJECT = Object(null); +new TestCase( SECTION, "Object(null).valueOf()", NULL_OBJECT, (NULL_OBJECT).valueOf() ); +new TestCase( SECTION, "typeof Object(null)", "object", typeof (Object(null)) ); +new TestCase( SECTION, "Object(null).__proto__", Object.prototype, (Object(null)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(null).valueOf()", NULL_OBJECT, (NULL_OBJECT).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(null)", "object", typeof (Object(null)) ); - array[item++] = new TestCase( SECTION, "Object(null).__proto__", Object.prototype, (Object(null)).__proto__ ); +var UNDEFINED_OBJECT = Object( void 0 ); - var UNDEFINED_OBJECT = Object( void 0 ); +new TestCase( SECTION, "Object(void 0).valueOf()", UNDEFINED_OBJECT, (UNDEFINED_OBJECT).valueOf() ); +new TestCase( SECTION, "typeof Object(void 0)", "object", typeof (Object(void 0)) ); +new TestCase( SECTION, "Object(void 0).__proto__", Object.prototype, (Object(void 0)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(void 0).valueOf()", UNDEFINED_OBJECT, (UNDEFINED_OBJECT).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(void 0)", "object", typeof (Object(void 0)) ); - array[item++] = new TestCase( SECTION, "Object(void 0).__proto__", Object.prototype, (Object(void 0)).__proto__ ); +new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); +new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); +new TestCase( SECTION, "var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); +new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); +new TestCase( SECTION, "var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("var MYOB = Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); +new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); +new TestCase( SECTION, "var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); +new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); +new TestCase( SECTION, "var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); +new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); +new TestCase( SECTION, "var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); +new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); +new TestCase( SECTION, "var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); +new TestCase( SECTION, "var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MAX_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); +new TestCase( SECTION, "var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.MIN_VALUE); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.POSITIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NEGATIVE_INFINITY); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); +new TestCase( SECTION, "var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("var MYOB = Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); +new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); +new TestCase( SECTION, "var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('a string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); +new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); +new TestCase( SECTION, "var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); +new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); +new TestCase( SECTION, "var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object('\\r\\t\\b\\n\\v\\f'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); +new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); +// new TestCase( SECTION, "var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); -// array[item++] = new TestCase( SECTION, "var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("var MYOB = Object( '\\\'\\\"\\' ); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += - ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.1.2.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.1.2.js index 1514da38973..b450d634b1b 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.1.2.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.1.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,67 +35,45 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.1.2.js - ECMA Section: 15.2.1.2 The Object Constructor Called as a Function: - Object(value) - Description: When Object is called as a function rather than as a - constructor, the following steps are taken: + File Name: 15.2.1.2.js + ECMA Section: 15.2.1.2 The Object Constructor Called as a Function: + Object(value) + Description: When Object is called as a function rather than as a + constructor, the following steps are taken: - 1. If value is null or undefined, create and return a - new object with no proerties other than internal - properties exactly as if the object constructor - had been called on that same value (15.2.2.1). - 2. Return ToObject (value), whose rules are: + 1. If value is null or undefined, create and return a + new object with no proerties other than internal + properties exactly as if the object constructor + had been called on that same value (15.2.2.1). + 2. Return ToObject (value), whose rules are: - undefined generate a runtime error - null generate a runtime error - boolean create a new Boolean object whose default - value is the value of the boolean. - number Create a new Number object whose default - value is the value of the number. - string Create a new String object whose default - value is the value of the string. - object Return the input argument (no conversion). + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). - Author: christine@netscape.com - Date: 17 july 1997 + Author: christine@netscape.com + Date: 17 july 1997 */ - var SECTION = "15.2.1.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object()"; +var SECTION = "15.2.1.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var MYOB = Object(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var MYOB = Object(); MYOB.valueOf()", MYOB, MYOB.valueOf() ); +new TestCase( SECTION, "typeof Object()", "object", typeof (Object(null)) ); +new TestCase( SECTION, "var MYOB = Object(); MYOB.toString()", "[object Object]", eval("var MYOB = Object(); MYOB.toString()") ); - var MYOB = Object(); - - array[item++] = new TestCase( SECTION, "var MYOB = Object(); MYOB.valueOf()", MYOB, MYOB.valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object()", "object", typeof (Object(null)) ); - array[item++] = new TestCase( SECTION, "var MYOB = Object(); MYOB.toString()", "[object Object]", eval("var MYOB = Object(); MYOB.toString()") ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += - ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.2.1.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.2.1.js index 34680c7e822..2780c8b672f 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.2.1.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.2.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,121 +35,102 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.2.1.js - ECMA Section: 15.2.2.1 The Object Constructor: new Object( value ) + File Name: 15.2.2.1.js + ECMA Section: 15.2.2.1 The Object Constructor: new Object( value ) - 1.If the type of the value is not Object, go to step 4. - 2.If the value is a native ECMAScript object, do not create a new object; simply return value. - 3.If the value is a host object, then actions are taken and a result is returned in an - implementation-dependent manner that may depend on the host object. - 4.If the type of the value is String, return ToObject(value). - 5.If the type of the value is Boolean, return ToObject(value). - 6.If the type of the value is Number, return ToObject(value). - 7.(The type of the value must be Null or Undefined.) Create a new native ECMAScript object. - The [[Prototype]] property of the newly constructed object is set to the Object prototype object. - The [[Class]] property of the newly constructed object is set to "Object". - The newly constructed object has no [[Value]] property. - Return the newly created native object. + 1.If the type of the value is not Object, go to step 4. + 2.If the value is a native ECMAScript object, do not create a new object; simply return value. + 3.If the value is a host object, then actions are taken and a result is returned in an + implementation-dependent manner that may depend on the host object. + 4.If the type of the value is String, return ToObject(value). + 5.If the type of the value is Boolean, return ToObject(value). + 6.If the type of the value is Number, return ToObject(value). + 7.(The type of the value must be Null or Undefined.) Create a new native ECMAScript object. + The [[Prototype]] property of the newly constructed object is set to the Object prototype object. + The [[Class]] property of the newly constructed object is set to "Object". + The newly constructed object has no [[Value]] property. + Return the newly created native object. - Description: This does not test cases where the object is a host object. - Author: christine@netscape.com - Date: 7 october 1997 + Description: This does not test cases where the object is a host object. + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.2.2.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "new Object( value )"; +var SECTION = "15.2.2.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Object( value )"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "typeof new Object(null)", "object", typeof new Object(null) ); - array[item++] = new TestCase( SECTION, "MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - - array[item++] = new TestCase( SECTION, "typeof new Object(void 0)", "object", typeof new Object(void 0) ); - array[item++] = new TestCase( SECTION, "MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - - array[item++] = new TestCase( SECTION, "typeof new Object('string')", "object", typeof new Object('string') ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object('string').valueOf()", "string", (new Object('string')).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object('')", "object", typeof new Object('') ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object('').valueOf()", "", (new Object('')).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object(Number.NaN)", "object", typeof new Object(Number.NaN) ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object(Number.NaN).valueOf()", Number.NaN, (new Object(Number.NaN)).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object(0)", "object", typeof new Object(0) ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object(0).valueOf()", 0, (new Object(0)).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object(-0)", "object", typeof new Object(-0) ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object(-0).valueOf()", -0, (new Object(-0)).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object(1)", "object", typeof new Object(1) ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object(1).valueOf()", 1, (new Object(1)).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object(-1)", "object", typeof new Object(-1) ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object(-1).valueOf()", -1, (new Object(-1)).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object(true)", "object", typeof new Object(true) ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object(true).valueOf()", true, (new Object(true)).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object(false)", "object", typeof new Object(false) ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object(false).valueOf()", false, (new Object(false)).valueOf() ); - - array[item++] = new TestCase( SECTION, "typeof new Object(Boolean())", "object", typeof new Object(Boolean()) ); - array[item++] = new TestCase( SECTION, "MYOB = (new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object(Boolean()).valueOf()", Boolean(), (new Object(Boolean())).valueOf() ); +writeHeaderToLog( SECTION + " "+ TITLE); - var myglobal = this; - var myobject = new Object( "my new object" ); - var myarray = new Array(); - var myboolean = new Boolean(); - var mynumber = new Number(); - var mystring = new String(); - var myobject = new Object(); - var myfunction = new Function( "x", "return x"); - var mymath = Math; +new TestCase( SECTION, "typeof new Object(null)", "object", typeof new Object(null) ); +new TestCase( SECTION, "MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(null); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - array[item++] = new TestCase( SECTION, "myglobal = new Object( this )", myglobal, new Object(this) ); - array[item++] = new TestCase( SECTION, "myobject = new Object('my new object'); new Object(myobject)", myobject, new Object(myobject) ); - array[item++] = new TestCase( SECTION, "myarray = new Array(); new Object(myarray)", myarray, new Object(myarray) ); - array[item++] = new TestCase( SECTION, "myboolean = new Boolean(); new Object(myboolean)", myboolean, new Object(myboolean) ); - array[item++] = new TestCase( SECTION, "mynumber = new Number(); new Object(mynumber)", mynumber, new Object(mynumber) ); - array[item++] = new TestCase( SECTION, "mystring = new String9); new Object(mystring)", mystring, new Object(mystring) ); - array[item++] = new TestCase( SECTION, "myobject = new Object(); new Object(mynobject)", myobject, new Object(myobject) ); - array[item++] = new TestCase( SECTION, "myfunction = new Function(); new Object(myfunction)", myfunction, new Object(myfunction) ); - array[item++] = new TestCase( SECTION, "mymath = Math; new Object(mymath)", mymath, new Object(mymath) ); +new TestCase( SECTION, "typeof new Object(void 0)", "object", typeof new Object(void 0) ); +new TestCase( SECTION, "MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Object]", eval("MYOB = new Object(new Object(void 0)); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); - return ( array ); -} -function test() { - for (tc = 0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; +new TestCase( SECTION, "typeof new Object('string')", "object", typeof new Object('string') ); +new TestCase( SECTION, "MYOB = (new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object('string'); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object('string').valueOf()", "string", (new Object('string')).valueOf() ); - } +new TestCase( SECTION, "typeof new Object('')", "object", typeof new Object('') ); +new TestCase( SECTION, "MYOB = (new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object String]", eval("MYOB = new Object(''); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object('').valueOf()", "", (new Object('')).valueOf() ); - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, "typeof new Object(Number.NaN)", "object", typeof new Object(Number.NaN) ); +new TestCase( SECTION, "MYOB = (new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(Number.NaN); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(Number.NaN).valueOf()", Number.NaN, (new Object(Number.NaN)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(0)", "object", typeof new Object(0) ); +new TestCase( SECTION, "MYOB = (new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(0).valueOf()", 0, (new Object(0)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(-0)", "object", typeof new Object(-0) ); +new TestCase( SECTION, "MYOB = (new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-0); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(-0).valueOf()", -0, (new Object(-0)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(1)", "object", typeof new Object(1) ); +new TestCase( SECTION, "MYOB = (new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(1).valueOf()", 1, (new Object(1)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(-1)", "object", typeof new Object(-1) ); +new TestCase( SECTION, "MYOB = (new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Number]", eval("MYOB = new Object(-1); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(-1).valueOf()", -1, (new Object(-1)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(true)", "object", typeof new Object(true) ); +new TestCase( SECTION, "MYOB = (new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(true); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(true).valueOf()", true, (new Object(true)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(false)", "object", typeof new Object(false) ); +new TestCase( SECTION, "MYOB = (new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(false); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(false).valueOf()", false, (new Object(false)).valueOf() ); + +new TestCase( SECTION, "typeof new Object(Boolean())", "object", typeof new Object(Boolean()) ); +new TestCase( SECTION, "MYOB = (new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()", "[object Boolean]", eval("MYOB = new Object(Boolean()); MYOB.toString = Object.prototype.toString; MYOB.toString()") ); +new TestCase( SECTION, "(new Object(Boolean()).valueOf()", Boolean(), (new Object(Boolean())).valueOf() ); + + +var myglobal = this; +var myobject = new Object( "my new object" ); +var myarray = new Array(); +var myboolean = new Boolean(); +var mynumber = new Number(); +var mystring = new String(); +var myobject = new Object(); +var myfunction = new Function( "x", "return x"); +var mymath = Math; + +new TestCase( SECTION, "myglobal = new Object( this )", myglobal, new Object(this) ); +new TestCase( SECTION, "myobject = new Object('my new object'); new Object(myobject)", myobject, new Object(myobject) ); +new TestCase( SECTION, "myarray = new Array(); new Object(myarray)", myarray, new Object(myarray) ); +new TestCase( SECTION, "myboolean = new Boolean(); new Object(myboolean)", myboolean, new Object(myboolean) ); +new TestCase( SECTION, "mynumber = new Number(); new Object(mynumber)", mynumber, new Object(mynumber) ); +new TestCase( SECTION, "mystring = new String9); new Object(mystring)", mystring, new Object(mystring) ); +new TestCase( SECTION, "myobject = new Object(); new Object(mynobject)", myobject, new Object(myobject) ); +new TestCase( SECTION, "myfunction = new Function(); new Object(myfunction)", myfunction, new Object(myfunction) ); +new TestCase( SECTION, "mymath = Math; new Object(mymath)", mymath, new Object(mymath) ); + +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.2.2.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.2.2.js index ac0e510a46b..4099f0f448a 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.2.2.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.2.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,63 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.2.2.js - ECMA Section: 15.2.2.2 new Object() - Description: + File Name: 15.2.2.2.js + ECMA Section: 15.2.2.2 new Object() + Description: - When the Object constructor is called with no argument, the following - step is taken: + When the Object constructor is called with no argument, the following + step is taken: - 1. Create a new native ECMAScript object. - The [[Prototype]] property of the newly constructed object is set to - the Object prototype object. + 1. Create a new native ECMAScript object. + The [[Prototype]] property of the newly constructed object is set to + the Object prototype object. - The [[Class]] property of the newly constructed object is set - to "Object". + The [[Class]] property of the newly constructed object is set + to "Object". - The newly constructed object has no [[Value]] property. + The newly constructed object has no [[Value]] property. - Return the newly created native object. + Return the newly created native object. - Author: christine@netscape.com - Date: 7 october 1997 + Author: christine@netscape.com + Date: 7 october 1997 */ - var SECTION = "15.2.2.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "new Object()"; +var SECTION = "15.2.2.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "new Object()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "typeof new Object()", "object", typeof new Object() ); +new TestCase( SECTION, "Object.prototype.toString()", "[object Object]", Object.prototype.toString() ); +new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "typeof new Object()", "object", typeof new Object() ); - array[item++] = new TestCase( SECTION, "Object.prototype.toString()", "[object Object]", Object.prototype.toString() ); - array[item++] = new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); - - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - -function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - this.toString = new Function( "return this.value+''" ); -} \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.3-1.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.3-1.js index 51317261c3b..ed8415159cc 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.3-1.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.3-1.js - ECMA Section: 15.2.3 Properties of the Object Constructor + File Name: 15.2.3-1.js + ECMA Section: 15.2.3 Properties of the Object Constructor - Description: The value of the internal [[Prototype]] property of the - Object constructor is the Function prototype object. + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. - Besides the call and construct propreties and the length - property, the Object constructor has properties described - in 15.2.3.1. + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.3"; - var VERSION = "ECMA_2"; - startTest(); - var testcases = getTestCases(); +var SECTION = "15.2.3"; +var VERSION = "ECMA_2"; +startTest(); - writeHeaderToLog( SECTION + " Properties of the Object Constructor"); - test(); +writeHeaderToLog( SECTION + " Properties of the Object Constructor"); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); +new TestCase( SECTION, "Object.length", 1, Object.length ); - array[item++] = new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); - array[item++] = new TestCase( SECTION, "Object.length", 1, Object.length ); - - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-1.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-1.js index 6c2b07555c6..af41647760f 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-1.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.3.1-1.js - ECMA Section: 15.2.3.1 Object.prototype + File Name: 15.2.3.1-1.js + ECMA Section: 15.2.3.1 Object.prototype - Description: The initial value of Object.prototype is the built-in - Object prototype object. + Description: The initial value of Object.prototype is the built-in + Object prototype object. - This property shall have the attributes [ DontEnum, - DontDelete ReadOnly ] + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] - This tests the [DontEnum] property of Object.prototype + This tests the [DontEnum] property of Object.prototype - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.3.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object.prototype"; +var SECTION = "15.2.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "var str = '';for ( p in Object ) { str += p; }; str", + "", + eval( "var str = ''; for ( p in Object ) { str += p; }; str" ) ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "var str = '';for ( p in Object ) { str += p; }; str", - "", - eval( "var str = ''; for ( p in Object ) { str += p; }; str" ) - ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-2.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-2.js index 21964f3b89b..2465fa61ad6 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-2.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.3.1-2.js - ECMA Section: 15.2.3.1 Object.prototype + File Name: 15.2.3.1-2.js + ECMA Section: 15.2.3.1 Object.prototype - Description: The initial value of Object.prototype is the built-in - Object prototype object. + Description: The initial value of Object.prototype is the built-in + Object prototype object. - This property shall have the attributes [ DontEnum, - DontDelete ReadOnly ] + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] - This tests the [DontDelete] property of Object.prototype + This tests the [DontDelete] property of Object.prototype - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.3.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object.prototype"; +var SECTION = "15.2.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "delete( Object.prototype )", + false, + eval("delete( Object.prototype )") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete( Object.prototype )", - false, - "delete( Object.prototype )" - ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-3.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-3.js index 3c12de8c2a6..8b49d69bb5d 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-3.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,51 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.3.1-3.js - ECMA Section: 15.2.3.1 Object.prototype + File Name: 15.2.3.1-3.js + ECMA Section: 15.2.3.1 Object.prototype - Description: The initial value of Object.prototype is the built-in - Object prototype object. + Description: The initial value of Object.prototype is the built-in + Object prototype object. - This property shall have the attributes [ DontEnum, - DontDelete ReadOnly ] + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] - This tests the [ReadOnly] property of Object.prototype + This tests the [ReadOnly] property of Object.prototype - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.3.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object.prototype"; +var SECTION = "15.2.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Object.prototype = null; Object.prototype", + Object.prototype, + eval("Object.prototype = null; Object.prototype")); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Object.prototype = null; Object.prototype", - Object.prototype, - "Object.prototype = null; Object.prototype" - ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-4.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-4.js index 3b687654898..d22eeaace40 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-4.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.1-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.3.1-4.js - ECMA Section: 15.2.3.1 Object.prototype + File Name: 15.2.3.1-4.js + ECMA Section: 15.2.3.1 Object.prototype - Description: The initial value of Object.prototype is the built-in - Object prototype object. + Description: The initial value of Object.prototype is the built-in + Object prototype object. - This property shall have the attributes [ DontEnum, - DontDelete ReadOnly ] + This property shall have the attributes [ DontEnum, + DontDelete ReadOnly ] - This tests the [DontDelete] property of Object.prototype + This tests the [DontDelete] property of Object.prototype - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.3.1-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object.prototype"; +var SECTION = "15.2.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "delete( Object.prototype ); Object.prototype", + Object.prototype, + eval("delete(Object.prototype); Object.prototype") ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "delete( Object.prototype ); Object.prototype", - Object.prototype, - "delete(Object.prototype); Object.prototype" - ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval(testcases[tc].actual); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.js index 77f864fe439..3afafded5aa 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.3.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,31 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.3.js - ECMA Section: 15.2.3 Properties of the Object Constructor + File Name: 15.2.3.js + ECMA Section: 15.2.3 Properties of the Object Constructor - Description: The value of the internal [[Prototype]] property of the - Object constructor is the Function prototype object. + Description: The value of the internal [[Prototype]] property of the + Object constructor is the Function prototype object. - Besides the call and construct propreties and the length - property, the Object constructor has properties described - in 15.2.3.1. + Besides the call and construct propreties and the length + property, the Object constructor has properties described + in 15.2.3.1. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the Object Constructor"; +var SECTION = "15.2.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the Object Constructor"; - writeHeaderToLog( SECTION + " " + TITLE); +writeHeaderToLog( SECTION + " " + TITLE); - var testcases = getTestCases(); - test(); +// new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); +new TestCase( SECTION, "Object.length", 1, Object.length ); -function getTestCases() { - var array = new Array(); - var item = 0; - -// array[item++] = new TestCase( SECTION, "Object.__proto__", Function.prototype, Object.__proto__ ); - array[item++] = new TestCase( SECTION, "Object.length", 1, Object.length ); - - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.4.1.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.4.1.js index 6cf7ad3e852..ad960e4bb3a 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.4.1.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.4.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.4.1.js - ECMA Section: 15.2.4 Object.prototype.constructor + File Name: 15.2.4.1.js + ECMA Section: 15.2.4 Object.prototype.constructor - Description: The initial value of the Object.prototype.constructor - is the built-in Object constructor. + Description: The initial value of the Object.prototype.constructor + is the built-in Object constructor. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.4.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object.prototype.constructor"; +var SECTION = "15.2.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.constructor"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "Object.prototype.constructor", + Object, + Object.prototype.constructor ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "Object.prototype.constructor", - Object, - Object.prototype.constructor - ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.4.2.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.4.2.js index a5b0a854d7f..60c8ef20828 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.4.2.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.4.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,110 +35,90 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.4.2.js - ECMA Section: 15.2.4.2 Object.prototype.toString() + File Name: 15.2.4.2.js + ECMA Section: 15.2.4.2 Object.prototype.toString() - Description: When the toString method is called, the following - steps are taken: - 1. Get the [[Class]] property of this object - 2. Call ToString( Result(1) ) - 3. Compute a string value by concatenating the three - strings "[object " + Result(2) + "]" - 4. Return Result(3). + Description: When the toString method is called, the following + steps are taken: + 1. Get the [[Class]] property of this object + 2. Call ToString( Result(1) ) + 3. Compute a string value by concatenating the three + strings "[object " + Result(2) + "]" + 4. Return Result(3). - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.4.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object.prototype.toString()"; +var SECTION = "15.2.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.toString()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()", + GLOBAL, + eval("myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "(new Object()).toString()", "[object Object]", (new Object()).toString() ); +new TestCase( SECTION, "myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()", - GLOBAL, - eval("myvar = this; myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()", + '[object Object]', + eval("myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()", - "[object Function]", - eval("myvar = MyObject; myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Number]", + eval("myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()", - '[object Object]', - eval("myvar = new MyObject( true ); myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object String]", + eval("myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()", - "[object Number]", - eval("myvar = new Number(0); myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Math]", + eval("myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()", - "[object String]", - eval("myvar = new String(''); myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Function]", + eval("myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()", - "[object Math]", - eval("myvar = Math; myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Array]", + eval("myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()", - "[object Function]", - eval("myvar = new Function(); myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Boolean]", + eval("myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()", - "[object Array]", - eval("myvar = new Array(); myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()", + "[object Date]", + eval("myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()", - "[object Boolean]", - eval("myvar = new Boolean(); myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "var MYVAR = new Object( this ); MYVAR.toString()", + GLOBAL, + eval("var MYVAR = new Object( this ); MYVAR.toString()") ); - array[item++] = new TestCase( SECTION, "myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()", - "[object Date]", - eval("myvar = new Date(); myvar.toString = Object.prototype.toString; myvar.toString()") ); +new TestCase( SECTION, "var MYVAR = new Object(); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(); MYVAR.toString()") ); - array[item++] = new TestCase( SECTION, "var MYVAR = new Object( this ); MYVAR.toString()", - GLOBAL, - eval("var MYVAR = new Object( this ); MYVAR.toString()") ); +new TestCase( SECTION, "var MYVAR = new Object(void 0); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(void 0); MYVAR.toString()") ); - array[item++] = new TestCase( SECTION, "var MYVAR = new Object(); MYVAR.toString()", - "[object Object]", - eval("var MYVAR = new Object(); MYVAR.toString()") ); +new TestCase( SECTION, "var MYVAR = new Object(null); MYVAR.toString()", + "[object Object]", + eval("var MYVAR = new Object(null); MYVAR.toString()") ); - array[item++] = new TestCase( SECTION, "var MYVAR = new Object(void 0); MYVAR.toString()", - "[object Object]", - eval("var MYVAR = new Object(void 0); MYVAR.toString()") ); - - array[item++] = new TestCase( SECTION, "var MYVAR = new Object(null); MYVAR.toString()", - "[object Object]", - eval("var MYVAR = new Object(null); MYVAR.toString()") ); - - return ( array ); -} -function test( array ) { - for ( tc=0 ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject( value ) { - this.value = new Function( "return this.value" ); - this.toString = new Function ( "return this.value+''"); -} \ No newline at end of file + this.value = new Function( "return this.value" ); + this.toString = new Function ( "return this.value+''"); +} diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.4.3.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.4.3.js index ff154711580..d2df3e7ff3f 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.4.3.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.4.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,97 +35,81 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.4.3.js - ECMA Section: 15.2.4.3 Object.prototype.valueOf() + File Name: 15.2.4.3.js + ECMA Section: 15.2.4.3 Object.prototype.valueOf() - Description: As a rule, the valueOf method for an object simply - returns the object; but if the object is a "wrapper" - for a host object, as may perhaps be created by the - Object constructor, then the contained host object - should be returned. + Description: As a rule, the valueOf method for an object simply + returns the object; but if the object is a "wrapper" + for a host object, as may perhaps be created by the + Object constructor, then the contained host object + should be returned. - This only covers native objects. + This only covers native objects. - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.4.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Object.prototype.valueOf()"; +var SECTION = "15.2.4.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Object.prototype.valueOf()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +var myarray = new Array(); +myarray.valueOf = Object.prototype.valueOf; +var myboolean = new Boolean(); +myboolean.valueOf = Object.prototype.valueOf; +var myfunction = new Function(); +myfunction.valueOf = Object.prototype.valueOf; +var myobject = new Object(); +myobject.valueOf = Object.prototype.valueOf; +var mymath = Math; +mymath.valueOf = Object.prototype.valueOf; +var mydate = new Date(); +mydate.valueOf = Object.prototype.valueOf; +var mynumber = new Number(); +mynumber.valueOf = Object.prototype.valueOf; +var mystring = new String(); +mystring.valueOf = Object.prototype.valueOf; - var myarray = new Array(); - myarray.valueOf = Object.prototype.valueOf; - var myboolean = new Boolean(); - myboolean.valueOf = Object.prototype.valueOf; - var myfunction = new Function(); - myfunction.valueOf = Object.prototype.valueOf; - var myobject = new Object(); - myobject.valueOf = Object.prototype.valueOf; - var mymath = Math; - mymath.valueOf = Object.prototype.valueOf; - var mydate = new Date(); - mydate.valueOf = Object.prototype.valueOf; - var mynumber = new Number(); - mynumber.valueOf = Object.prototype.valueOf; - var mystring = new String(); - mystring.valueOf = Object.prototype.valueOf; +new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length ); - array[item++] = new TestCase( SECTION, "Object.prototype.valueOf.length", 0, Object.prototype.valueOf.length ); +new TestCase( SECTION, + "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()", + myarray, + myarray.valueOf() ); +new TestCase( SECTION, + "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()", + myboolean, + myboolean.valueOf() ); +new TestCase( SECTION, + "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()", + myfunction, + myfunction.valueOf() ); +new TestCase( SECTION, + "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()", + myobject, + myobject.valueOf() ); +new TestCase( SECTION, + "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()", + mymath, + mymath.valueOf() ); +new TestCase( SECTION, + "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()", + mynumber, + mynumber.valueOf() ); +new TestCase( SECTION, + "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()", + mystring, + mystring.valueOf() ); +new TestCase( SECTION, + "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()", + mydate, + mydate.valueOf() ); - array[item++] = new TestCase( SECTION, - "myarray = new Array(); myarray.valueOf = Object.prototype.valueOf; myarray.valueOf()", - myarray, - myarray.valueOf() ); - array[item++] = new TestCase( SECTION, - "myboolean = new Boolean(); myboolean.valueOf = Object.prototype.valueOf; myboolean.valueOf()", - myboolean, - myboolean.valueOf() ); - array[item++] = new TestCase( SECTION, - "myfunction = new Function(); myfunction.valueOf = Object.prototype.valueOf; myfunction.valueOf()", - myfunction, - myfunction.valueOf() ); - array[item++] = new TestCase( SECTION, - "myobject = new Object(); myobject.valueOf = Object.prototype.valueOf; myobject.valueOf()", - myobject, - myobject.valueOf() ); - array[item++] = new TestCase( SECTION, - "mymath = Math; mymath.valueOf = Object.prototype.valueOf; mymath.valueOf()", - mymath, - mymath.valueOf() ); - array[item++] = new TestCase( SECTION, - "mynumber = new Number(); mynumber.valueOf = Object.prototype.valueOf; mynumber.valueOf()", - mynumber, - mynumber.valueOf() ); - array[item++] = new TestCase( SECTION, - "mystring = new String(); mystring.valueOf = Object.prototype.valueOf; mystring.valueOf()", - mystring, - mystring.valueOf() ); - array[item++] = new TestCase( SECTION, - "mydate = new Date(); mydate.valueOf = Object.prototype.valueOf; mydate.valueOf()", - mydate, - mydate.valueOf() ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/ObjectObjects/15.2.4.js b/mozilla/js/tests/ecma/ObjectObjects/15.2.4.js index cc099c21190..2487c6582d3 100644 --- a/mozilla/js/tests/ecma/ObjectObjects/15.2.4.js +++ b/mozilla/js/tests/ecma/ObjectObjects/15.2.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,42 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.2.4.js - ECMA Section: 15.2.4 Properties of the Object prototype object + File Name: 15.2.4.js + ECMA Section: 15.2.4 Properties of the Object prototype object - Description: The value of the internal [[Prototype]] property of - the Object prototype object is null + Description: The value of the internal [[Prototype]] property of + the Object prototype object is null - Author: christine@netscape.com - Date: 28 october 1997 + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.2.4"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "Properties of the Object.prototype object"; +var SECTION = "15.2.4"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Properties of the Object.prototype object"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - testcases[tc++] = new TestCase( SECTION, "Object.prototype.__proto__", - null, - Object.prototype.__proto__ - ); +new TestCase( SECTION, + "Object.prototype.__proto__", + null, + Object.prototype.__proto__ ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/ObjectObjects/browser.js b/mozilla/js/tests/ecma/ObjectObjects/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/ObjectObjects/shell.js b/mozilla/js/tests/ecma/ObjectObjects/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/README b/mozilla/js/tests/ecma/README new file mode 100755 index 00000000000..91f174ab610 --- /dev/null +++ b/mozilla/js/tests/ecma/README @@ -0,0 +1 @@ +ECMA 262 Edition 1 diff --git a/mozilla/js/tests/ecma/SourceText/6-1.js b/mozilla/js/tests/ecma/SourceText/6-1.js index 543b9da7531..bca7d308c46 100644 --- a/mozilla/js/tests/ecma/SourceText/6-1.js +++ b/mozilla/js/tests/ecma/SourceText/6-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,106 +35,92 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 6-1.js - ECMA Section: Source Text - Description: + File Name: 6-1.js + ECMA Section: Source Text + Description: - ECMAScript source text is represented as a sequence of characters - representable using the Unicode version 2.0 character encoding. + ECMAScript source text is represented as a sequence of characters + representable using the Unicode version 2.0 character encoding. - SourceCharacter :: - any Unicode character + SourceCharacter :: + any Unicode character - However, it is possible to represent every ECMAScript program using - only ASCII characters (which are equivalent to the first 128 Unicode - characters). Non-ASCII Unicode characters may appear only within comments - and string literals. In string literals, any Unicode character may also be - expressed as a Unicode escape sequence consisting of six ASCII characters, - namely \u plus four hexadecimal digits. Within a comment, such an escape - sequence is effectively ignored as part of the comment. Within a string - literal, the Unicode escape sequence contributes one character to the string - value of the literal. + However, it is possible to represent every ECMAScript program using + only ASCII characters (which are equivalent to the first 128 Unicode + characters). Non-ASCII Unicode characters may appear only within comments + and string literals. In string literals, any Unicode character may also be + expressed as a Unicode escape sequence consisting of six ASCII characters, + namely \u plus four hexadecimal digits. Within a comment, such an escape + sequence is effectively ignored as part of the comment. Within a string + literal, the Unicode escape sequence contributes one character to the string + value of the literal. - Note that ECMAScript differs from the Java programming language in the - behavior of Unicode escape sequences. In a Java program, if the Unicode escape - sequence \u000A, for example, occurs within a single-line comment, it is - interpreted as a line terminator (Unicode character 000A is line feed) and - therefore the next character is not part of the comment. Similarly, if the - Unicode escape sequence \u000A occurs within a string literal in a Java - program, it is likewise interpreted as a line terminator, which is not - allowed within a string literal-one must write \n instead of \u000A to - cause a line feed to be part of the string value of a string literal. In - an ECMAScript program, a Unicode escape sequence occurring within a comment - is never interpreted and therefore cannot contribute to termination of the - comment. Similarly, a Unicode escape sequence occurring within a string literal - in an ECMAScript program always contributes a character to the string value of - the literal and is never interpreted as a line terminator or as a quote mark - that might terminate the string literal. + Note that ECMAScript differs from the Java programming language in the + behavior of Unicode escape sequences. In a Java program, if the Unicode escape + sequence \u000A, for example, occurs within a single-line comment, it is + interpreted as a line terminator (Unicode character 000A is line feed) and + therefore the next character is not part of the comment. Similarly, if the + Unicode escape sequence \u000A occurs within a string literal in a Java + program, it is likewise interpreted as a line terminator, which is not + allowed within a string literal-one must write \n instead of \u000A to + cause a line feed to be part of the string value of a string literal. In + an ECMAScript program, a Unicode escape sequence occurring within a comment + is never interpreted and therefore cannot contribute to termination of the + comment. Similarly, a Unicode escape sequence occurring within a string literal + in an ECMAScript program always contributes a character to the string value of + the literal and is never interpreted as a line terminator or as a quote mark + that might terminate the string literal. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "6-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Source Text"; +var SECTION = "6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Source Text"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var testcase = new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \u000A", + 'PASSED', + "PASSED" ); - testcases[tc] = new TestCase( SECTION, - "// the following character should not be interpreted as a line terminator in a comment: \u000A", - 'PASSED', - "PASSED" ); +// \u000A testcase.actual = "FAILED!"; - // \u000A testcases[tc].actual = "FAILED!"; +testcase = +new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'", + 'PASSED', + 'PASSED' ); - tc++; +// the following character should noy be interpreted as a line terminator: \\n testcase.actual = "FAILED" - testcases[tc] = new TestCase( SECTION, - "// the following character should not be interpreted as a line terminator in a comment: \\n 'FAILED'", - 'PASSED', - 'PASSED' ); +testcase = +new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'", + 'PASSED', + 'PASSED' ); - // the following character should noy be interpreted as a line terminator: \\n testcases[tc].actual = "FAILED" +// the following character should not be interpreted as a line terminator: \u000A testcase.actual = "FAILED" - tc++; +testcase = +new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'", + 'PASSED', + 'PASSED' ); +// the following character should not be interpreted as a line terminator: \n testcase.actual = 'FAILED' - testcases[tc] = new TestCase( SECTION, - "// the following character should not be interpreted as a line terminator in a comment: \\u000A 'FAILED'", - 'PASSED', - 'PASSED' ) +testcase = +new TestCase( SECTION, + "// the following character should not be interpreted as a line terminator in a comment: u000D", + 'PASSED', + 'PASSED' ); - // the following character should not be interpreted as a line terminator: \u000A testcases[tc].actual = "FAILED" +// the following character should not be interpreted as a line terminator: \u000D testcase.actual = "FAILED" - testcases[tc++] = new TestCase( SECTION, - "// the following character should not be interpreted as a line terminator in a comment: \n 'PASSED'", - 'PASSED', - 'PASSED' ) - // the following character should not be interpreted as a line terminator: \n testcases[tc].actual = 'FAILED' +test(); - testcases[tc] = new TestCase( SECTION, - "// the following character should not be interpreted as a line terminator in a comment: u000D", - 'PASSED', - 'PASSED' ) - - // the following character should not be interpreted as a line terminator: \u000D testcases[tc].actual = "FAILED" - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/SourceText/6-2.js b/mozilla/js/tests/ecma/SourceText/6-2.js index f5d5d229ddc..fa517ab0ec7 100644 --- a/mozilla/js/tests/ecma/SourceText/6-2.js +++ b/mozilla/js/tests/ecma/SourceText/6-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,111 +35,95 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 6-1.js - ECMA Section: Source Text - Description: + File Name: 6-1.js + ECMA Section: Source Text + Description: - ECMAScript source text is represented as a sequence of characters - representable using the Unicode version 2.0 character encoding. + ECMAScript source text is represented as a sequence of characters + representable using the Unicode version 2.0 character encoding. - SourceCharacter :: - any Unicode character + SourceCharacter :: + any Unicode character - However, it is possible to represent every ECMAScript program using - only ASCII characters (which are equivalent to the first 128 Unicode - characters). Non-ASCII Unicode characters may appear only within comments - and string literals. In string literals, any Unicode character may also be - expressed as a Unicode escape sequence consisting of six ASCII characters, - namely \u plus four hexadecimal digits. Within a comment, such an escape - sequence is effectively ignored as part of the comment. Within a string - literal, the Unicode escape sequence contributes one character to the string - value of the literal. + However, it is possible to represent every ECMAScript program using + only ASCII characters (which are equivalent to the first 128 Unicode + characters). Non-ASCII Unicode characters may appear only within comments + and string literals. In string literals, any Unicode character may also be + expressed as a Unicode escape sequence consisting of six ASCII characters, + namely \u plus four hexadecimal digits. Within a comment, such an escape + sequence is effectively ignored as part of the comment. Within a string + literal, the Unicode escape sequence contributes one character to the string + value of the literal. - Note that ECMAScript differs from the Java programming language in the - behavior of Unicode escape sequences. In a Java program, if the Unicode escape - sequence \u000A, for example, occurs within a single-line comment, it is - interpreted as a line terminator (Unicode character 000A is line feed) and - therefore the next character is not part of the comment. Similarly, if the - Unicode escape sequence \u000A occurs within a string literal in a Java - program, it is likewise interpreted as a line terminator, which is not - allowed within a string literal-one must write \n instead of \u000A to - cause a line feed to be part of the string value of a string literal. In - an ECMAScript program, a Unicode escape sequence occurring within a comment - is never interpreted and therefore cannot contribute to termination of the - comment. Similarly, a Unicode escape sequence occurring within a string literal - in an ECMAScript program always contributes a character to the string value of - the literal and is never interpreted as a line terminator or as a quote mark - that might terminate the string literal. + Note that ECMAScript differs from the Java programming language in the + behavior of Unicode escape sequences. In a Java program, if the Unicode escape + sequence \u000A, for example, occurs within a single-line comment, it is + interpreted as a line terminator (Unicode character 000A is line feed) and + therefore the next character is not part of the comment. Similarly, if the + Unicode escape sequence \u000A occurs within a string literal in a Java + program, it is likewise interpreted as a line terminator, which is not + allowed within a string literal-one must write \n instead of \u000A to + cause a line feed to be part of the string value of a string literal. In + an ECMAScript program, a Unicode escape sequence occurring within a comment + is never interpreted and therefore cannot contribute to termination of the + comment. Similarly, a Unicode escape sequence occurring within a string literal + in an ECMAScript program always contributes a character to the string value of + the literal and is never interpreted as a line terminator or as a quote mark + that might terminate the string literal. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "6-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Source Text"; +var SECTION = "6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Source Text"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// encoded quotes should not end a quote - // encoded quotes should not end a quote +new TestCase( SECTION, + "var s = 'PAS\\u0022SED'; s", + "PAS\"SED", + eval("var s = 'PAS\\u0022SED'; s") ); - testcases[tc++]= new TestCase( SECTION, - "var s = 'PAS\\u0022SED'; s", - "PAS\"SED", - eval("var s = 'PAS\\u0022SED'; s") ); - - testcases[tc++]= new TestCase( SECTION, - 'var s = "PAS\\u0022SED"; s', - "PAS\"SED", - eval('var s = "PAS\\u0022SED"; s') ); +new TestCase( SECTION, + 'var s = "PAS\\u0022SED"; s', + "PAS\"SED", + eval('var s = "PAS\\u0022SED"; s') ); - testcases[tc++]= new TestCase( SECTION, - "var s = 'PAS\\u0027SED'; s", - "PAS\'SED", - eval("var s = 'PAS\\u0027SED'; s") ); +new TestCase( SECTION, + "var s = 'PAS\\u0027SED'; s", + "PAS\'SED", + eval("var s = 'PAS\\u0027SED'; s") ); - testcases[tc++]= new TestCase( SECTION, - 'var s = "PAS\\u0027SED"; s', - "PAS\'SED", - eval('var s = "PAS\\u0027SED"; s') ); +new TestCase( SECTION, + 'var s = "PAS\\u0027SED"; s', + "PAS\'SED", + eval('var s = "PAS\\u0027SED"; s') ); - testcases[tc] = new TestCase( SECTION, - 'var s="PAS\\u0027SED"; s', - "PAS\'SED", - "" ) - var s = "PAS\u0027SED"; +var testcase = new TestCase( SECTION, + 'var s="PAS\\u0027SED"; s', + "PAS\'SED", + "" ); +var s = "PAS\u0027SED"; - testcases[tc].actual = s; +testcase.actual = s; - tc++; +testcase = new TestCase( SECTION, + 'var s = "PAS\\u0022SED"; s', + "PAS\"SED", + "" ); +var s = "PAS\u0022SED"; - testcases[tc]= new TestCase( SECTION, - 'var s = "PAS\\u0027SED"; s', - "PAS\"SED", - "" ); - var s = "PAS\u0022SED"; - - testcases[tc].actual = s; +testcase.actual = s; - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/SourceText/browser.js b/mozilla/js/tests/ecma/SourceText/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/SourceText/shell.js b/mozilla/js/tests/ecma/SourceText/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Statements/12.10-1.js b/mozilla/js/tests/ecma/Statements/12.10-1.js index a5e6166da2b..3938ecdd22e 100644 --- a/mozilla/js/tests/ecma/Statements/12.10-1.js +++ b/mozilla/js/tests/ecma/Statements/12.10-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,133 +35,115 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.10-1.js - ECMA Section: 12.10 The with statement - Description: - WithStatement : - with ( Expression ) Statement + File Name: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: + WithStatement : + with ( Expression ) Statement - The with statement adds a computed object to the front of the scope chain - of the current execution context, then executes a statement with this - augmented scope chain, then restores the scope chain. + The with statement adds a computed object to the front of the scope chain + of the current execution context, then executes a statement with this + augmented scope chain, then restores the scope chain. - Semantics + Semantics - The production WithStatement : with ( Expression ) Statement is evaluated - as follows: - 1. Evaluate Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Add Result(3) to the front of the scope chain. - 5. Evaluate Statement using the augmented scope chain from step 4. - 6. Remove Result(3) from the front of the scope chain. - 7. Return Result(5). + The production WithStatement : with ( Expression ) Statement is evaluated + as follows: + 1. Evaluate Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Add Result(3) to the front of the scope chain. + 5. Evaluate Statement using the augmented scope chain from step 4. + 6. Remove Result(3) from the front of the scope chain. + 7. Return Result(5). - Discussion - Note that no matter how control leaves the embedded Statement, whether - normally or by some form of abrupt completion, the scope chain is always - restored to its former state. + Discussion + Note that no matter how control leaves the embedded Statement, whether + normally or by some form of abrupt completion, the scope chain is always + restored to its former state. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.10-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The with statment"; +var SECTION = "12.10-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The with statement"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - // although the scope chain changes, the this value is immutable for a given - // execution context. - - array[item++] = new TestCase( SECTION, - "with( new Number() ) { this +'' }", - "[object global]", - eval("with( new Number() ) { this +'' }") ); - - // the object's functions and properties should override those of the - // global object. - - array[item++] = new TestCase( - SECTION, - "var MYOB = new WithObject(true); with (MYOB) { parseInt() }", - true, - eval("var MYOB = new WithObject(true); with (MYOB) { parseInt() }") ); - - array[item++] = new TestCase( - SECTION, - "var MYOB = new WithObject(false); with (MYOB) { NaN }", - false, - eval("var MYOB = new WithObject(false); with (MYOB) { NaN }") ); - - array[item++] = new TestCase( - SECTION, - "var MYOB = new WithObject(NaN); with (MYOB) { Infinity }", - Number.NaN, - eval("var MYOB = new WithObject(NaN); with (MYOB) { Infinity }") ); - - array[item++] = new TestCase( - SECTION, - "var MYOB = new WithObject(false); with (MYOB) { }; Infinity", - Number.POSITIVE_INFINITY, - eval("var MYOB = new WithObject(false); with (MYOB) { }; Infinity") ); +writeHeaderToLog( SECTION + " "+ TITLE); - array[item++] = new TestCase( - SECTION, - "var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }", - Number.POSITIVE_INFINITY, - eval("var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }") ); +// although the scope chain changes, the this value is immutable for a given +// execution context. - // let us leave the with block via a break. +new TestCase( SECTION, + "with( new Number() ) { this +'' }", + GLOBAL, + eval("with( new Number() ) { this +'' }") ); - array[item++] = new TestCase( - SECTION, - "var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity", - Number.POSITIVE_INFINITY, - eval("var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity") ); +// the object's functions and properties should override those of the +// global object. + +new TestCase( + SECTION, + "var MYOB = new WithObject(true); with (MYOB) { parseInt() }", + true, + eval("var MYOB = new WithObject(true); with (MYOB) { parseInt() }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { NaN }", + false, + eval("var MYOB = new WithObject(false); with (MYOB) { NaN }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(NaN); with (MYOB) { Infinity }", + Number.NaN, + eval("var MYOB = new WithObject(NaN); with (MYOB) { Infinity }") ); + +new TestCase( + SECTION, + "var MYOB = new WithObject(false); with (MYOB) { }; Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(false); with (MYOB) { }; Infinity") ); + + +new TestCase( + SECTION, + "var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); with (MYOB) { delete Infinity; Infinity }") ); + +// let us leave the with block via a break. + +new TestCase( + SECTION, + "var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity", + Number.POSITIVE_INFINITY, + eval("var MYOB = new WithObject(0); while (true) { with (MYOB) { Infinity; break; } } Infinity") ); + + +test(); - return ( array ); -} function WithObject( value ) { - this.prop1 = 1; - this.prop2 = new Boolean(true); - this.prop3 = "a string"; - this.value = value; + this.prop1 = 1; + this.prop2 = new Boolean(true); + this.prop3 = "a string"; + this.value = value; - // now we will override global functions + // now we will override global functions - this.parseInt = new Function( "return this.value" ); - this.NaN = value; - this.Infinity = value; - this.unescape = new Function( "return this.value" ); - this.escape = new Function( "return this.value" ); - this.eval = new Function( "return this.value" ); - this.parseFloat = new Function( "return this.value" ); - this.isNaN = new Function( "return this.value" ); - this.isFinite = new Function( "return this.value" ); + this.parseInt = new Function( "return this.value" ); + this.NaN = value; + this.Infinity = value; + this.unescape = new Function( "return this.value" ); + this.escape = new Function( "return this.value" ); + this.eval = new Function( "return this.value" ); + this.parseFloat = new Function( "return this.value" ); + this.isNaN = new Function( "return this.value" ); + this.isFinite = new Function( "return this.value" ); } diff --git a/mozilla/js/tests/ecma/Statements/12.10.js b/mozilla/js/tests/ecma/Statements/12.10.js index a53b97d1087..5d4d659296d 100644 --- a/mozilla/js/tests/ecma/Statements/12.10.js +++ b/mozilla/js/tests/ecma/Statements/12.10.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,25 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.10-1.js - ECMA Section: 12.10 The with statement - Description: + File Name: 12.10-1.js + ECMA Section: 12.10 The with statement + Description: - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.10-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The with statement"; +var SECTION = "12.10-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The with statement"; - var testcases = getTestCases(); +writeHeaderToLog( SECTION +" "+ TITLE); - writeHeaderToLog( SECTION +" "+ TITLE); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var x; with (7) x = valueOf(); typeof x;", - "number", - eval("var x; with(7) x = valueOf(); typeof x;") ); - return ( array ); -} +new TestCase( SECTION, + "var x; with (7) x = valueOf(); typeof x;", + "number", + eval("var x; with(7) x = valueOf(); typeof x;") ); +test(); diff --git a/mozilla/js/tests/ecma/Statements/12.2-1.js b/mozilla/js/tests/ecma/Statements/12.2-1.js index 5beca24d8ee..69e5a93f12f 100644 --- a/mozilla/js/tests/ecma/Statements/12.2-1.js +++ b/mozilla/js/tests/ecma/Statements/12.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.2-1.js - ECMA Section: The variable statement - Description: + File Name: 12.2-1.js + ECMA Section: The variable statement + Description: - If the variable statement occurs inside a FunctionDeclaration, the - variables are defined with function-local scope in that function, as - described in section 10.1.3. Otherwise, they are defined with global - scope, that is, they are created as members of the global object, as - described in section 0. Variables are created when the execution scope - is entered. A Block does not define a new execution scope. Only Program and - FunctionDeclaration produce a new scope. Variables are initialized to the - undefined value when created. A variable with an Initializer is assigned - the value of its AssignmentExpression when the VariableStatement is executed, - not when the variable is created. + If the variable statement occurs inside a FunctionDeclaration, the + variables are defined with function-local scope in that function, as + described in section 10.1.3. Otherwise, they are defined with global + scope, that is, they are created as members of the global object, as + described in section 0. Variables are created when the execution scope + is entered. A Block does not define a new execution scope. Only Program and + FunctionDeclaration produce a new scope. Variables are initialized to the + undefined value when created. A variable with an Initializer is assigned + the value of its AssignmentExpression when the VariableStatement is executed, + not when the variable is created. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The variable statement"; +var SECTION = "12.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The variable statement"; - writeHeaderToLog( SECTION +" "+ TITLE); +writeHeaderToLog( SECTION +" "+ TITLE); - var testcases = new Array(); +new TestCase( "SECTION", + "var x = 3; function f() { var a = x; var x = 23; return a; }; f()", + void 0, + eval("var x = 3; function f() { var a = x; var x = 23; return a; }; f()") ); - testcases[tc] = new TestCase( "SECTION", - "var x = 3; function f() { var a = x; var x = 23; return a; }; f()", - void 0, - eval("var x = 3; function f() { var a = x; var x = 23; return a; }; f()") ); +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Statements/12.5-1.js b/mozilla/js/tests/ecma/Statements/12.5-1.js index 5da2b3f6e1d..3d8d601ff60 100644 --- a/mozilla/js/tests/ecma/Statements/12.5-1.js +++ b/mozilla/js/tests/ecma/Statements/12.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,66 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.5-1.js - ECMA Section: The if statement - Description: + File Name: 12.5-1.js + ECMA Section: The if statement + Description: - The production IfStatement : if ( Expression ) Statement else Statement - is evaluated as follows: + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: - 1.Evaluate Expression. - 2.Call GetValue(Result(1)). - 3.Call ToBoolean(Result(2)). - 4.If Result(3) is false, go to step 7. - 5.Evaluate the first Statement. - 6.Return Result(5). - 7.Evaluate the second Statement. - 8.Return Result(7). + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.5-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The if statment"; +var SECTION = "12.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The if statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';", - "PASSED", - eval("var MYVAR; if ( true ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); +new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';", - "PASSED", - eval("var MYVAR; if ( false ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", - "PASSED", - eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';", - "PASSED", - eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); +new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';", - "PASSED", - eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; else MYVAR= 'FAILED';") ); +new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';", + "PASSED", + eval("var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';", - "PASSED", - eval("var MYVAR; if ( 0 ) MYVAR='FAILED'; else MYVAR= 'PASSED';") ); +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Statements/12.5-2.js b/mozilla/js/tests/ecma/Statements/12.5-2.js index 22bfc8ab483..02acbf1da5a 100644 --- a/mozilla/js/tests/ecma/Statements/12.5-2.js +++ b/mozilla/js/tests/ecma/Statements/12.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,63 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.5-2.js - ECMA Section: The if statement - Description: + File Name: 12.5-2.js + ECMA Section: The if statement + Description: - The production IfStatement : if ( Expression ) Statement else Statement - is evaluated as follows: + The production IfStatement : if ( Expression ) Statement else Statement + is evaluated as follows: - 1.Evaluate Expression. - 2.Call GetValue(Result(1)). - 3.Call ToBoolean(Result(2)). - 4.If Result(3) is false, go to step 7. - 5.Evaluate the first Statement. - 6.Return Result(5). - 7.Evaluate the second Statement. - 8.Return Result(7). + 1.Evaluate Expression. + 2.Call GetValue(Result(1)). + 3.Call ToBoolean(Result(2)). + 4.If Result(3) is false, go to step 7. + 5.Evaluate the first Statement. + 6.Return Result(5). + 7.Evaluate the second Statement. + 8.Return Result(7). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.5-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The if statement" ; +var SECTION = "12.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The if statement" ; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR", - "PASSED", - eval("var MYVAR; if ( true ) MYVAR='PASSED'; MYVAR") ); +new TestCase( SECTION, + "var MYVAR; if ( false ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( false ) MYVAR='FAILED'; MYVAR;") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( false ) MYVAR='FAILED'; MYVAR;", - "PASSED", - eval("var MYVAR=\"PASSED\"; if ( false ) MYVAR='FAILED'; MYVAR;") ); +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR", - "PASSED", - eval("var MYVAR; if ( new Boolean(true) ) MYVAR='PASSED'; MYVAR") ); +new TestCase( SECTION, + "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR", - "PASSED", - eval("var MYVAR; if ( new Boolean(false) ) MYVAR='PASSED'; MYVAR") ); +new TestCase( SECTION, + "var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR", + "PASSED", + eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR", - "PASSED", - eval("var MYVAR; if ( 1 ) MYVAR='PASSED'; MYVAR") ); +new TestCase( SECTION, + "var MYVAR; if ( 0 ) MYVAR='FAILED'; MYVAR;", + "PASSED", + eval("var MYVAR=\"PASSED\"; if ( 0 ) MYVAR='FAILED'; MYVAR;") ); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR; if ( 0 ) MYVAR='FAILED'; MYVAR;", - "PASSED", - eval("var MYVAR=\"PASSED\"; if ( 0 ) MYVAR='FAILED'; MYVAR;") ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Statements/12.6.1-1.js b/mozilla/js/tests/ecma/Statements/12.6.1-1.js index 5a2ba4d3520..1746b688acb 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.1-1.js +++ b/mozilla/js/tests/ecma/Statements/12.6.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.1-1.js - ECMA Section: The while statement - Description: + File Name: 12.6.1-1.js + ECMA Section: The while statement + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.6.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The While statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +var SECTION = "12.6.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The While statement"; +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ", - 1, - eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ")); +new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ", + 1, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) break; } MYVAR ")); - testcases[tc++] = new TestCase( SECTION, - "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ", - 100, - eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ")); +new TestCase( SECTION, + "var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ", + 100, + eval("var MYVAR = 0; while( MYVAR++ < 100) { if ( MYVAR < 100 ) continue; else break; } MYVAR ")); - testcases[tc++] = new TestCase( SECTION, - "function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)", - 2, - eval("function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)")); - test(); +new TestCase( SECTION, + "function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)", + 2, + eval("function MYFUN( arg1 ) { while ( arg1++ < 100 ) { if ( arg1 < 100 ) return arg1; } }; MYFUN(1)")); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-1.js b/mozilla/js/tests/ecma/Statements/12.6.2-1.js index 1a7c5a74916..963e954ce0d 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-1.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,39 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-1.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-1.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is not present. - 2. second expression is not present - 3. third expression is not present + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new getTestCases(); +new TestCase( "12.6.2-1", "for statement", 99, testprogram() ); - test(); +test(); -function getTestCases() { - var array = new Array(); - array[0] = new TestCase( "12.6.2-1", "for statement", 99, "" ); - return ( array ); -} function testprogram() { - myVar = 0; + myVar = 0; - for ( ; ; ) { - if ( ++myVar == 99 ) - break; - } + for ( ; ; ) { + if ( ++myVar == 99 ) + break; + } - return myVar; -} -function test() { - testcases[0].actual = testprogram(); - - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - - stopTest(); - - return ( testcases ); + return myVar; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-2.js b/mozilla/js/tests/ecma/Statements/12.6.2-2.js index 7f62388ebb3..33720b6da4f 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-2.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,58 +35,40 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-2.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-2.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is not present. - 2. second expression is not present - 3. third expression is present + 1. first expression is not present. + 2. second expression is not present + 3. third expression is present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "for statement", 99, testprogram() ); - test(); - -function getTestCases() { - var array = new Array(); - array[0] = new TestCase( SECTION, "for statement", 99, "" ); - return ( array ); -} +test(); function testprogram() { - myVar = 0; + myVar = 0; - for ( ; ; myVar++ ) { - if ( myVar < 99 ) { - continue; - } else { - break; - } + for ( ; ; myVar++ ) { + if ( myVar < 99 ) { + continue; + } else { + break; } + } - return myVar; -} -function test() { - testcases[0].actual = testprogram(); - - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - - stopTest(); - return ( testcases ); + return myVar; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-3.js b/mozilla/js/tests/ecma/Statements/12.6.2-3.js index 2672f165a83..bcf477c5796 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-3.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-3.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-3.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is not present. - 2. second expression is present - 3. third expression is present + 1. first expression is not present. + 2. second expression is present + 3. third expression is present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - testcases[0] = new TestCase( SECTION, "for statement", 100, "" ); +new TestCase( SECTION, "for statement", 100, testprogram() ); - test(); +test(); function testprogram() { - myVar = 0; + myVar = 0; - for ( ; myVar < 100 ; myVar++ ) { - continue; - } + for ( ; myVar < 100 ; myVar++ ) { + continue; + } - return myVar; -} -function test() { - testcases[0].actual = testprogram(); - - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - stopTest(); - - return ( testcases ); + return myVar; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-4.js b/mozilla/js/tests/ecma/Statements/12.6.2-4.js index d1b97ba5cee..66e32df4ab3 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-4.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-4.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-4.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is not present. - 2. second expression is present - 3. third expression is present + 1. first expression is not present. + 2. second expression is present + 3. third expression is present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, "for statement", 100, testprogram() ); - testcases[testcases.length] = new TestCase( SECTION, - "for statement", 100, testprogram() ); - - test(); +test(); function testprogram() { - myVar = 0; + myVar = 0; - for ( ; myVar < 100 ; myVar++ ) { - } + for ( ; myVar < 100 ; myVar++ ) { + } - return myVar; -} -function test() { - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - stopTest(); - return ( testcases ); + return myVar; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-5.js b/mozilla/js/tests/ecma/Statements/12.6.2-5.js index 74610555117..53d6f3146ce 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-5.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-5.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-5.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is not present. - 2. second expression is present - 3. third expression is present + 1. first expression is not present. + 2. second expression is present + 3. third expression is present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "for statement", 99, testprogram() ); - test(); - -function getTestCases() { - var array = new Array(); - array[0] = new TestCase( SECTION, "for statement", 99, "" ); - return ( array ); -} +test(); function testprogram() { - myVar = 0; + myVar = 0; - for ( ; myVar < 100 ; myVar++ ) { - if (myVar == 99) - break; - } + for ( ; myVar < 100 ; myVar++ ) { + if (myVar == 99) + break; + } - return myVar; -} -function test() { - testcases[0].actual = testprogram(); - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - stopTest(); - return ( testcases ); + return myVar; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-6.js b/mozilla/js/tests/ecma/Statements/12.6.2-6.js index ed67b89bdbb..ca066af5f7a 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-6.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,39 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-6.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-6.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is present. - 2. second expression is not present - 3. third expression is present + 1. first expression is present. + 2. second expression is not present + 3. third expression is present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( "12.6.2-6", "for statement", 256, testprogram() ); - test(); - -function getTestCases() { - var array = new Array(); - array[0] = new TestCase( "12.6.2-6", "for statement", 256, "" ); - return ( array ); -} +test(); function testprogram() { - var myVar; + var myVar; - for ( myVar=2; ; myVar *= myVar ) { + for ( myVar=2; ; myVar *= myVar ) { - if (myVar > 100) - break; - continue; - } + if (myVar > 100) + break; + continue; + } - return myVar; -} -function test() { - testcases[0].actual = testprogram(); - - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - - stopTest(); - return ( testcases ); + return myVar; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-7.js b/mozilla/js/tests/ecma/Statements/12.6.2-7.js index 0584681f7bc..9803f4b2b12 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-7.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-7.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-7.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is present. - 2. second expression is not present - 3. third expression is present + 1. first expression is present. + 2. second expression is not present + 3. third expression is present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-7"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-7"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "for statement", 256, testprogram() ); - test(); - -function getTestCases() { - var array = new Array(); - array[0] = new TestCase( SECTION, "for statement", 256, "" ); - return ( array ); -} +test(); function testprogram() { - var myVar; + var myVar; - for ( myVar=2; myVar < 100 ; myVar *= myVar ) { + for ( myVar=2; myVar < 100 ; myVar *= myVar ) { - continue; - } + continue; + } - return myVar; -} -function test() { - testcases[0].actual = testprogram(); - - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - stopTest(); - return ( testcases ); + return myVar; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-8.js b/mozilla/js/tests/ecma/Statements/12.6.2-8.js index d0ee79c6cf6..e5835c5aa00 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-8.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,51 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-8.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-8.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is present. - 2. second expression is present - 3. third expression is present + 1. first expression is present. + 2. second expression is present + 3. third expression is present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-8"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-8"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, "for statement", 256, testprogram() ); - test(); +test(); -function getTestCases() { - var array = new Array(); - array[0] = new TestCase( SECTION, "for statement", 256, "" ); - return ( array ); -} function testprogram() { - var myVar; + var myVar; - for ( myVar=2; myVar < 256; myVar *= myVar ) { - } + for ( myVar=2; myVar < 256; myVar *= myVar ) { + } - return myVar; -} -function test() { - testcases[0].actual = testprogram(); - - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - stopTest(); - return ( testcases ); + return myVar; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.2-9-n.js b/mozilla/js/tests/ecma/Statements/12.6.2-9-n.js index b0282b4935c..4b7dbf98cce 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.2-9-n.js +++ b/mozilla/js/tests/ecma/Statements/12.6.2-9-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,40 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.2-9-n.js - ECMA Section: 12.6.2 The for Statement + File Name: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is not present. - 2. second expression is not present - 3. third expression is not present + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "12.6.2-9-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for statment"; +var SECTION = "12.6.2-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +DESCRIPTION = "for (i)"; +EXPECTED = "error"; - testcases[testcases.length] = new TestCase( SECTION, - "for (i)", - "error", - "" ); +new TestCase( SECTION, + "for (i)", + "error", + eval("for (i) { }") ); - for (i) { - } +/* + for (i) { + } - test(); +*/ +test(); -function test() { - testcases[0].passed = writeTestCaseResult( - testcases[0].expect, - testcases[0].actual, - testcases[0].description +" = "+ testcases[0].actual ); - - testcases[0].reason += ( testcases[0].passed ) ? "" : "wrong value "; - - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-1.js b/mozilla/js/tests/ecma/Statements/12.6.3-1.js index f6b23a7db47..43ebcac8f09 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-1.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - Author: christine@netscape.com - Date: 11 september 1997 +/** + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; +var SECTION = "12.6.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, + "var x; Number.prototype.foo = 34; for ( j in 7 ) x = j; x", + "foo", + eval("var x; Number.prototype.foo = 34; for ( j in 7 ){x = j;} x") ); - test(); +test(); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var x; Number.prototype.foo = 34; for ( j in 7 ) x = j; x", - "foo", - eval("var x; Number.prototype.foo = 34; for ( j in 7 ){x = j;} x") ); - - return ( array ); -} - - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function MyObject(a, b, c, d, e) { - - -} \ No newline at end of file diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-10.js b/mozilla/js/tests/ecma/Statements/12.6.3-10.js index 4f4363f1951..3194a60d772 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-10.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-10.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,94 +35,79 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-10.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-10.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-10"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; +var SECTION = "12.6.3-10"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression - // for ( LeftHandSideExpression in Expression ) - // LeftHandSideExpression:NewExpression:MemberExpression +var count = 0; +function f() { count++; return new Array("h","e","l","l","o"); } - var count = 0; - function f() { count++; return new Array("h","e","l","l","o"); } +var result = ""; +for ( p in f() ) { result += f()[p] }; - var result = ""; - for ( p in f() ) { result += f()[p] }; +new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); - testcases[testcases.length] = new TestCase( SECTION, - "count = 0; result = \"\"; "+ - "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ - "for ( p in f() ) { result += f()[p] }; count", - 6, - count ); +new TestCase( SECTION, + "result", + "hello", + result ); - testcases[testcases.length] = new TestCase( SECTION, - "result", - "hello", - result ); +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier - // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] - // LeftHandSideExpression:NewExpression:MemberExpression . Identifier - // LeftHandSideExpression:NewExpression:new MemberExpression Arguments - // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) - // LeftHandSideExpression:CallExpression:MemberExpression Arguments - // LeftHandSideExpression:CallExpression Arguments - // LeftHandSideExpression:CallExpression [ Expression ] - // LeftHandSideExpression:CallExpression . Identifier - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-11.js b/mozilla/js/tests/ecma/Statements/12.6.3-11.js index c6382359bd9..8d58550609a 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-11.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-11.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,75 +35,62 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-11.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-11.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-11"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; +var SECTION = "12.6.3-11"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); // 5. Get the name of the next property of Result(3) that doesn't have the // DontEnum attribute. If there is no such property, go to step 14. - var result = ""; +var result = ""; - for ( p in Number ) { result += String(p) }; +for ( p in Number ) { result += String(p) }; - testcases[testcases.length] = new TestCase( SECTION, - "result = \"\"; for ( p in Number ) { result += String(p) };", - "", - result ); +new TestCase( SECTION, + "result = \"\"; for ( p in Number ) { result += String(p) };", + "", + result ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-12.js b/mozilla/js/tests/ecma/Statements/12.6.3-12.js index 3ed0197bc50..b2cc65be26c 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-12.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-12.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,81 +36,65 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 12.6.3-12.js - ECMA Section: 12.6.3 The for...in Statement - Description: + File Name: 12.6.3-12.js + ECMA Section: 12.6.3 The for...in Statement + Description: - This is a regression test for http://bugzilla.mozilla.org/show_bug.cgi?id=9802. + This is a regression test for http://bugzilla.mozilla.org/show_bug.cgi?id=9802. - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-12"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; +var SECTION = "12.6.3-12"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var result = "PASSED"; - var result = "PASSED"; +for ( aVar in this ) { + if (aVar == "aVar") { + result = "FAILED" + } +}; - for ( aVar in this ) { - if (aVar == "aVar") { - result = "FAILED" - } - }; +new TestCase( + SECTION, + "var result=''; for ( aVar in this ) { " + + "if (aVar == 'aVar') {return a failure}; result", + "PASSED", + result ); - testcases[testcases.length] = new TestCase( - SECTION, - "var result=''; for ( aVar in this ) { " + - "if (aVar == 'aVar') {return a failure}; result", - "PASSED", - result ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-19.js b/mozilla/js/tests/ecma/Statements/12.6.3-19.js index 3f4aea45da2..8d0e1e41679 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-19.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-19.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,96 +35,81 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression - // for ( LeftHandSideExpression in Expression ) - // LeftHandSideExpression:NewExpression:MemberExpression +var count = 0; +function f() { count++; return new Array("h","e","l","l","o"); } - var count = 0; - function f() { count++; return new Array("h","e","l","l","o"); } +var result = ""; +for ( p in f() ) { result += f()[p] }; - var result = ""; - for ( p in f() ) { result += f()[p] }; +new TestCase( SECTION, + "count = 0; result = \"\"; "+ + "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ + "for ( p in f() ) { result += f()[p] }; count", + 6, + count ); - testcases[testcases.length] = new TestCase( SECTION, - "count = 0; result = \"\"; "+ - "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+ - "for ( p in f() ) { result += f()[p] }; count", - 6, - count ); - - testcases[testcases.length] = new TestCase( SECTION, - "result", - "hello", - result ); +new TestCase( SECTION, + "result", + "hello", + result ); - // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] - // LeftHandSideExpression:NewExpression:MemberExpression . Identifier - // LeftHandSideExpression:NewExpression:new MemberExpression Arguments - // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) - // LeftHandSideExpression:CallExpression:MemberExpression Arguments - // LeftHandSideExpression:CallExpression Arguments - // LeftHandSideExpression:CallExpression [ Expression ] - // LeftHandSideExpression:CallExpression . Identifier +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-2.js b/mozilla/js/tests/ecma/Statements/12.6.3-2.js index de7ba5217e2..0c958c0d093 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-2.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-2.js - ECMA Section: 12.6.3 The for...in Statement - Description: Check the Boolean Object + File Name: 12.6.3-2.js + ECMA Section: 12.6.3 The for...in Statement + Description: Check the Boolean Object - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; +var SECTION = "12.6.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +new TestCase( SECTION, + "Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j]", + 34, + eval("Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j] ") ); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j]", - 34, - eval("Boolean.prototype.foo = 34; for ( j in Boolean ) Boolean[j] ") ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-3.js b/mozilla/js/tests/ecma/Statements/12.6.3-3.js index f537715759a..caa750f0b52 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-3.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-3.js - ECMA Section: for..in loops - Description: + File Name: 12.6.3-3.js + ECMA Section: for..in loops + Description: - This verifies the fix to - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112156 - for..in should take general lvalue for first argument + This verifies the fix to + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=112156 + for..in should take general lvalue for first argument - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.6.3-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; +var SECTION = "12.6.3-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var o = {}; +var result = ""; - var o = {}; +for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } - var result = ""; +new TestCase( SECTION, + "for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } result", + "123", + result ); - for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } +test(); - testcases[testcases.length] = new TestCase( SECTION, - "for ( o.a in [1,2,3] ) { result += String( [1,2,3][o.a] ); } result", - "123", - result ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-4.js b/mozilla/js/tests/ecma/Statements/12.6.3-4.js index d5eccc9e258..3d89dbc2850 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-4.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,175 +35,166 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; - var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; +var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression - // for ( LeftHandSideExpression in Expression ) - // LeftHandSideExpression:NewExpression:MemberExpression +var o = new MyObject(); +var result = 0; - var o = new MyObject(); - var result = 0; - - for ( MyObject in o ) { - result += o[MyObject]; - } - - testcases[testcases.length] = new TestCase( SECTION, - "for ( MyObject in o ) { result += o[MyObject] }", - 6, - result ); - - var result = 0; - - for ( value in o ) { - result += o[value]; - } - - testcases[testcases.length] = new TestCase( SECTION, - "for ( value in o ) { result += o[value]", - 6, - result ); - - var value = "value"; - var result = 0; - for ( value in o ) { - result += o[value]; - } - - testcases[testcases.length] = new TestCase( SECTION, - "value = \"value\"; for ( value in o ) { result += o[value]", - 6, - result ); - - var value = 0; - var result = 0; - for ( value in o ) { - result += o[value]; - } - - testcases[testcases.length] = new TestCase( SECTION, - "value = 0; for ( value in o ) { result += o[value]", - 6, - result ); - - // this causes a segv - - var ob = { 0:"hello" }; - var result = 0; - for ( ob[0] in o ) { - result += o[ob[0]]; - } - testcases[testcases.length] = new TestCase( SECTION, - "ob = { 0:\"hello\" }; for ( ob[0] in o ) { result += o[ob[0]]", - 6, - result ); - - var result = 0; - for ( ob["0"] in o ) { - result += o[ob["0"]]; - } - testcases[testcases.length] = new TestCase( SECTION, - "value = 0; for ( ob[\"0\"] in o ) { result += o[o[\"0\"]]", - 6, - result ); - - var result = 0; - var ob = { value:"hello" }; - for ( ob[value] in o ) { - result += o[ob[value]]; - } - testcases[testcases.length] = new TestCase( SECTION, - "ob = { 0:\"hello\" }; for ( ob[value] in o ) { result += o[ob[value]]", - 6, - result ); - - var result = 0; - for ( ob["value"] in o ) { - result += o[ob["value"]]; - } - testcases[testcases.length] = new TestCase( SECTION, - "value = 0; for ( ob[\"value\"] in o ) { result += o[ob[\"value\"]]", - 6, - result ); - - var result = 0; - for ( ob.value in o ) { - result += o[ob.value]; - } - testcases[testcases.length] = new TestCase( SECTION, - "value = 0; for ( ob.value in o ) { result += o[ob.value]", - 6, - result ); - - // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] - // LeftHandSideExpression:NewExpression:MemberExpression . Identifier - // LeftHandSideExpression:NewExpression:new MemberExpression Arguments - // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) - // LeftHandSideExpression:CallExpression:MemberExpression Arguments - // LeftHandSideExpression:CallExpression Arguments - // LeftHandSideExpression:CallExpression [ Expression ] - // LeftHandSideExpression:CallExpression . Identifier - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( MyObject in o ) { + result += o[MyObject]; } + +new TestCase( SECTION, + "for ( MyObject in o ) { result += o[MyObject] }", + 6, + result ); + +var result = 0; + +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "for ( value in o ) { result += o[value]", + 6, + result ); + +var value = "value"; +var result = 0; +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "value = \"value\"; for ( value in o ) { result += o[value]", + 6, + result ); + +var value = 0; +var result = 0; +for ( value in o ) { + result += o[value]; +} + +new TestCase( SECTION, + "value = 0; for ( value in o ) { result += o[value]", + 6, + result ); + +// this causes a segv + +var ob = { 0:"hello" }; +var result = 0; +for ( ob[0] in o ) { + result += o[ob[0]]; +} + +new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[0] in o ) { result += o[ob[0]]", + 6, + result ); + +var result = 0; +for ( ob["0"] in o ) { + result += o[ob["0"]]; +} + +new TestCase( SECTION, + "value = 0; for ( ob[\"0\"] in o ) { result += o[o[\"0\"]]", + 6, + result ); + +var result = 0; +var ob = { value:"hello" }; +for ( ob[value] in o ) { + result += o[ob[value]]; +} + +new TestCase( SECTION, + "ob = { 0:\"hello\" }; for ( ob[value] in o ) { result += o[ob[value]]", + 6, + result ); + +var result = 0; +for ( ob["value"] in o ) { + result += o[ob["value"]]; +} + +new TestCase( SECTION, + "value = 0; for ( ob[\"value\"] in o ) { result += o[ob[\"value\"]]", + 6, + result ); + +var result = 0; +for ( ob.value in o ) { + result += o[ob.value]; +} + +new TestCase( SECTION, + "value = 0; for ( ob.value in o ) { result += o[ob.value]", + 6, + result ); + +// LeftHandSideExpression:NewExpression:MemberExpression [ Expression ] +// LeftHandSideExpression:NewExpression:MemberExpression . Identifier +// LeftHandSideExpression:NewExpression:new MemberExpression Arguments +// LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression ) +// LeftHandSideExpression:CallExpression:MemberExpression Arguments +// LeftHandSideExpression:CallExpression Arguments +// LeftHandSideExpression:CallExpression [ Expression ] +// LeftHandSideExpression:CallExpression . Identifier + +test(); + function MyObject() { - this.value = 2; - this[0] = 4; - return this; + this.value = 2; + this[0] = 4; + return this; } diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-5-n.js b/mozilla/js/tests/ecma/Statements/12.6.3-5-n.js index 9e2d88a8484..3eeb56faef3 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-5-n.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-5-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; - var error = err; +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; +var error = err; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression - // for ( LeftHandSideExpression in Expression ) - // LeftHandSideExpression:NewExpression:MemberExpression +DESCRIPTION = "more than one member expression"; +EXPECTED = "error"; - testcases[testcases.length] = new TestCase( SECTION, - "more than one member expression", - "error", - "" ); +new TestCase( SECTION, + "more than one member expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( var i, p in this) { result += this[p]; }") ); - var o = new MyObject(); - var result = 0; +/* + var o = new MyObject(); + var result = 0; - for ( var i, p in this) { - result += this[p]; - } + for ( var i, p in this) { + result += this[p]; + } +*/ - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} \ No newline at end of file + this.value = 2; + this[0] = 4; + return this; +} diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-6-n.js b/mozilla/js/tests/ecma/Statements/12.6.3-6-n.js index 5db04edac24..0e6a12da653 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-6-n.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-6-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; - var error = err; +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; +var error = err; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression - // for ( LeftHandSideExpression in Expression ) - // LeftHandSideExpression:NewExpression:MemberExpression +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; - testcases[testcases.length] = new TestCase( SECTION, - "bad left-hand side expression", - "error", - "" ); +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( this in o) { result += this[p]; }") ); +/* + var o = new MyObject(); + var result = 0; - var o = new MyObject(); - var result = 0; + for ( this in o) { + result += this[p]; + } +*/ - for ( this in o) { - result += this[p]; - } +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} \ No newline at end of file + this.value = 2; + this[0] = 4; + return this; +} diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-7-n.js b/mozilla/js/tests/ecma/Statements/12.6.3-7-n.js index 0f91d3c40f1..7718ceb73de 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-7-n.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-7-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; - var error = err; +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; +var error = err; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression - // for ( LeftHandSideExpression in Expression ) - // LeftHandSideExpression:NewExpression:MemberExpression +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; - testcases[testcases.length] = new TestCase( SECTION, - "bad left-hand side expression", - "error", - "" ); +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( \"a\" in o) { result += this[p]; } ") ); - var o = new MyObject(); - var result = 0; +/* + var o = new MyObject(); + var result = 0; - for ( "a" in o) { - result += this[p]; - } + for ( "a" in o) { + result += this[p]; + } +*/ - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} \ No newline at end of file + this.value = 2; + this[0] = 4; + return this; +} diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-8-n.js b/mozilla/js/tests/ecma/Statements/12.6.3-8-n.js index be11cf809a2..d35dcf801df 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-8-n.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-8-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-8-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; - var error = err; +var SECTION = "12.6.3-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; +var error = err; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression - // for ( LeftHandSideExpression in Expression ) - // LeftHandSideExpression:NewExpression:MemberExpression +DESCRIPTION = "bad left-hand side expression"; +EXPECTED = "error"; - testcases[testcases.length] = new TestCase( SECTION, - "bad left-hand side expression", - "error", - "" ); +new TestCase( SECTION, + "bad left-hand side expression", + "error", + eval("var o = new MyObject(); var result = 0; for ( 1 in o) { result += this[p]; } ") ); - var o = new MyObject(); - var result = 0; +/* + var o = new MyObject(); + var result = 0; - for ( 1 in o) { - result += this[p]; - } + for ( 1 in o) { + result += this[p]; + } +*/ - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} \ No newline at end of file + this.value = 2; + this[0] = 4; + return this; +} diff --git a/mozilla/js/tests/ecma/Statements/12.6.3-9-n.js b/mozilla/js/tests/ecma/Statements/12.6.3-9-n.js index f06936b4f40..bc1e560e78b 100644 --- a/mozilla/js/tests/ecma/Statements/12.6.3-9-n.js +++ b/mozilla/js/tests/ecma/Statements/12.6.3-9-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.6.3-9-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "12.6.3-9-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The for..in statment"; - var error = err; +var SECTION = "12.6.3-9-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The for..in statement"; +var error = err; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// for ( LeftHandSideExpression in Expression ) +// LeftHandSideExpression:NewExpression:MemberExpression - // for ( LeftHandSideExpression in Expression ) - // LeftHandSideExpression:NewExpression:MemberExpression +DESCRIPTION = "object is not defined"; +EXPECTED = "error"; - testcases[testcases.length] = new TestCase( SECTION, - "object is not defined", - "error", - "" ); +new TestCase( SECTION, + "object is not defined", + "error", + eval("var o = new MyObject(); var result = 0; for ( var o in foo) { result += this[o]; } ") ); +/* + var o = new MyObject(); + var result = 0; - var o = new MyObject(); - var result = 0; + for ( var o in foo) { + result += this[o]; + } +*/ - for ( var o in foo) { - result += this[o]; - } +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} \ No newline at end of file + this.value = 2; + this[0] = 4; + return this; +} diff --git a/mozilla/js/tests/ecma/Statements/12.7-1-n.js b/mozilla/js/tests/ecma/Statements/12.7-1-n.js index 8cffef5eb00..f0b7f757bfc 100644 --- a/mozilla/js/tests/ecma/Statements/12.7-1-n.js +++ b/mozilla/js/tests/ecma/Statements/12.7-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,28 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.7-1-n.js - ECMA Section: 12.7 The continue statement - Description: + File Name: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.7.1-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The continue statment"; +var SECTION = "12.7.1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The continue statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +DESCRIPTION = "continue"; +EXPECTED = "error"; - test(); +new TestCase( SECTION, + "continue", + "error", + eval("continue") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "continue", - "error", - "continue" ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/Statements/12.8-1-n.js b/mozilla/js/tests/ecma/Statements/12.8-1-n.js index ff1ad1c4941..04b22528c34 100644 --- a/mozilla/js/tests/ecma/Statements/12.8-1-n.js +++ b/mozilla/js/tests/ecma/Statements/12.8-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,51 +35,31 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 12.8-1-n.js - ECMA Section: 12.8 The break statement - Description: - Author: christine@netscape.com - Date: 12 november 1997 +/** + File Name: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.8-1-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The break in statment"; +var SECTION = "12.8-1-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The break in statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); +DESCRIPTION = "break"; +EXPECTED = "error"; - test(); +new TestCase( SECTION, + "break", + "error", + eval("break") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval( testcases[tc].actual ); - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "break", - "error", - "break" ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/Statements/12.9-1-n.js b/mozilla/js/tests/ecma/Statements/12.9-1-n.js index 1a3cc7f1de9..d1d9384af68 100644 --- a/mozilla/js/tests/ecma/Statements/12.9-1-n.js +++ b/mozilla/js/tests/ecma/Statements/12.9-1-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,46 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 12.9-1-n.js - ECMA Section: 12.9 The return statement - Description: + File Name: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.9-1-n"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "12.9-1-n"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " The return statement"); - test(); +writeHeaderToLog( SECTION + " The return statement"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { +DESCRIPTION = "return"; +EXPECTED = "error"; - testcases[tc].actual = eval( testcases[tc].actual ); +new TestCase( SECTION, + "return", + "error", + eval("return") ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "return", - "error", - "return" ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/Statements/browser.js b/mozilla/js/tests/ecma/Statements/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Statements/shell.js b/mozilla/js/tests/ecma/Statements/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/String/15.5.1.js b/mozilla/js/tests/ecma/String/15.5.1.js index 53826d513d7..7cb5c93fe2b 100644 --- a/mozilla/js/tests/ecma/String/15.5.1.js +++ b/mozilla/js/tests/ecma/String/15.5.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,118 +35,98 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.1.js - ECMA Section: 15.5.1 The String Constructor called as a Function - 15.5.1.1 String(value) - 15.5.1.2 String() + File Name: 15.5.1.js + ECMA Section: 15.5.1 The String Constructor called as a Function + 15.5.1.1 String(value) + 15.5.1.2 String() - Description: When String is called as a function rather than as - a constructor, it performs a type conversion. - - String(value) returns a string value (not a String - object) computed by ToString(value) - - String() returns the empty string "" + Description: When String is called as a function rather than as + a constructor, it performs a type conversion. + - String(value) returns a string value (not a String + object) computed by ToString(value) + - String() returns the empty string "" - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The String Constructor Called as a Function"; +var SECTION = "15.5.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The String Constructor Called as a Function"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "String('string primitive')", "string primitive", String('string primitive') ); - array[item++] = new TestCase( SECTION, "String(void 0)", "undefined", String( void 0) ); - array[item++] = new TestCase( SECTION, "String(null)", "null", String( null ) ); - array[item++] = new TestCase( SECTION, "String(true)", "true", String( true) ); - array[item++] = new TestCase( SECTION, "String(false)", "false", String( false ) ); - array[item++] = new TestCase( SECTION, "String(Boolean(true))", "true", String(Boolean(true)) ); - array[item++] = new TestCase( SECTION, "String(Boolean(false))", "false", String(Boolean(false)) ); - array[item++] = new TestCase( SECTION, "String(Boolean())", "false", String(Boolean(false)) ); - array[item++] = new TestCase( SECTION, "String(new Array())", "", String( new Array()) ); - array[item++] = new TestCase( SECTION, "String(new Array(1,2,3))", "1,2,3", String( new Array(1,2,3)) ); +new TestCase( SECTION, "String('string primitive')", "string primitive", String('string primitive') ); +new TestCase( SECTION, "String(void 0)", "undefined", String( void 0) ); +new TestCase( SECTION, "String(null)", "null", String( null ) ); +new TestCase( SECTION, "String(true)", "true", String( true) ); +new TestCase( SECTION, "String(false)", "false", String( false ) ); +new TestCase( SECTION, "String(Boolean(true))", "true", String(Boolean(true)) ); +new TestCase( SECTION, "String(Boolean(false))", "false", String(Boolean(false)) ); +new TestCase( SECTION, "String(Boolean())", "false", String(Boolean(false)) ); +new TestCase( SECTION, "String(new Array())", "", String( new Array()) ); +new TestCase( SECTION, "String(new Array(1,2,3))", "1,2,3", String( new Array(1,2,3)) ); - array[item++] = new TestCase( SECTION, "String( Number.NaN )", "NaN", String( Number.NaN ) ); - array[item++] = new TestCase( SECTION, "String( 0 )", "0", String( 0 ) ); - array[item++] = new TestCase( SECTION, "String( -0 )", "0", String( -0 ) ); - array[item++] = new TestCase( SECTION, "String( Number.POSITIVE_INFINITY )", "Infinity", String( Number.POSITIVE_INFINITY ) ); - array[item++] = new TestCase( SECTION, "String( Number.NEGATIVE_INFINITY )", "-Infinity", String( Number.NEGATIVE_INFINITY ) ); - array[item++] = new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); +new TestCase( SECTION, "String( Number.NaN )", "NaN", String( Number.NaN ) ); +new TestCase( SECTION, "String( 0 )", "0", String( 0 ) ); +new TestCase( SECTION, "String( -0 )", "0", String( -0 ) ); +new TestCase( SECTION, "String( Number.POSITIVE_INFINITY )", "Infinity", String( Number.POSITIVE_INFINITY ) ); +new TestCase( SECTION, "String( Number.NEGATIVE_INFINITY )", "-Infinity", String( Number.NEGATIVE_INFINITY ) ); +new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); - // cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 +// cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 - array[item++] = new TestCase( SECTION, "String( 1 )", "1", String( 1 ) ); - array[item++] = new TestCase( SECTION, "String( 10 )", "10", String( 10 ) ); - array[item++] = new TestCase( SECTION, "String( 100 )", "100", String( 100 ) ); - array[item++] = new TestCase( SECTION, "String( 1000 )", "1000", String( 1000 ) ); - array[item++] = new TestCase( SECTION, "String( 10000 )", "10000", String( 10000 ) ); - array[item++] = new TestCase( SECTION, "String( 10000000000 )", "10000000000", String( 10000000000 ) ); - array[item++] = new TestCase( SECTION, "String( 10000000000000000000 )", "10000000000000000000", String( 10000000000000000000 ) ); - array[item++] = new TestCase( SECTION, "String( 100000000000000000000 )","100000000000000000000",String( 100000000000000000000 ) ); +new TestCase( SECTION, "String( 1 )", "1", String( 1 ) ); +new TestCase( SECTION, "String( 10 )", "10", String( 10 ) ); +new TestCase( SECTION, "String( 100 )", "100", String( 100 ) ); +new TestCase( SECTION, "String( 1000 )", "1000", String( 1000 ) ); +new TestCase( SECTION, "String( 10000 )", "10000", String( 10000 ) ); +new TestCase( SECTION, "String( 10000000000 )", "10000000000", String( 10000000000 ) ); +new TestCase( SECTION, "String( 10000000000000000000 )", "10000000000000000000", String( 10000000000000000000 ) ); +new TestCase( SECTION, "String( 100000000000000000000 )","100000000000000000000",String( 100000000000000000000 ) ); - array[item++] = new TestCase( SECTION, "String( 12345 )", "12345", String( 12345 ) ); - array[item++] = new TestCase( SECTION, "String( 1234567890 )", "1234567890", String( 1234567890 ) ); +new TestCase( SECTION, "String( 12345 )", "12345", String( 12345 ) ); +new TestCase( SECTION, "String( 1234567890 )", "1234567890", String( 1234567890 ) ); - array[item++] = new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); - array[item++] = new TestCase( SECTION, "String( -10 )", "-10", String( -10 ) ); - array[item++] = new TestCase( SECTION, "String( -100 )", "-100", String( -100 ) ); - array[item++] = new TestCase( SECTION, "String( -1000 )", "-1000", String( -1000 ) ); - array[item++] = new TestCase( SECTION, "String( -1000000000 )", "-1000000000", String( -1000000000 ) ); - array[item++] = new TestCase( SECTION, "String( -1000000000000000 )", "-1000000000000000", String( -1000000000000000 ) ); - array[item++] = new TestCase( SECTION, "String( -100000000000000000000 )", "-100000000000000000000", String( -100000000000000000000 ) ); - array[item++] = new TestCase( SECTION, "String( -1000000000000000000000 )", "-1e+21", String( -1000000000000000000000 ) ); +new TestCase( SECTION, "String( -1 )", "-1", String( -1 ) ); +new TestCase( SECTION, "String( -10 )", "-10", String( -10 ) ); +new TestCase( SECTION, "String( -100 )", "-100", String( -100 ) ); +new TestCase( SECTION, "String( -1000 )", "-1000", String( -1000 ) ); +new TestCase( SECTION, "String( -1000000000 )", "-1000000000", String( -1000000000 ) ); +new TestCase( SECTION, "String( -1000000000000000 )", "-1000000000000000", String( -1000000000000000 ) ); +new TestCase( SECTION, "String( -100000000000000000000 )", "-100000000000000000000", String( -100000000000000000000 ) ); +new TestCase( SECTION, "String( -1000000000000000000000 )", "-1e+21", String( -1000000000000000000000 ) ); - array[item++] = new TestCase( SECTION, "String( -12345 )", "-12345", String( -12345 ) ); - array[item++] = new TestCase( SECTION, "String( -1234567890 )", "-1234567890", String( -1234567890 ) ); +new TestCase( SECTION, "String( -12345 )", "-12345", String( -12345 ) ); +new TestCase( SECTION, "String( -1234567890 )", "-1234567890", String( -1234567890 ) ); - // cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, - array[item++] = new TestCase( SECTION, "String( 1.0000001 )", "1.0000001", String( 1.0000001 ) ); +// cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, +new TestCase( SECTION, "String( 1.0000001 )", "1.0000001", String( 1.0000001 ) ); - // cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 +// cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 - // cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 +// cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 - array[item++] = new TestCase( SECTION, "String( 1000000000000000000000 )", "1e+21", String( 1000000000000000000000 ) ); - array[item++] = new TestCase( SECTION, "String( 10000000000000000000000 )", "1e+22", String( 10000000000000000000000 ) ); +new TestCase( SECTION, "String( 1000000000000000000000 )", "1e+21", String( 1000000000000000000000 ) ); +new TestCase( SECTION, "String( 10000000000000000000000 )", "1e+22", String( 10000000000000000000000 ) ); - // cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 - array[item++] = new TestCase( SECTION, "String( 1.2345 )", "1.2345", String( 1.2345)); - array[item++] = new TestCase( SECTION, "String( 1.234567890 )", "1.23456789", String( 1.234567890 )); +// cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 +new TestCase( SECTION, "String( 1.2345 )", "1.2345", String( 1.2345)); +new TestCase( SECTION, "String( 1.234567890 )", "1.23456789", String( 1.234567890 )); - array[item++] = new TestCase( SECTION, "String( .12345 )", "0.12345", String(.12345 ) ); - array[item++] = new TestCase( SECTION, "String( .012345 )", "0.012345", String(.012345) ); - array[item++] = new TestCase( SECTION, "String( .0012345 )", "0.0012345", String(.0012345) ); - array[item++] = new TestCase( SECTION, "String( .00012345 )", "0.00012345", String(.00012345) ); - array[item++] = new TestCase( SECTION, "String( .000012345 )", "0.000012345", String(.000012345) ); - array[item++] = new TestCase( SECTION, "String( .0000012345 )", "0.0000012345", String(.0000012345) ); - array[item++] = new TestCase( SECTION, "String( .00000012345 )", "1.2345e-7", String(.00000012345)); +new TestCase( SECTION, "String( .12345 )", "0.12345", String(.12345 ) ); +new TestCase( SECTION, "String( .012345 )", "0.012345", String(.012345) ); +new TestCase( SECTION, "String( .0012345 )", "0.0012345", String(.0012345) ); +new TestCase( SECTION, "String( .00012345 )", "0.00012345", String(.00012345) ); +new TestCase( SECTION, "String( .000012345 )", "0.000012345", String(.000012345) ); +new TestCase( SECTION, "String( .0000012345 )", "0.0000012345", String(.0000012345) ); +new TestCase( SECTION, "String( .00000012345 )", "1.2345e-7", String(.00000012345)); - array[item++] = new TestCase( "15.5.2", "String()", "", String() ); +new TestCase( "15.5.2", "String()", "", String() ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.2.js b/mozilla/js/tests/ecma/String/15.5.2.js index c48e8f82c0f..5bf0c5d3190 100644 --- a/mozilla/js/tests/ecma/String/15.5.2.js +++ b/mozilla/js/tests/ecma/String/15.5.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,94 +35,73 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.2.js - ECMA Section: 15.5.2 The String Constructor - 15.5.2.1 new String(value) - 15.5.2.2 new String() - - Description: When String is called as part of a new expression, it - is a constructor; it initializes the newly constructed - object. - - - The prototype property of the newly constructed - object is set to the original String prototype object, - the one that is the intial value of String.prototype - - The internal [[Class]] property of the object is "String" - - The value of the object is ToString(value). - - If no value is specified, its value is the empty string. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ - - var SECTION = "15.5.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The String Constructor"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "typeof new String('string primitive')", "object", typeof new String('string primitive') ); - array[item++] = new TestCase( SECTION, "var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, "(new String('string primitive')).valueOf()", 'string primitive', (new String('string primitive')).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String('string primitive')).substring", String.prototype.substring, (new String('string primitive')).substring ); - - array[item++] = new TestCase( SECTION, "typeof new String(void 0)", "object", typeof new String(void 0) ); - array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, "(new String(void 0)).valueOf()", "undefined", (new String(void 0)).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String(void 0)).toString", String.prototype.toString, (new String(void 0)).toString ); - - array[item++] = new TestCase( SECTION, "typeof new String(null)", "object", typeof new String(null) ); - array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, "(new String(null)).valueOf()", "null", (new String(null)).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String(null)).valueOf", String.prototype.valueOf, (new String(null)).valueOf ); - - array[item++] = new TestCase( SECTION, "typeof new String(true)", "object", typeof new String(true) ); - array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, "(new String(true)).valueOf()", "true", (new String(true)).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String(true)).charAt", String.prototype.charAt, (new String(true)).charAt ); - - array[item++] = new TestCase( SECTION, "typeof new String(false)", "object", typeof new String(false) ); - array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, "(new String(false)).valueOf()", "false", (new String(false)).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String(false)).charCodeAt", String.prototype.charCodeAt, (new String(false)).charCodeAt ); - - array[item++] = new TestCase( SECTION, "typeof new String(new Boolean(true))", "object", typeof new String(new Boolean(true)) ); - array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, "(new String(new Boolean(true))).valueOf()", "true", (new String(new Boolean(true))).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String(new Boolean(true))).indexOf", String.prototype.indexOf, (new String(new Boolean(true))).indexOf ); - - array[item++] = new TestCase( SECTION, "typeof new String()", "object", typeof new String() ); - array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, "(new String()).valueOf()", '', (new String()).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String()).lastIndexOf", String.prototype.lastIndexOf, (new String()).lastIndexOf ); - - array[item++] = new TestCase( SECTION, "typeof new String('')", "object", typeof new String('') ); - array[item++] = new TestCase( SECTION, "var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, "(new String('')).valueOf()", '', (new String('')).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String('')).split", String.prototype.split, (new String('')).split ); - - return ( array ); -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.5.2.js + ECMA Section: 15.5.2 The String Constructor + 15.5.2.1 new String(value) + 15.5.2.2 new String() + + Description: When String is called as part of a new expression, it + is a constructor; it initializes the newly constructed + object. + + - The prototype property of the newly constructed + object is set to the original String prototype object, + the one that is the intial value of String.prototype + - The internal [[Class]] property of the object is "String" + - The value of the object is ToString(value). + - If no value is specified, its value is the empty string. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The String Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + + +new TestCase( SECTION, "typeof new String('string primitive')", "object", typeof new String('string primitive') ); +new TestCase( SECTION, "var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String('string primitive'); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String('string primitive')).valueOf()", 'string primitive', (new String('string primitive')).valueOf() ); +new TestCase( SECTION, "(new String('string primitive')).substring", String.prototype.substring, (new String('string primitive')).substring ); + +new TestCase( SECTION, "typeof new String(void 0)", "object", typeof new String(void 0) ); +new TestCase( SECTION, "var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(void 0); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(void 0)).valueOf()", "undefined", (new String(void 0)).valueOf() ); +new TestCase( SECTION, "(new String(void 0)).toString", String.prototype.toString, (new String(void 0)).toString ); + +new TestCase( SECTION, "typeof new String(null)", "object", typeof new String(null) ); +new TestCase( SECTION, "var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(null); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(null)).valueOf()", "null", (new String(null)).valueOf() ); +new TestCase( SECTION, "(new String(null)).valueOf", String.prototype.valueOf, (new String(null)).valueOf ); + +new TestCase( SECTION, "typeof new String(true)", "object", typeof new String(true) ); +new TestCase( SECTION, "var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(true); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(true)).valueOf()", "true", (new String(true)).valueOf() ); +new TestCase( SECTION, "(new String(true)).charAt", String.prototype.charAt, (new String(true)).charAt ); + +new TestCase( SECTION, "typeof new String(false)", "object", typeof new String(false) ); +new TestCase( SECTION, "var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(false); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(false)).valueOf()", "false", (new String(false)).valueOf() ); +new TestCase( SECTION, "(new String(false)).charCodeAt", String.prototype.charCodeAt, (new String(false)).charCodeAt ); + +new TestCase( SECTION, "typeof new String(new Boolean(true))", "object", typeof new String(new Boolean(true)) ); +new TestCase( SECTION, "var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(new Boolean(true)); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String(new Boolean(true))).valueOf()", "true", (new String(new Boolean(true))).valueOf() ); +new TestCase( SECTION, "(new String(new Boolean(true))).indexOf", String.prototype.indexOf, (new String(new Boolean(true))).indexOf ); + +new TestCase( SECTION, "typeof new String()", "object", typeof new String() ); +new TestCase( SECTION, "var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String()).valueOf()", '', (new String()).valueOf() ); +new TestCase( SECTION, "(new String()).lastIndexOf", String.prototype.lastIndexOf, (new String()).lastIndexOf ); + +new TestCase( SECTION, "typeof new String('')", "object", typeof new String('') ); +new TestCase( SECTION, "var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()", "[object String]", eval("var TESTSTRING = new String(''); TESTSTRING.toString=Object.prototype.toString;TESTSTRING.toString()") ); +new TestCase( SECTION, "(new String('')).valueOf()", '', (new String('')).valueOf() ); +new TestCase( SECTION, "(new String('')).split", String.prototype.split, (new String('')).split ); + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.3.1-1.js b/mozilla/js/tests/ecma/String/15.5.3.1-1.js index 51c0caf7992..9cf08c02d2f 100644 --- a/mozilla/js/tests/ecma/String/15.5.3.1-1.js +++ b/mozilla/js/tests/ecma/String/15.5.3.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,55 +35,35 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.3.1-1.js - ECMA Section: 15.5.3.1 Properties of the String Constructor + File Name: 15.5.3.1-1.js + ECMA Section: 15.5.3.1 Properties of the String Constructor - Description: The initial value of String.prototype is the built-in - String prototype object. + Description: The initial value of String.prototype is the built-in + String prototype object. - This property shall have the attributes [ DontEnum, - DontDelete, ReadOnly] + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] - This tests the DontEnum attribute. + This tests the DontEnum attribute. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.3.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the String Constructor"; +var SECTION = "15.5.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Constructor"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); +new TestCase( SECTION, + "var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str", + "", + eval("var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); - - array[item++] = new TestCase( SECTION, - "var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str", - "", - eval("var str='';for ( p in String ) { if ( p == 'prototype' ) str += p; } str") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.3.1-2.js b/mozilla/js/tests/ecma/String/15.5.3.1-2.js index cff00045a0a..8d69bf8efdc 100644 --- a/mozilla/js/tests/ecma/String/15.5.3.1-2.js +++ b/mozilla/js/tests/ecma/String/15.5.3.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,32 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.3.1-2.js - ECMA Section: 15.5.3.1 Properties of the String Constructor - - Description: The initial value of String.prototype is the built-in - String prototype object. - - This property shall have the attributes [ DontEnum, - DontDelete, ReadOnly] - - This tests the ReadOnly attribute. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ - - var SECTION = "15.5.3.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the String Constructor"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "String.prototype=null;String.prototype", - String.prototype, - eval("String.prototype=null;String.prototype") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.5.3.1-2.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the ReadOnly attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "String.prototype=null;String.prototype", + String.prototype, + eval("String.prototype=null;String.prototype") ); + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.3.1-3.js b/mozilla/js/tests/ecma/String/15.5.3.1-3.js index f1a7d649340..05cff4fdd11 100644 --- a/mozilla/js/tests/ecma/String/15.5.3.1-3.js +++ b/mozilla/js/tests/ecma/String/15.5.3.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,49 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.3.1-3.js - ECMA Section: 15.5.3.1 Properties of the String Constructor - - Description: The initial value of String.prototype is the built-in - String prototype object. - - This property shall have the attributes [ DontEnum, - DontDelete, ReadOnly] - - This tests the DontDelete attribute. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ - - var SECTION = "15.5.3.1-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the String Constructor"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "delete( String.prototype )", false, eval("delete ( String.prototype )") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.5.3.1-3.js + ECMA Section: 15.5.3.1 Properties of the String Constructor + + Description: The initial value of String.prototype is the built-in + String prototype object. + + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] + + This tests the DontDelete attribute. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + +var SECTION = "15.5.3.1-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "delete( String.prototype )", false, eval("delete ( String.prototype )") ); + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.3.1-4.js b/mozilla/js/tests/ecma/String/15.5.3.1-4.js index 572e6140a19..e9a3eb3b77f 100644 --- a/mozilla/js/tests/ecma/String/15.5.3.1-4.js +++ b/mozilla/js/tests/ecma/String/15.5.3.1-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.3.1-4.js - ECMA Section: 15.5.3.1 Properties of the String Constructor + File Name: 15.5.3.1-4.js + ECMA Section: 15.5.3.1 Properties of the String Constructor - Description: The initial value of String.prototype is the built-in - String prototype object. + Description: The initial value of String.prototype is the built-in + String prototype object. - This property shall have the attributes [ DontEnum, - DontDelete, ReadOnly] + This property shall have the attributes [ DontEnum, + DontDelete, ReadOnly] - This tests the DontDelete attribute. + This tests the DontDelete attribute. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.3.1-4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the String Constructor"; +var SECTION = "15.5.3.1-4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Constructor"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "delete( String.prototype );String.prototype", String.prototype, eval("delete ( String.prototype );String.prototype") ); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "delete( String.prototype );String.prototype", String.prototype, eval("delete ( String.prototype );String.prototype") ); - return ( array ); -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.3.2-1.js b/mozilla/js/tests/ecma/String/15.5.3.2-1.js index c15cca56979..ba831884e47 100644 --- a/mozilla/js/tests/ecma/String/15.5.3.2-1.js +++ b/mozilla/js/tests/ecma/String/15.5.3.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,177 +35,154 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.3.2-1.js - ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) - Description: Return a string value containing as many characters - as the number of arguments. Each argument specifies - one character of the resulting string, with the first - argument specifying the first character, and so on, - from left to right. An argument is converted to a - character by applying the operation ToUint16 and - regarding the resulting 16bit integeras the Unicode - encoding of a character. If no arguments are supplied, - the result is the empty string. + File Name: 15.5.3.2-1.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. - This test covers Basic Latin (range U+0020 - U+007F) + This test covers Basic Latin (range U+0020 - U+007F) - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.3.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.fromCharCode()"; +var SECTION = "15.5.3.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.fromCharCode()"; - writeHeaderToLog( SECTION + " "+ TITLE); +new TestCase( SECTION, "typeof String.fromCharCode", "function", typeof String.fromCharCode ); +new TestCase( SECTION, "typeof String.prototype.fromCharCode", "undefined", typeof String.prototype.fromCharCode ); +new TestCase( SECTION, "var x = new String(); typeof x.fromCharCode", "undefined", eval("var x = new String(); typeof x.fromCharCode") ); +new TestCase( SECTION, "String.fromCharCode.length", 1, String.fromCharCode.length ); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "String.fromCharCode()", "", String.fromCharCode() ); +new TestCase( SECTION, "String.fromCharCode(0x0020)", " ", String.fromCharCode(0x0020) ); +new TestCase( SECTION, "String.fromCharCode(0x0021)", "!", String.fromCharCode(0x0021) ); +new TestCase( SECTION, "String.fromCharCode(0x0022)", "\"", String.fromCharCode(0x0022) ); +new TestCase( SECTION, "String.fromCharCode(0x0023)", "#", String.fromCharCode(0x0023) ); +new TestCase( SECTION, "String.fromCharCode(0x0024)", "$", String.fromCharCode(0x0024) ); +new TestCase( SECTION, "String.fromCharCode(0x0025)", "%", String.fromCharCode(0x0025) ); +new TestCase( SECTION, "String.fromCharCode(0x0026)", "&", String.fromCharCode(0x0026) ); +new TestCase( SECTION, "String.fromCharCode(0x0027)", "\'", String.fromCharCode(0x0027) ); +new TestCase( SECTION, "String.fromCharCode(0x0028)", "(", String.fromCharCode(0x0028) ); +new TestCase( SECTION, "String.fromCharCode(0x0029)", ")", String.fromCharCode(0x0029) ); +new TestCase( SECTION, "String.fromCharCode(0x002A)", "*", String.fromCharCode(0x002A) ); +new TestCase( SECTION, "String.fromCharCode(0x002B)", "+", String.fromCharCode(0x002B) ); +new TestCase( SECTION, "String.fromCharCode(0x002C)", ",", String.fromCharCode(0x002C) ); +new TestCase( SECTION, "String.fromCharCode(0x002D)", "-", String.fromCharCode(0x002D) ); +new TestCase( SECTION, "String.fromCharCode(0x002E)", ".", String.fromCharCode(0x002E) ); +new TestCase( SECTION, "String.fromCharCode(0x002F)", "/", String.fromCharCode(0x002F) ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "String.fromCharCode(0x0030)", "0", String.fromCharCode(0x0030) ); +new TestCase( SECTION, "String.fromCharCode(0x0031)", "1", String.fromCharCode(0x0031) ); +new TestCase( SECTION, "String.fromCharCode(0x0032)", "2", String.fromCharCode(0x0032) ); +new TestCase( SECTION, "String.fromCharCode(0x0033)", "3", String.fromCharCode(0x0033) ); +new TestCase( SECTION, "String.fromCharCode(0x0034)", "4", String.fromCharCode(0x0034) ); +new TestCase( SECTION, "String.fromCharCode(0x0035)", "5", String.fromCharCode(0x0035) ); +new TestCase( SECTION, "String.fromCharCode(0x0036)", "6", String.fromCharCode(0x0036) ); +new TestCase( SECTION, "String.fromCharCode(0x0037)", "7", String.fromCharCode(0x0037) ); +new TestCase( SECTION, "String.fromCharCode(0x0038)", "8", String.fromCharCode(0x0038) ); +new TestCase( SECTION, "String.fromCharCode(0x0039)", "9", String.fromCharCode(0x0039) ); +new TestCase( SECTION, "String.fromCharCode(0x003A)", ":", String.fromCharCode(0x003A) ); +new TestCase( SECTION, "String.fromCharCode(0x003B)", ";", String.fromCharCode(0x003B) ); +new TestCase( SECTION, "String.fromCharCode(0x003C)", "<", String.fromCharCode(0x003C) ); +new TestCase( SECTION, "String.fromCharCode(0x003D)", "=", String.fromCharCode(0x003D) ); +new TestCase( SECTION, "String.fromCharCode(0x003E)", ">", String.fromCharCode(0x003E) ); +new TestCase( SECTION, "String.fromCharCode(0x003F)", "?", String.fromCharCode(0x003F) ); - array[item++] = new TestCase( SECTION, "typeof String.fromCharCode", "function", typeof String.fromCharCode ); - array[item++] = new TestCase( SECTION, "typeof String.prototype.fromCharCode", "undefined", typeof String.prototype.fromCharCode ); - array[item++] = new TestCase( SECTION, "var x = new String(); typeof x.fromCharCode", "undefined", eval("var x = new String(); typeof x.fromCharCode") ); - array[item++] = new TestCase( SECTION, "String.fromCharCode.length", 1, String.fromCharCode.length ); +new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); +new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); +new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); +new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); +new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); +new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); +new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); +new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); +new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); +new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); +new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); +new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); +new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); +new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); +new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); +new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode()", "", String.fromCharCode() ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0020)", " ", String.fromCharCode(0x0020) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0021)", "!", String.fromCharCode(0x0021) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0022)", "\"", String.fromCharCode(0x0022) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0023)", "#", String.fromCharCode(0x0023) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0024)", "$", String.fromCharCode(0x0024) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0025)", "%", String.fromCharCode(0x0025) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0026)", "&", String.fromCharCode(0x0026) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0027)", "\'", String.fromCharCode(0x0027) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0028)", "(", String.fromCharCode(0x0028) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0029)", ")", String.fromCharCode(0x0029) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002A)", "*", String.fromCharCode(0x002A) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002B)", "+", String.fromCharCode(0x002B) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002C)", ",", String.fromCharCode(0x002C) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002D)", "-", String.fromCharCode(0x002D) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002E)", ".", String.fromCharCode(0x002E) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x002F)", "/", String.fromCharCode(0x002F) ); +new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); +new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); +new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); +new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); +new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); +new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); +new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); +new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); +new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); +new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); +new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); +new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); +new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); +new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); +new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); +new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0030)", "0", String.fromCharCode(0x0030) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0031)", "1", String.fromCharCode(0x0031) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0032)", "2", String.fromCharCode(0x0032) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0033)", "3", String.fromCharCode(0x0033) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0034)", "4", String.fromCharCode(0x0034) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0035)", "5", String.fromCharCode(0x0035) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0036)", "6", String.fromCharCode(0x0036) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0037)", "7", String.fromCharCode(0x0037) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0038)", "8", String.fromCharCode(0x0038) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0039)", "9", String.fromCharCode(0x0039) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003A)", ":", String.fromCharCode(0x003A) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003B)", ";", String.fromCharCode(0x003B) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003C)", "<", String.fromCharCode(0x003C) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003D)", "=", String.fromCharCode(0x003D) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003E)", ">", String.fromCharCode(0x003E) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x003F)", "?", String.fromCharCode(0x003F) ); +new TestCase( SECTION, "String.fromCharCode(0x0050)", "P", String.fromCharCode(0x0050) ); +new TestCase( SECTION, "String.fromCharCode(0x0051)", "Q", String.fromCharCode(0x0051) ); +new TestCase( SECTION, "String.fromCharCode(0x0052)", "R", String.fromCharCode(0x0052) ); +new TestCase( SECTION, "String.fromCharCode(0x0053)", "S", String.fromCharCode(0x0053) ); +new TestCase( SECTION, "String.fromCharCode(0x0054)", "T", String.fromCharCode(0x0054) ); +new TestCase( SECTION, "String.fromCharCode(0x0055)", "U", String.fromCharCode(0x0055) ); +new TestCase( SECTION, "String.fromCharCode(0x0056)", "V", String.fromCharCode(0x0056) ); +new TestCase( SECTION, "String.fromCharCode(0x0057)", "W", String.fromCharCode(0x0057) ); +new TestCase( SECTION, "String.fromCharCode(0x0058)", "X", String.fromCharCode(0x0058) ); +new TestCase( SECTION, "String.fromCharCode(0x0059)", "Y", String.fromCharCode(0x0059) ); +new TestCase( SECTION, "String.fromCharCode(0x005A)", "Z", String.fromCharCode(0x005A) ); +new TestCase( SECTION, "String.fromCharCode(0x005B)", "[", String.fromCharCode(0x005B) ); +new TestCase( SECTION, "String.fromCharCode(0x005C)", "\\", String.fromCharCode(0x005C) ); +new TestCase( SECTION, "String.fromCharCode(0x005D)", "]", String.fromCharCode(0x005D) ); +new TestCase( SECTION, "String.fromCharCode(0x005E)", "^", String.fromCharCode(0x005E) ); +new TestCase( SECTION, "String.fromCharCode(0x005F)", "_", String.fromCharCode(0x005F) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); +new TestCase( SECTION, "String.fromCharCode(0x0060)", "`", String.fromCharCode(0x0060) ); +new TestCase( SECTION, "String.fromCharCode(0x0061)", "a", String.fromCharCode(0x0061) ); +new TestCase( SECTION, "String.fromCharCode(0x0062)", "b", String.fromCharCode(0x0062) ); +new TestCase( SECTION, "String.fromCharCode(0x0063)", "c", String.fromCharCode(0x0063) ); +new TestCase( SECTION, "String.fromCharCode(0x0064)", "d", String.fromCharCode(0x0064) ); +new TestCase( SECTION, "String.fromCharCode(0x0065)", "e", String.fromCharCode(0x0065) ); +new TestCase( SECTION, "String.fromCharCode(0x0066)", "f", String.fromCharCode(0x0066) ); +new TestCase( SECTION, "String.fromCharCode(0x0067)", "g", String.fromCharCode(0x0067) ); +new TestCase( SECTION, "String.fromCharCode(0x0068)", "h", String.fromCharCode(0x0068) ); +new TestCase( SECTION, "String.fromCharCode(0x0069)", "i", String.fromCharCode(0x0069) ); +new TestCase( SECTION, "String.fromCharCode(0x006A)", "j", String.fromCharCode(0x006A) ); +new TestCase( SECTION, "String.fromCharCode(0x006B)", "k", String.fromCharCode(0x006B) ); +new TestCase( SECTION, "String.fromCharCode(0x006C)", "l", String.fromCharCode(0x006C) ); +new TestCase( SECTION, "String.fromCharCode(0x006D)", "m", String.fromCharCode(0x006D) ); +new TestCase( SECTION, "String.fromCharCode(0x006E)", "n", String.fromCharCode(0x006E) ); +new TestCase( SECTION, "String.fromCharCode(0x006F)", "o", String.fromCharCode(0x006F) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0040)", "@", String.fromCharCode(0x0040) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0041)", "A", String.fromCharCode(0x0041) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0042)", "B", String.fromCharCode(0x0042) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0043)", "C", String.fromCharCode(0x0043) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0044)", "D", String.fromCharCode(0x0044) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0045)", "E", String.fromCharCode(0x0045) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0046)", "F", String.fromCharCode(0x0046) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0047)", "G", String.fromCharCode(0x0047) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0048)", "H", String.fromCharCode(0x0048) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0049)", "I", String.fromCharCode(0x0049) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004A)", "J", String.fromCharCode(0x004A) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004B)", "K", String.fromCharCode(0x004B) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004C)", "L", String.fromCharCode(0x004C) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004D)", "M", String.fromCharCode(0x004D) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004E)", "N", String.fromCharCode(0x004E) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x004F)", "O", String.fromCharCode(0x004F) ); +new TestCase( SECTION, "String.fromCharCode(0x0070)", "p", String.fromCharCode(0x0070) ); +new TestCase( SECTION, "String.fromCharCode(0x0071)", "q", String.fromCharCode(0x0071) ); +new TestCase( SECTION, "String.fromCharCode(0x0072)", "r", String.fromCharCode(0x0072) ); +new TestCase( SECTION, "String.fromCharCode(0x0073)", "s", String.fromCharCode(0x0073) ); +new TestCase( SECTION, "String.fromCharCode(0x0074)", "t", String.fromCharCode(0x0074) ); +new TestCase( SECTION, "String.fromCharCode(0x0075)", "u", String.fromCharCode(0x0075) ); +new TestCase( SECTION, "String.fromCharCode(0x0076)", "v", String.fromCharCode(0x0076) ); +new TestCase( SECTION, "String.fromCharCode(0x0077)", "w", String.fromCharCode(0x0077) ); +new TestCase( SECTION, "String.fromCharCode(0x0078)", "x", String.fromCharCode(0x0078) ); +new TestCase( SECTION, "String.fromCharCode(0x0079)", "y", String.fromCharCode(0x0079) ); +new TestCase( SECTION, "String.fromCharCode(0x007A)", "z", String.fromCharCode(0x007A) ); +new TestCase( SECTION, "String.fromCharCode(0x007B)", "{", String.fromCharCode(0x007B) ); +new TestCase( SECTION, "String.fromCharCode(0x007C)", "|", String.fromCharCode(0x007C) ); +new TestCase( SECTION, "String.fromCharCode(0x007D)", "}", String.fromCharCode(0x007D) ); +new TestCase( SECTION, "String.fromCharCode(0x007E)", "~", String.fromCharCode(0x007E) ); +// new TestCase( SECTION, "String.fromCharCode(0x0020, 0x007F)", "", String.fromCharCode(0x0040, 0x007F) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0050)", "P", String.fromCharCode(0x0050) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0051)", "Q", String.fromCharCode(0x0051) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0052)", "R", String.fromCharCode(0x0052) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0053)", "S", String.fromCharCode(0x0053) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0054)", "T", String.fromCharCode(0x0054) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0055)", "U", String.fromCharCode(0x0055) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0056)", "V", String.fromCharCode(0x0056) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0057)", "W", String.fromCharCode(0x0057) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0058)", "X", String.fromCharCode(0x0058) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0059)", "Y", String.fromCharCode(0x0059) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005A)", "Z", String.fromCharCode(0x005A) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005B)", "[", String.fromCharCode(0x005B) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005C)", "\\", String.fromCharCode(0x005C) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005D)", "]", String.fromCharCode(0x005D) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005E)", "^", String.fromCharCode(0x005E) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x005F)", "_", String.fromCharCode(0x005F) ); - - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0060)", "`", String.fromCharCode(0x0060) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0061)", "a", String.fromCharCode(0x0061) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0062)", "b", String.fromCharCode(0x0062) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0063)", "c", String.fromCharCode(0x0063) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0064)", "d", String.fromCharCode(0x0064) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0065)", "e", String.fromCharCode(0x0065) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0066)", "f", String.fromCharCode(0x0066) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0067)", "g", String.fromCharCode(0x0067) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0068)", "h", String.fromCharCode(0x0068) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0069)", "i", String.fromCharCode(0x0069) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006A)", "j", String.fromCharCode(0x006A) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006B)", "k", String.fromCharCode(0x006B) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006C)", "l", String.fromCharCode(0x006C) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006D)", "m", String.fromCharCode(0x006D) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006E)", "n", String.fromCharCode(0x006E) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x006F)", "o", String.fromCharCode(0x006F) ); - - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0070)", "p", String.fromCharCode(0x0070) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0071)", "q", String.fromCharCode(0x0071) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0072)", "r", String.fromCharCode(0x0072) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0073)", "s", String.fromCharCode(0x0073) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0074)", "t", String.fromCharCode(0x0074) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0075)", "u", String.fromCharCode(0x0075) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0076)", "v", String.fromCharCode(0x0076) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0077)", "w", String.fromCharCode(0x0077) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0078)", "x", String.fromCharCode(0x0078) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0079)", "y", String.fromCharCode(0x0079) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007A)", "z", String.fromCharCode(0x007A) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007B)", "{", String.fromCharCode(0x007B) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007C)", "|", String.fromCharCode(0x007C) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007D)", "}", String.fromCharCode(0x007D) ); - array[item++] = new TestCase( SECTION, "String.fromCharCode(0x007E)", "~", String.fromCharCode(0x007E) ); -// array[item++] = new TestCase( SECTION, "String.fromCharCode(0x0020, 0x007F)", "", String.fromCharCode(0x0040, 0x007F) ); - - return array; -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.3.2-2.js b/mozilla/js/tests/ecma/String/15.5.3.2-2.js index 4eb5f0eb2ff..53248fc3f12 100644 --- a/mozilla/js/tests/ecma/String/15.5.3.2-2.js +++ b/mozilla/js/tests/ecma/String/15.5.3.2-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,40 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.3.2-2.js - ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) - Description: Return a string value containing as many characters - as the number of arguments. Each argument specifies - one character of the resulting string, with the first - argument specifying the first character, and so on, - from left to right. An argument is converted to a - character by applying the operation ToUint16 and - regarding the resulting 16bit integeras the Unicode - encoding of a character. If no arguments are supplied, - the result is the empty string. - - This tests String.fromCharCode with multiple arguments. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ - - var SECTION = "15.5.3.2-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.fromCharCode()"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var MYSTRING = String.fromCharCode(eval(\"var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;\")); MYSTRING", - " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", - eval( "var MYSTRING = String.fromCharCode(" + eval("var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;") +"); MYSTRING" )); - - array[item++] = new TestCase( SECTION, - "MYSTRING.length", - 0x007f - 0x0020, - MYSTRING.length ); - return array; -} - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.5.3.2-2.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. + + This tests String.fromCharCode with multiple arguments. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ + +var SECTION = "15.5.3.2-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.fromCharCode()"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var MYSTRING = String.fromCharCode(eval(\"var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;\")); MYSTRING", + " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", + eval( "var MYSTRING = String.fromCharCode(" + eval("var args=''; for ( i = 0x0020; i < 0x007f; i++ ) { args += ( i == 0x007e ) ? i : i + ', '; } args;") +"); MYSTRING" )); + +new TestCase( SECTION, + "MYSTRING.length", + 0x007f - 0x0020, + MYSTRING.length ); + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.3.2-3.js b/mozilla/js/tests/ecma/String/15.5.3.2-3.js index 049ff205987..55aad4e4f5a 100644 --- a/mozilla/js/tests/ecma/String/15.5.3.2-3.js +++ b/mozilla/js/tests/ecma/String/15.5.3.2-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,104 +35,85 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.3.2-1.js - ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) - Description: Return a string value containing as many characters - as the number of arguments. Each argument specifies - one character of the resulting string, with the first - argument specifying the first character, and so on, - from left to right. An argument is converted to a - character by applying the operation ToUint16 and - regarding the resulting 16bit integeras the Unicode - encoding of a character. If no arguments are supplied, - the result is the empty string. + File Name: 15.5.3.2-1.js + ECMA Section: 15.5.3.2 String.fromCharCode( char0, char1, ... ) + Description: Return a string value containing as many characters + as the number of arguments. Each argument specifies + one character of the resulting string, with the first + argument specifying the first character, and so on, + from left to right. An argument is converted to a + character by applying the operation ToUint16 and + regarding the resulting 16bit integeras the Unicode + encoding of a character. If no arguments are supplied, + the result is the empty string. - This test covers Basic Latin (range U+0020 - U+007F) + This test covers Basic Latin (range U+0020 - U+007F) - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.3.2-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.fromCharCode()"; +var SECTION = "15.5.3.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.fromCharCode()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - for ( CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", - ToUint16(CHARCODE), - (String.fromCharCode(CHARCODE)).charCodeAt(0) - ); - } - for ( CHARCODE = 256; CHARCODE < 65536; CHARCODE+=333 ) { - array[item++] = new TestCase( SECTION, - "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", - ToUint16(CHARCODE), - (String.fromCharCode(CHARCODE)).charCodeAt(0) - ); - } - for ( CHARCODE = 65535; CHARCODE < 65538; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", - ToUint16(CHARCODE), - (String.fromCharCode(CHARCODE)).charCodeAt(0) - ); - } - for ( CHARCODE = Math.pow(2,32)-1; CHARCODE < Math.pow(2,32)+1; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", - ToUint16(CHARCODE), - (String.fromCharCode(CHARCODE)).charCodeAt(0) - ); - } - for ( CHARCODE = 0; CHARCODE > -65536; CHARCODE-=3333 ) { - array[item++] = new TestCase( SECTION, - "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", - ToUint16(CHARCODE), - (String.fromCharCode(CHARCODE)).charCodeAt(0) - ); - } - array[item++] = new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); - array[item++] = new TestCase( SECTION, "(String.fromCharCode(65536)).charCodeAt(0)", 0, (String.fromCharCode(65536)).charCodeAt(0) ); - array[item++] = new TestCase( SECTION, "(String.fromCharCode(65537)).charCodeAt(0)", 1, (String.fromCharCode(65537)).charCodeAt(0) ); - - return array; +for ( CHARCODE = 0; CHARCODE < 256; CHARCODE++ ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); } +for ( CHARCODE = 256; CHARCODE < 65536; CHARCODE+=333 ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +for ( CHARCODE = 65535; CHARCODE < 65538; CHARCODE++ ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +for ( CHARCODE = Math.pow(2,32)-1; CHARCODE < Math.pow(2,32)+1; CHARCODE++ ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +for ( CHARCODE = 0; CHARCODE > -65536; CHARCODE-=3333 ) { + new TestCase( SECTION, + "(String.fromCharCode(" + CHARCODE +")).charCodeAt(0)", + ToUint16(CHARCODE), + (String.fromCharCode(CHARCODE)).charCodeAt(0) + ); +} +new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); +new TestCase( SECTION, "(String.fromCharCode(65536)).charCodeAt(0)", 0, (String.fromCharCode(65536)).charCodeAt(0) ); +new TestCase( SECTION, "(String.fromCharCode(65537)).charCodeAt(0)", 1, (String.fromCharCode(65537)).charCodeAt(0) ); + +test(); + function ToUint16( num ) { - num = Number( num ); - if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { - return 0; - } + num = Number( num ); + if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { + return 0; + } - var sign = ( num < 0 ) ? -1 : 1; + var sign = ( num < 0 ) ? -1 : 1; - num = sign * Math.floor( Math.abs( num ) ); - num = num % Math.pow(2,16); - num = ( num > -65536 && num < 0) ? 65536 + num : num; - return num; + num = sign * Math.floor( Math.abs( num ) ); + num = num % Math.pow(2,16); + num = ( num > -65536 && num < 0) ? 65536 + num : num; + return num; } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/String/15.5.3.js b/mozilla/js/tests/ecma/String/15.5.3.js index a19558c6342..b916ceb4396 100644 --- a/mozilla/js/tests/ecma/String/15.5.3.js +++ b/mozilla/js/tests/ecma/String/15.5.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,56 +35,32 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.3.1.js - ECMA Section: 15.5.3 Properties of the String Constructor + File Name: 15.5.3.1.js + ECMA Section: 15.5.3 Properties of the String Constructor - Description: The value of the internal [[Prototype]] property of - the String constructor is the Function prototype - object. + Description: The value of the internal [[Prototype]] property of + the String constructor is the Function prototype + object. - In addition to the internal [[Call]] and [[Construct]] - properties, the String constructor also has the length - property, as well as properties described in 15.5.3.1 - and 15.5.3.2. + In addition to the internal [[Call]] and [[Construct]] + properties, the String constructor also has the length + property, as well as properties described in 15.5.3.1 + and 15.5.3.2. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.3"; - var VERSION = "ECMA_2"; - startTest(); - var passed = true; - writeHeaderToLog( SECTION + " Properties of the String Constructor" ); +var SECTION = "15.5.3"; +var VERSION = "ECMA_2"; +startTest(); +var passed = true; +writeHeaderToLog( SECTION + " Properties of the String Constructor" ); - var testcases = getTestCases(); - var tc= 0; +new TestCase( SECTION, "String.prototype", Function.prototype, String.__proto__ ); -// all tests must call a function that returns an array of TestCase objects. - test( testcases ); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "String.prototype", Function.prototype, String.__proto__ ); - array[item++] = new TestCase( SECTION, "String.length", 1, String.length ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - - stopTest(); - - // all tests must return an array of TestCase objects - return ( testcases ); -} +new TestCase( SECTION, "String.length", 1, String.length ); +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.1.js b/mozilla/js/tests/ecma/String/15.5.4.1.js index f745952ee42..39fc412ac3d 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,26 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.1.js - ECMA Section: 15.5.4.1 String.prototype.constructor - - Description: - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - var SECTION = "15.5.4.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.constructor"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "String.prototype.constructor == String", true, String.prototype.constructor == String ); - array[item++] = new TestCase( SECTION, "var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()", - "[object String]", - eval("var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()") ); - return ( array ); -} -function test( array ) { - for ( ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - - stopTest(); - - // all tests must return an array of TestCase objects - return ( testcases ); -} +/** + File Name: 15.5.4.1.js + ECMA Section: 15.5.4.1 String.prototype.constructor + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.5.4.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.constructor"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.constructor == String", true, String.prototype.constructor == String ); + +new TestCase( SECTION, "var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()", + "[object String]", + eval("var STRING = new String.prototype.constructor('hi'); STRING.getClass = Object.prototype.toString; STRING.getClass()") ); + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.10-1.js b/mozilla/js/tests/ecma/String/15.5.4.10-1.js index c2bb005f55a..b93236b96a5 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.10-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.10-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,200 +35,181 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.10-1.js - ECMA Section: 15.5.4.10 String.prototype.substring( start, end ) - Description: + File Name: 15.5.4.10-1.js + ECMA Section: 15.5.4.10 String.prototype.substring( start, end ) + Description: - 15.5.4.10 String.prototype.substring(start, end) + 15.5.4.10 String.prototype.substring(start, end) - Returns a substring of the result of converting this object to a string, - starting from character position start and running to character position - end of the string. The result is a string value, not a String object. + Returns a substring of the result of converting this object to a string, + starting from character position start and running to character position + end of the string. The result is a string value, not a String object. - If either argument is NaN or negative, it is replaced with zero; if either - argument is larger than the length of the string, it is replaced with the - length of the string. + If either argument is NaN or negative, it is replaced with zero; if either + argument is larger than the length of the string, it is replaced with the + length of the string. - If start is larger than end, they are swapped. + If start is larger than end, they are swapped. - When the substring method is called with two arguments start and end, the - following steps are taken: + When the substring method is called with two arguments start and end, the + following steps are taken: - 1. Call ToString, giving it the this value as its argument. - 2. Call ToInteger(start). - 3. Call ToInteger (end). - 4. Compute the number of characters in Result(1). - 5. Compute min(max(Result(2), 0), Result(4)). - 6. Compute min(max(Result(3), 0), Result(4)). - 7. Compute min(Result(5), Result(6)). - 8. Compute max(Result(5), Result(6)). - 9. Return a string whose length is the difference between Result(8) and - Result(7), containing characters from Result(1), namely the characters - with indices Result(7) through Result(8)1, in ascending order. + 1. Call ToString, giving it the this value as its argument. + 2. Call ToInteger(start). + 3. Call ToInteger (end). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(2), 0), Result(4)). + 6. Compute min(max(Result(3), 0), Result(4)). + 7. Compute min(Result(5), Result(6)). + 8. Compute max(Result(5), Result(6)). + 9. Return a string whose length is the difference between Result(8) and + Result(7), containing characters from Result(1), namely the characters + with indices Result(7) through Result(8)1, in ascending order. - Note that the substring function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the substring function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.10-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.substring( start, end )"; +var SECTION = "15.5.4.10-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.substring( start, end )"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); +new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); +new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); -function getTestCases() { - var array = new Array(); - var item = 0; +// test cases for when substring is called with no arguments. - array[item++] = new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); +// this is a string object - // test cases for when substring is called with no arguments. +new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.substring()", + "string", + eval("var s = new String('this is a string object'); typeof s.substring()") ); - // this is a string object +new TestCase( SECTION, + "var s = new String(''); s.substring(1,0)", + "", + eval("var s = new String(''); s.substring(1,0)") ); - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); typeof s.substring()", - "string", - eval("var s = new String('this is a string object'); typeof s.substring()") ); +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(true, false)", + "t", + eval("var s = new String('this is a string object'); s.substring(false, true)") ); - array[item++] = new TestCase( SECTION, - "var s = new String(''); s.substring(1,0)", - "", - eval("var s = new String(''); s.substring(1,0)") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(true, false)", - "t", - eval("var s = new String('this is a string object'); s.substring(false, true)") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(NaN, Infinity)", - "this is a string object", - eval("var s = new String('this is a string object'); s.substring(NaN, Infinity)") ); +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(NaN, Infinity)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(NaN, Infinity)") ); - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(Infinity, NaN)", - "this is a string object", - eval("var s = new String('this is a string object'); s.substring(Infinity, NaN)") ); +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity, NaN)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(Infinity, NaN)") ); - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(Infinity, Infinity)", - "", - eval("var s = new String('this is a string object'); s.substring(Infinity, Infinity)") ); +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity, Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(Infinity, Infinity)") ); - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(-0.01, 0)", - "", - eval("var s = new String('this is a string object'); s.substring(-0.01,0)") ); +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-0.01, 0)", + "", + eval("var s = new String('this is a string object'); s.substring(-0.01,0)") ); - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(s.length, s.length)", - "", - eval("var s = new String('this is a string object'); s.substring(s.length, s.length)") ); +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length, s.length)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length, s.length)") ); - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(s.length+1, 0)", - "this is a string object", - eval("var s = new String('this is a string object'); s.substring(s.length+1, 0)") ); +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length+1, 0)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(s.length+1, 0)") ); - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)", - "", - eval("var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)") ); +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(-Infinity, -Infinity)") ); - // this is not a String object, start is not an integer +// this is not a String object, start is not an integer - array[item++] = new TestCase( SECTION, - "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)", - "1,2,3,4,5", - eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)") ); +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)", + "1,2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(Infinity,-Infinity)") ); - array[item++] = new TestCase( SECTION, - "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)", - "1", - eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)") ); +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)", + "1", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true, false)") ); - array[item++] = new TestCase( SECTION, - "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')", - "3", - eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')") ); +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')", + "3", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4', '5')") ); - // this is an object object - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)", - "[object ", - eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)") ); +// this is an object object +new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)", + "[object ", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,0)") ); - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,obj.toString().length)", - "Object]", - eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8, obj.toString().length)") ); +new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8,obj.toString().length)", + "Object]", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8, obj.toString().length)") ); - // this is a function object - array[item++] = new TestCase( SECTION, - "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8, Infinity)", - "Function]", - eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8,Infinity)") ); - // this is a number object - array[item++] = new TestCase( SECTION, - "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)", - "NaN", - eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)") ); +// this is a function object +new TestCase( SECTION, + "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8, Infinity)", + "Function]", + eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8,Infinity)") ); +// this is a number object +new TestCase( SECTION, + "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)", + "NaN", + eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(Infinity, NaN)") ); - // this is the Math object - array[item++] = new TestCase( SECTION, - "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)", - "[ob", - eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)") ); +// this is the Math object +new TestCase( SECTION, + "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)", + "[ob", + eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI, -10)") ); - // this is a Boolean object +// this is a Boolean object - array[item++] = new TestCase( SECTION, - "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))", - "f", - eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))") ); +new TestCase( SECTION, + "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))", + "f", + eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array(), new Boolean(1))") ); - // this is a user defined object +// this is a user defined object - array[item++] = new TestCase( SECTION, - "var obj = new MyObject( void 0 ); obj.substring(0, 100)", - "undefined", - eval( "var obj = new MyObject( void 0 ); obj.substring(0,100)") ); +new TestCase( SECTION, + "var obj = new MyObject( void 0 ); obj.substring(0, 100)", + "undefined", + eval( "var obj = new MyObject( void 0 ); obj.substring(0,100)") ); - return array; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); -} \ No newline at end of file + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.11-1.js b/mozilla/js/tests/ecma/String/15.5.4.11-1.js index 4cf10671bd5..559febc131b 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.11-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.11-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,500 +36,480 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.11-1.js - ECMA Section: 15.5.4.11 String.prototype.toLowerCase() - Description: + File Name: 15.5.4.11-1.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toLowerCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.11-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toLowerCase()"; +var SECTION = "15.5.4.11-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); +new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); +new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); - - // Basic Latin, Latin-1 Supplement, Latin Extended A - for ( var i = 0; i <= 0x017f; i++ ) { - var U = new Unicode(i); +// Basic Latin, Latin-1 Supplement, Latin Extended A +for ( var i = 0; i <= 0x017f; i++ ) { + var U = new Unicode(i); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", - String.fromCharCode(U.lower), - eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", - U.lower, - eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); - } - - return array; } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.11-2.js b/mozilla/js/tests/ecma/String/15.5.4.11-2.js index 570154e6ef1..08d1888d740 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.11-2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.11-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,497 +36,477 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.11-2.js - ECMA Section: 15.5.4.11 String.prototype.toLowerCase() - Description: + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toLowerCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.11-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toLowerCase()"; +var SECTION = "15.5.4.11-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // Georgian - // Range: U+10A0 to U+10FF - for ( var i = 0x10A0; i <= 0x10FF; i++ ) { - var U = new Unicode( i ); +// Georgian +// Range: U+10A0 to U+10FF +for ( var i = 0x10A0; i <= 0x10FF; i++ ) { + var U = new Unicode( i ); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", - String.fromCharCode(U.lower), - eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", - U.lower, - eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); - } - - return array; + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.11-3.js b/mozilla/js/tests/ecma/String/15.5.4.11-3.js index ba0bbab65b9..b6757ce2f4a 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.11-3.js +++ b/mozilla/js/tests/ecma/String/15.5.4.11-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,495 +36,476 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.11-2.js - ECMA Section: 15.5.4.11 String.prototype.toLowerCase() - Description: + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toLowerCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.11-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toLowerCase()"; +var SECTION = "15.5.4.11-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { - var U = new Unicode(i); +// Halfwidth and Fullwidth Forms +// Range: U+FF00 to U+FFEF +for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { + var U = new Unicode(i); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", - String.fromCharCode(U.lower), - eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", - U.lower, - eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); - } - - return array; + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.11-4.js b/mozilla/js/tests/ecma/String/15.5.4.11-4.js index 7c6a662a725..b0c6b510ec2 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.11-4.js +++ b/mozilla/js/tests/ecma/String/15.5.4.11-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,489 +36,469 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.11-2.js - ECMA Section: 15.5.4.11 String.prototype.toLowerCase() - Description: + File Name: 15.5.4.11-2.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toLowerCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.11-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toLowerCase()"; +var SECTION = "15.5.4.11-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// Hiragana (no upper / lower case) +// Range: U+3040 to U+309F -function getTestCases() { - var array = new Array(); - var item = 0; - - // Hiragana (no upper / lower case) - // Range: U+3040 to U+309F - - for ( var i = 0x3040; i <= 0x309F; i++ ) { - var U = new Unicode( i ); +for ( var i = 0x3040; i <= 0x309F; i++ ) { + var U = new Unicode( i ); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", - String.fromCharCode(U.lower), - eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", - U.lower, - eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); - } - - return array; + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { + this.upper = c; + this.lower = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + this.upper = c; + this.lower = c + 32; + return this; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + this.upper = c - 32; + this.lower = c; + return this; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + this.upper = c - 32; + this.lower = c; + return this; + } + if ( c == 0x00FF ) { + this.upper = 0x0178; + this.lower = c; + return this; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + this.upper = c; + this.lower = 0x0069; + return this; + } + if ( c == 0x0131 ) { + this.upper = 0x0049; + this.lower = c; + return this; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + this.upper = c; + this.lower = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + this.upper = c-1; + this.lower = c; + } + return this; + } + if ( c == 0x0178 ) { + this.upper = c; + this.lower = 0x00FF; + return this; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + this.upper = c; + this.lower = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + this.upper = c-1; + this.lower = c; + } + return this; + } + if ( c == 0x017F ) { + this.upper = 0x0053; + this.lower = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + this.upper = c; + this.lower = c+1; + } else { + this.upper = c-1; + this.lower = c; + } + return this; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + this.upper = c; + this.lower = c + 80; + return this; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + this.upper = c - 32; + this.lower = c; + return this; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + this.upper = c -80; + this.lower = c; + return this; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + this.upper = c; + this.lower = c +1; + } else { + this.upper = c - 1; + this.lower = c; + } + return this; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + this.upper = c; + this.lower = c + 48; + return this; + } + if ( c >= 0x0561 && c < 0x0587 ) { + this.upper = c - 48; + this.lower = c; + return this; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + this.upper = c; + this.lower = c + 48; + return this; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { this.upper = c; this.lower = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - this.upper = c; - this.lower = c + 32; - return this; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - this.upper = c - 32; - this.lower = c; - return this; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - this.upper = c; - this.lower = c + 32; - return this; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - this.upper = c - 32; - this.lower = c; - return this; - } - if ( c == 0x00FF ) { - this.upper = 0x0178; - this.lower = c; - return this; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - this.upper = c; - this.lower = 0x0069; - return this; - } - if ( c == 0x0131 ) { - this.upper = 0x0049; - this.lower = c; - return this; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - this.upper = c; - this.lower = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - this.upper = c-1; - this.lower = c; - } - return this; - } - if ( c == 0x0178 ) { - this.upper = c; - this.lower = 0x00FF; - return this; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - this.upper = c; - this.lower = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - this.upper = c-1; - this.lower = c; - } - return this; - } - if ( c == 0x017F ) { - this.upper = 0x0053; - this.lower = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - this.upper = c; - this.lower = c+1; - } else { - this.upper = c-1; - this.lower = c; - } - return this; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - this.upper = c; - this.lower = c + 80; - return this; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - this.upper = c; - this.lower = c + 32; - return this; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - this.upper = c - 32; - this.lower = c; - return this; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - this.upper = c -80; - this.lower = c; - return this; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - this.upper = c; - this.lower = c +1; - } else { - this.upper = c - 1; - this.lower = c; - } - return this; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - this.upper = c; - this.lower = c + 48; - return this; - } - if ( c >= 0x0561 && c < 0x0587 ) { - this.upper = c - 48; - this.lower = c; - return this; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - this.upper = c; - this.lower = c + 48; - return this; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - this.upper = c; - this.lower = c; - return this; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - this.upper = c; - this.lower = c + 32; - return this; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - this.upper = c - 32; - this.lower = c; - return this; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return this; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + this.upper = c; + this.lower = c + 32; + return this; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + this.upper = c - 32; + this.lower = c; + return this; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return this; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.11-5.js b/mozilla/js/tests/ecma/String/15.5.4.11-5.js index 6167eccba8a..ef42eccacd3 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.11-5.js +++ b/mozilla/js/tests/ecma/String/15.5.4.11-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,500 +36,482 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.11-5.js - ECMA Section: 15.5.4.11 String.prototype.toLowerCase() - Description: + File Name: 15.5.4.11-5.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toLowerCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.11-5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toLowerCase()"; +var SECTION = "15.5.4.11-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); - array[item++] = new TestCase( SECTION, "String.prototype.toLowerCase.length", 0, String.prototype.toLowerCase.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length", false, delete String.prototype.toLowerCase.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); +new TestCase( SECTION, "delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length", 0, eval("delete String.prototype.toLowerCase.length; String.prototype.toLowerCase.length") ); - // Cyrillic (part) - // Range: U+0400 to U+04FF - for ( var i = 0x0400; i <= 0x047F; i++ ) { - var U = new Unicode( i ); +// Cyrillic (part) +// Range: U+0400 to U+04FF +for ( var i = 0x0400; i <= 0x047F; i++ ) { + var U = new Unicode( i ); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", - String.fromCharCode(U.lower), - eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", - U.lower, - eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); - - } - return array; + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.11-6.js b/mozilla/js/tests/ecma/String/15.5.4.11-6.js index d1faa89fecd..84e8e20893a 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.11-6.js +++ b/mozilla/js/tests/ecma/String/15.5.4.11-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,497 +36,478 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.11-6.js - ECMA Section: 15.5.4.11 String.prototype.toLowerCase() - Description: + File Name: 15.5.4.11-6.js + ECMA Section: 15.5.4.11 String.prototype.toLowerCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toLowerCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toLowerCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.11-6"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toLowerCase()"; +var SECTION = "15.5.4.11-6"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toLowerCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// Armenian +// Range: U+0530 to U+058F +for ( var i = 0x0530; i <= 0x058F; i++ ) { -function getTestCases() { - var array = new Array(); - var item = 0; - - // Armenian - // Range: U+0530 to U+058F - for ( var i = 0x0530; i <= 0x058F; i++ ) { - - var U = new Unicode( i ); + var U = new Unicode( i ); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", - String.fromCharCode(U.lower), - eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()", + String.fromCharCode(U.lower), + eval("var s = new String( String.fromCharCode("+i+") ); s.toLowerCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", - U.lower, - eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toLowerCase().charCodeAt(0)", + U.lower, + eval("var s = new String( String.fromCharCode(i) ); s.toLowerCase().charCodeAt(0)") ); - } - return array; } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.12-1.js b/mozilla/js/tests/ecma/String/15.5.4.12-1.js index 2f1f17ef5dd..a728cc16a90 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.12-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.12-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,501 +36,482 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.12-1.js - ECMA Section: 15.5.4.12 String.prototype.toUpperCase() - Description: + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toUpperCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.12-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toUpperCase()"; +var SECTION = "15.5.4.12-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "String.prototype.toUpperCase.length", 0, String.prototype.toUpperCase.length ); +new TestCase( SECTION, "delete String.prototype.toUpperCase.length", false, delete String.prototype.toUpperCase.length ); +new TestCase( SECTION, "delete String.prototype.toupperCase.length; String.prototype.toupperCase.length", 0, eval("delete String.prototype.toUpperCase.length; String.prototype.toUpperCase.length") ); -function getTestCases() { - var array = new Array(); - var item = 0; +// Basic Latin, Latin-1 Supplement, Latin Extended A +for ( var i = 0; i <= 0x017f; i++ ) { + var U = new Unicode( i ); - array[item++] = new TestCase( SECTION, "String.prototype.toUpperCase.length", 0, String.prototype.toUpperCase.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.toUpperCase.length", false, delete String.prototype.toUpperCase.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.toupperCase.length; String.prototype.toupperCase.length", 0, eval("delete String.prototype.toUpperCase.length; String.prototype.toUpperCase.length") ); + // XXX DF fails in java - // Basic Latin, Latin-1 Supplement, Latin Extended A - for ( var i = 0; i <= 0x017f; i++ ) { - var U = new Unicode( i ); - - // XXX DF fails in java - - if ( i == 0x00DF ) { - continue; - } + if ( i == 0x00DF ) { + continue; + } - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", - U.upper, - eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); - } - - return array; + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.12-2.js b/mozilla/js/tests/ecma/String/15.5.4.12-2.js index d0294565788..7fe8fbc0d87 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.12-2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.12-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,500 +36,480 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.12-2.js - ECMA Section: 15.5.4.12 String.prototype.toUpperCase() - Description: + File Name: 15.5.4.12-2.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toUpperCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.12-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toUpperCase()"; +var SECTION = "15.5.4.12-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var TEST_STRING = ""; +var EXPECT_STRING = ""; -function getTestCases() { - var array = new Array(); - var item = 0; +// basic latin test - var TEST_STRING = ""; - var EXPECT_STRING = ""; - - // basic latin test - - for ( var i = 0; i < 0x007A; i++ ) { - var u = new Unicode(i); - TEST_STRING += String.fromCharCode(i); - EXPECT_STRING += String.fromCharCode( u.upper ); - } - - // don't print out the value of the strings since they contain control - // characters that break the driver - var isEqual = EXPECT_STRING == (new String( TEST_STRING )).toUpperCase(); - - array[item++] = new TestCase( SECTION, - "isEqual", - true, - isEqual); - return array; +for ( var i = 0; i < 0x007A; i++ ) { + var u = new Unicode(i); + TEST_STRING += String.fromCharCode(i); + EXPECT_STRING += String.fromCharCode( u.upper ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +// don't print out the value of the strings since they contain control +// characters that break the driver +var isEqual = EXPECT_STRING == (new String( TEST_STRING )).toUpperCase(); + +new TestCase( SECTION, + "isEqual", + true, + isEqual); +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; + return h; } diff --git a/mozilla/js/tests/ecma/String/15.5.4.12-3.js b/mozilla/js/tests/ecma/String/15.5.4.12-3.js index 24ef4a103ae..8c0d3833be8 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.12-3.js +++ b/mozilla/js/tests/ecma/String/15.5.4.12-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,542 +36,521 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.12-3.js - ECMA Section: 15.5.4.12 String.prototype.toUpperCase() - Description: + File Name: 15.5.4.12-3.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toUpperCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.12-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toUpperCase()"; +var SECTION = "15.5.4.12-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // Georgian - // Range: U+10A0 to U+10FF - for ( var i = 0x10A0; i <= 0x10FF; i++ ) { - var U = new Unicode( i ); +// Georgian +// Range: U+10A0 to U+10FF +for ( var i = 0x10A0; i <= 0x10FF; i++ ) { + var U = new Unicode( i ); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", - String.fromCharCode(U.upper), - eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + String.fromCharCode(U.upper), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", - U.upper, - eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); - } +} - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", - eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), - eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +// Halfwidth and Fullwidth Forms +// Range: U+FF00 to U+FFEF +for ( var i = 0xFF00; i <= 0xFFEF; i++ ) { + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", - eval( "var u = new Unicode( i ); u.upper" ), - eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); - } + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + eval( "var u = new Unicode( i ); u.upper" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); +} - // Hiragana (no upper / lower case) - // Range: U+3040 to U+309F +// Hiragana (no upper / lower case) +// Range: U+3040 to U+309F - for ( var i = 0x3040; i <= 0x309F; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", - eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), - eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); +for ( var i = 0x3040; i <= 0x309F; i++ ) { + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + eval( "var u = new Unicode( i ); String.fromCharCode(u.upper)" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", - eval( "var u = new Unicode( i ); u.upper" ), - eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); - } + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + eval( "var u = new Unicode( i ); u.upper" ), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)") ); +} /* - var TEST_STRING = ""; - var EXPECT_STRING = ""; + var TEST_STRING = ""; + var EXPECT_STRING = ""; - // basic latin test + // basic latin test - for ( var i = 0; i < 0x007A; i++ ) { - var u = new Unicode(i); - TEST_STRING += String.fromCharCode(i); - EXPECT_STRING += String.fromCharCode( u.upper ); - } + for ( var i = 0; i < 0x007A; i++ ) { + var u = new Unicode(i); + TEST_STRING += String.fromCharCode(i); + EXPECT_STRING += String.fromCharCode( u.upper ); + } */ +test(); - return array; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.12-4.js b/mozilla/js/tests/ecma/String/15.5.4.12-4.js index fa891f357d1..61f9d7b3f74 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.12-4.js +++ b/mozilla/js/tests/ecma/String/15.5.4.12-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,497 +36,477 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.12-1.js - ECMA Section: 15.5.4.12 String.prototype.toUpperCase() - Description: + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toUpperCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.12-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toUpperCase()"; +var SECTION = "15.5.4.12-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // Cyrillic (part) - // Range: U+0400 to U+04FF - for ( var i = 0x0400; i <= 0x047F; i++ ) { - var U =new Unicode( i ); +// Cyrillic (part) +// Range: U+0400 to U+04FF +for ( var i = 0x0400; i <= 0x047F; i++ ) { + var U =new Unicode( i ); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", - U.upper, - eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + U.upper, + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", - U.upper, - eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); - } - - return array; } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.12-5.js b/mozilla/js/tests/ecma/String/15.5.4.12-5.js index 6d4ff0da59b..a7588ef0a84 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.12-5.js +++ b/mozilla/js/tests/ecma/String/15.5.4.12-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,497 +36,477 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.12-1.js - ECMA Section: 15.5.4.12 String.prototype.toUpperCase() - Description: + File Name: 15.5.4.12-1.js + ECMA Section: 15.5.4.12 String.prototype.toUpperCase() + Description: - Returns a string equal in length to the length of the result of converting - this object to a string. The result is a string value, not a String object. + Returns a string equal in length to the length of the result of converting + this object to a string. The result is a string value, not a String object. - Every character of the result is equal to the corresponding character of the - string, unless that character has a Unicode 2.0 uppercase equivalent, in which - case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case - mapping shall be used, which does not depend on implementation or locale.) + Every character of the result is equal to the corresponding character of the + string, unless that character has a Unicode 2.0 uppercase equivalent, in which + case the uppercase equivalent is used instead. (The canonical Unicode 2.0 case + mapping shall be used, which does not depend on implementation or locale.) - Note that the toUpperCase function is intentionally generic; it does not require - that its this value be a String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the toUpperCase function is intentionally generic; it does not require + that its this value be a String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.12-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toUpperCase()"; +var SECTION = "15.5.4.12-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toUpperCase()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - // Armenian - // Range: U+0530 to U+058F - for ( var i = 0x0530; i <= 0x058F; i++ ) { - var U = new Unicode( i ); +// Armenian +// Range: U+0530 to U+058F +for ( var i = 0x0530; i <= 0x058F; i++ ) { + var U = new Unicode( i ); /* - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", - String.fromCharCode(U.upper), - eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()", + String.fromCharCode(U.upper), + eval("var s = new String( String.fromCharCode("+i+") ); s.toUpperCase()") ); */ - array[item++] = new TestCase( SECTION, - "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", - U.upper, - eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); + new TestCase( SECTION, + "var s = new String( String.fromCharCode("+i+") ); s.toUpperCase().charCodeAt(0)", + U.upper, + eval("var s = new String( String.fromCharCode(i) ); s.toUpperCase().charCodeAt(0)") ); - } - - return array; } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); + function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); } function Unicode( c ) { - u = GetUnicodeValues( c ); - this.upper = u[0]; - this.lower = u[1] + u = GetUnicodeValues( c ); + this.upper = u[0]; + this.lower = u[1] return this; } function GetUnicodeValues( c ) { - u = new Array(); + u = new Array(); + u[0] = c; + u[1] = c; + + // upper case Basic Latin + + if ( c >= 0x0041 && c <= 0x005A) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Basic Latin + if ( c >= 0x0061 && c <= 0x007a ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // upper case Latin-1 Supplement + if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + // lower case Latin-1 Supplement + if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { + u[0] = c - 32; + u[1] = c; + return u; + } + if ( c == 0x00FF ) { + u[0] = 0x0178; + u[1] = c; + return u; + } + // Latin Extended A + if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { + // special case for capital I + if ( c == 0x0130 ) { + u[0] = c; + u[1] = 0x0069; + return u; + } + if ( c == 0x0131 ) { + u[0] = 0x0049; + u[1] = c; + return u; + } + + if ( c % 2 == 0 ) { + // if it's even, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's odd, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x0178 ) { + u[0] = c; + u[1] = 0x00FF; + return u; + } + + if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { + if ( c % 2 == 1 ) { + // if it's odd, it's a capital and the lower case is c +1 + u[0] = c; + u[1] = c+1; + } else { + // if it's even, it's a lower case and upper case is c-1 + u[0] = c-1; + u[1] = c; + } + return u; + } + if ( c == 0x017F ) { + u[0] = 0x0053; + u[1] = c; + } + + // Latin Extended B + // need to improve this set + + if ( c >= 0x0200 && c <= 0x0217 ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c+1; + } else { + u[0] = c-1; + u[1] = c; + } + return u; + } + + // Latin Extended Additional + // Range: U+1E00 to U+1EFF + // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html + + // Spacing Modifier Leters + // Range: U+02B0 to U+02FF + + // Combining Diacritical Marks + // Range: U+0300 to U+036F + + // skip Greek for now + // Greek + // Range: U+0370 to U+03FF + + // Cyrillic + // Range: U+0400 to U+04FF + + if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { + u[0] = c; + u[1] = c + 80; + return u; + } + + + if ( c >= 0x0410 && c <= 0x042F ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0x0430 && c<= 0x044F ) { + u[0] = c - 32; + u[1] = c; + return u; + + } + if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { + u[0] = c -80; + u[1] = c; + return u; + } + + if ( c >= 0x0460 && c <= 0x047F ) { + if ( c % 2 == 0 ) { + u[0] = c; + u[1] = c +1; + } else { + u[0] = c - 1; + u[1] = c; + } + return u; + } + + // Armenian + // Range: U+0530 to U+058F + if ( c >= 0x0531 && c <= 0x0556 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x0561 && c < 0x0587 ) { + u[0] = c - 48; + u[1] = c; + return u; + } + + // Hebrew + // Range: U+0590 to U+05FF + + + // Arabic + // Range: U+0600 to U+06FF + + // Devanagari + // Range: U+0900 to U+097F + + + // Bengali + // Range: U+0980 to U+09FF + + + // Gurmukhi + // Range: U+0A00 to U+0A7F + + + // Gujarati + // Range: U+0A80 to U+0AFF + + + // Oriya + // Range: U+0B00 to U+0B7F + // no capital / lower case + + + // Tamil + // Range: U+0B80 to U+0BFF + // no capital / lower case + + + // Telugu + // Range: U+0C00 to U+0C7F + // no capital / lower case + + + // Kannada + // Range: U+0C80 to U+0CFF + // no capital / lower case + + + // Malayalam + // Range: U+0D00 to U+0D7F + + // Thai + // Range: U+0E00 to U+0E7F + + + // Lao + // Range: U+0E80 to U+0EFF + + + // Tibetan + // Range: U+0F00 to U+0FBF + + // Georgian + // Range: U+10A0 to U+10F0 + if ( c >= 0x10A0 && c <= 0x10C5 ) { + u[0] = c; + u[1] = c + 48; + return u; + } + if ( c >= 0x10D0 && c <= 0x10F5 ) { u[0] = c; u[1] = c; - - // upper case Basic Latin - - if ( c >= 0x0041 && c <= 0x005A) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Basic Latin - if ( c >= 0x0061 && c <= 0x007a ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // upper case Latin-1 Supplement - if ( (c >= 0x00C0 && c <= 0x00D6) || (c >= 0x00D8 && c<=0x00DE) ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - // lower case Latin-1 Supplement - if ( (c >= 0x00E0 && c <= 0x00F6) || (c >= 0x00F8 && c <= 0x00FE) ) { - u[0] = c - 32; - u[1] = c; - return u; - } - if ( c == 0x00FF ) { - u[0] = 0x0178; - u[1] = c; - return u; - } - // Latin Extended A - if ( (c >= 0x0100 && c < 0x0138) || (c > 0x0149 && c < 0x0178) ) { - // special case for capital I - if ( c == 0x0130 ) { - u[0] = c; - u[1] = 0x0069; - return u; - } - if ( c == 0x0131 ) { - u[0] = 0x0049; - u[1] = c; - return u; - } - - if ( c % 2 == 0 ) { - // if it's even, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's odd, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x0178 ) { - u[0] = c; - u[1] = 0x00FF; - return u; - } - - if ( (c >= 0x0139 && c < 0x0149) || (c > 0x0178 && c < 0x017F) ) { - if ( c % 2 == 1 ) { - // if it's odd, it's a capital and the lower case is c +1 - u[0] = c; - u[1] = c+1; - } else { - // if it's even, it's a lower case and upper case is c-1 - u[0] = c-1; - u[1] = c; - } - return u; - } - if ( c == 0x017F ) { - u[0] = 0x0053; - u[1] = c; - } - - // Latin Extended B - // need to improve this set - - if ( c >= 0x0200 && c <= 0x0217 ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c+1; - } else { - u[0] = c-1; - u[1] = c; - } - return u; - } - - // Latin Extended Additional - // Range: U+1E00 to U+1EFF - // http://www.unicode.org/Unicode.charts/glyphless/U1E00.html - - // Spacing Modifier Leters - // Range: U+02B0 to U+02FF - - // Combining Diacritical Marks - // Range: U+0300 to U+036F - - // skip Greek for now - // Greek - // Range: U+0370 to U+03FF - - // Cyrillic - // Range: U+0400 to U+04FF - - if ( (c >= 0x0401 && c <= 0x040C) || ( c>= 0x040E && c <= 0x040F ) ) { - u[0] = c; - u[1] = c + 80; - return u; - } - - - if ( c >= 0x0410 && c <= 0x042F ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0x0430 && c<= 0x044F ) { - u[0] = c - 32; - u[1] = c; - return u; - - } - if ( (c >= 0x0451 && c <= 0x045C) || (c >=0x045E && c<= 0x045F) ) { - u[0] = c -80; - u[1] = c; - return u; - } - - if ( c >= 0x0460 && c <= 0x047F ) { - if ( c % 2 == 0 ) { - u[0] = c; - u[1] = c +1; - } else { - u[0] = c - 1; - u[1] = c; - } - return u; - } - - // Armenian - // Range: U+0530 to U+058F - if ( c >= 0x0531 && c <= 0x0556 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x0561 && c < 0x0587 ) { - u[0] = c - 48; - u[1] = c; - return u; - } - - // Hebrew - // Range: U+0590 to U+05FF - - - // Arabic - // Range: U+0600 to U+06FF - - // Devanagari - // Range: U+0900 to U+097F - - - // Bengali - // Range: U+0980 to U+09FF - - - // Gurmukhi - // Range: U+0A00 to U+0A7F - - - // Gujarati - // Range: U+0A80 to U+0AFF - - - // Oriya - // Range: U+0B00 to U+0B7F - // no capital / lower case - - - // Tamil - // Range: U+0B80 to U+0BFF - // no capital / lower case - - - // Telugu - // Range: U+0C00 to U+0C7F - // no capital / lower case - - - // Kannada - // Range: U+0C80 to U+0CFF - // no capital / lower case - - - // Malayalam - // Range: U+0D00 to U+0D7F - - // Thai - // Range: U+0E00 to U+0E7F - - - // Lao - // Range: U+0E80 to U+0EFF - - - // Tibetan - // Range: U+0F00 to U+0FBF - - // Georgian - // Range: U+10A0 to U+10F0 - if ( c >= 0x10A0 && c <= 0x10C5 ) { - u[0] = c; - u[1] = c + 48; - return u; - } - if ( c >= 0x10D0 && c <= 0x10F5 ) { - u[0] = c; - u[1] = c; - return u; - } - - // Hangul Jamo - // Range: U+1100 to U+11FF - - // Greek Extended - // Range: U+1F00 to U+1FFF - // skip for now - - - // General Punctuation - // Range: U+2000 to U+206F - - // Superscripts and Subscripts - // Range: U+2070 to U+209F - - // Currency Symbols - // Range: U+20A0 to U+20CF - - - // Combining Diacritical Marks for Symbols - // Range: U+20D0 to U+20FF - // skip for now - - - // Number Forms - // Range: U+2150 to U+218F - // skip for now - - - // Arrows - // Range: U+2190 to U+21FF - - // Mathematical Operators - // Range: U+2200 to U+22FF - - // Miscellaneous Technical - // Range: U+2300 to U+23FF - - // Control Pictures - // Range: U+2400 to U+243F - - // Optical Character Recognition - // Range: U+2440 to U+245F - - // Enclosed Alphanumerics - // Range: U+2460 to U+24FF - - // Box Drawing - // Range: U+2500 to U+257F - - // Block Elements - // Range: U+2580 to U+259F - - // Geometric Shapes - // Range: U+25A0 to U+25FF - - // Miscellaneous Symbols - // Range: U+2600 to U+26FF - - // Dingbats - // Range: U+2700 to U+27BF - - // CJK Symbols and Punctuation - // Range: U+3000 to U+303F - - // Hiragana - // Range: U+3040 to U+309F - - // Katakana - // Range: U+30A0 to U+30FF - - // Bopomofo - // Range: U+3100 to U+312F - - // Hangul Compatibility Jamo - // Range: U+3130 to U+318F - - // Kanbun - // Range: U+3190 to U+319F - - - // Enclosed CJK Letters and Months - // Range: U+3200 to U+32FF - - // CJK Compatibility - // Range: U+3300 to U+33FF - - // Hangul Syllables - // Range: U+AC00 to U+D7A3 - - // High Surrogates - // Range: U+D800 to U+DB7F - - // Private Use High Surrogates - // Range: U+DB80 to U+DBFF - - // Low Surrogates - // Range: U+DC00 to U+DFFF - - // Private Use Area - // Range: U+E000 to U+F8FF - - // CJK Compatibility Ideographs - // Range: U+F900 to U+FAFF - - // Alphabetic Presentation Forms - // Range: U+FB00 to U+FB4F - - // Arabic Presentation Forms-A - // Range: U+FB50 to U+FDFF - - // Combining Half Marks - // Range: U+FE20 to U+FE2F - - // CJK Compatibility Forms - // Range: U+FE30 to U+FE4F - - // Small Form Variants - // Range: U+FE50 to U+FE6F - - // Arabic Presentation Forms-B - // Range: U+FE70 to U+FEFF - - // Halfwidth and Fullwidth Forms - // Range: U+FF00 to U+FFEF - - if ( c >= 0xFF21 && c <= 0xFF3A ) { - u[0] = c; - u[1] = c + 32; - return u; - } - - if ( c >= 0xFF41 && c <= 0xFF5A ) { - u[0] = c - 32; - u[1] = c; - return u; - } - - // Specials - // Range: U+FFF0 to U+FFFF - return u; + } + + // Hangul Jamo + // Range: U+1100 to U+11FF + + // Greek Extended + // Range: U+1F00 to U+1FFF + // skip for now + + + // General Punctuation + // Range: U+2000 to U+206F + + // Superscripts and Subscripts + // Range: U+2070 to U+209F + + // Currency Symbols + // Range: U+20A0 to U+20CF + + + // Combining Diacritical Marks for Symbols + // Range: U+20D0 to U+20FF + // skip for now + + + // Number Forms + // Range: U+2150 to U+218F + // skip for now + + + // Arrows + // Range: U+2190 to U+21FF + + // Mathematical Operators + // Range: U+2200 to U+22FF + + // Miscellaneous Technical + // Range: U+2300 to U+23FF + + // Control Pictures + // Range: U+2400 to U+243F + + // Optical Character Recognition + // Range: U+2440 to U+245F + + // Enclosed Alphanumerics + // Range: U+2460 to U+24FF + + // Box Drawing + // Range: U+2500 to U+257F + + // Block Elements + // Range: U+2580 to U+259F + + // Geometric Shapes + // Range: U+25A0 to U+25FF + + // Miscellaneous Symbols + // Range: U+2600 to U+26FF + + // Dingbats + // Range: U+2700 to U+27BF + + // CJK Symbols and Punctuation + // Range: U+3000 to U+303F + + // Hiragana + // Range: U+3040 to U+309F + + // Katakana + // Range: U+30A0 to U+30FF + + // Bopomofo + // Range: U+3100 to U+312F + + // Hangul Compatibility Jamo + // Range: U+3130 to U+318F + + // Kanbun + // Range: U+3190 to U+319F + + + // Enclosed CJK Letters and Months + // Range: U+3200 to U+32FF + + // CJK Compatibility + // Range: U+3300 to U+33FF + + // Hangul Syllables + // Range: U+AC00 to U+D7A3 + + // High Surrogates + // Range: U+D800 to U+DB7F + + // Private Use High Surrogates + // Range: U+DB80 to U+DBFF + + // Low Surrogates + // Range: U+DC00 to U+DFFF + + // Private Use Area + // Range: U+E000 to U+F8FF + + // CJK Compatibility Ideographs + // Range: U+F900 to U+FAFF + + // Alphabetic Presentation Forms + // Range: U+FB00 to U+FB4F + + // Arabic Presentation Forms-A + // Range: U+FB50 to U+FDFF + + // Combining Half Marks + // Range: U+FE20 to U+FE2F + + // CJK Compatibility Forms + // Range: U+FE30 to U+FE4F + + // Small Form Variants + // Range: U+FE50 to U+FE6F + + // Arabic Presentation Forms-B + // Range: U+FE70 to U+FEFF + + // Halfwidth and Fullwidth Forms + // Range: U+FF00 to U+FFEF + + if ( c >= 0xFF21 && c <= 0xFF3A ) { + u[0] = c; + u[1] = c + 32; + return u; + } + + if ( c >= 0xFF41 && c <= 0xFF5A ) { + u[0] = c - 32; + u[1] = c; + return u; + } + + // Specials + // Range: U+FFF0 to U+FFFF + + return u; } function DecimalToHexString( n ) { - n = Number( n ); - var h = "0x"; + n = Number( n ); + var h = "0x"; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; -} \ No newline at end of file + return h; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.2-1.js b/mozilla/js/tests/ecma/String/15.5.4.2-1.js index 6797d0b6803..c3b97b415b9 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.2-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.2-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.2-1.js - ECMA Section: 15.5.4.2 String.prototype.toString() + File Name: 15.5.4.2-1.js + ECMA Section: 15.5.4.2 String.prototype.toString() - Description: Returns this string value. Note that, for a String - object, the toString() method happens to return the same - thing as the valueOf() method. + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. - The toString function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.4.2-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toString"; +var SECTION = "15.5.4.2-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toString"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); +new TestCase( SECTION, "(new String()).toString()", "", (new String()).toString() ); +new TestCase( SECTION, "(new String(\"\")).toString()", "", (new String("")).toString() ); +new TestCase( SECTION, "(new String( String() )).toString()","", (new String(String())).toString() ); +new TestCase( SECTION, "(new String( \"h e l l o\" )).toString()", "h e l l o", (new String("h e l l o")).toString() ); +new TestCase( SECTION, "(new String( 0 )).toString()", "0", (new String(0)).toString() ); -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); - array[item++] = new TestCase( SECTION, "(new String()).toString()", "", (new String()).toString() ); - array[item++] = new TestCase( SECTION, "(new String(\"\")).toString()", "", (new String("")).toString() ); - array[item++] = new TestCase( SECTION, "(new String( String() )).toString()","", (new String(String())).toString() ); - array[item++] = new TestCase( SECTION, "(new String( \"h e l l o\" )).toString()", "h e l l o", (new String("h e l l o")).toString() ); - array[item++] = new TestCase( SECTION, "(new String( 0 )).toString()", "0", (new String(0)).toString() ); - return ( array ); -} -function test( array ) { - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.2-2-n.js b/mozilla/js/tests/ecma/String/15.5.4.2-2-n.js index 023d93ad9e9..1447e659fec 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.2-2-n.js +++ b/mozilla/js/tests/ecma/String/15.5.4.2-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,56 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.2-2-n.js - ECMA Section: 15.5.4.2 String.prototype.toString() + File Name: 15.5.4.2-2-n.js + ECMA Section: 15.5.4.2 String.prototype.toString() - Description: Returns this string value. Note that, for a String - object, the toString() method happens to return the same - thing as the valueOf() method. + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. - The toString function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.4.2-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toString"; +var SECTION = "15.5.4.2-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toString"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()"; +EXPECTED = "error"; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()", + "error", + eval("var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()") ); - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()", - "error", - "var tostr=String.prototype.toString; astring=new Number(); astring.toString = tostr; astring.toString()" ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.2-3.js b/mozilla/js/tests/ecma/String/15.5.4.2-3.js index bce392116c1..7ff264fce96 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.2-3.js +++ b/mozilla/js/tests/ecma/String/15.5.4.2-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,69 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.2-3.js - ECMA Section: 15.5.4.2 String.prototype.toString() + File Name: 15.5.4.2-3.js + ECMA Section: 15.5.4.2 String.prototype.toString() - Description: Returns this string value. Note that, for a String - object, the toString() method happens to return the same - thing as the valueOf() method. + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. - The toString function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.4.2-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.toString"; +var SECTION = "15.5.4.2-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.toString"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()", + "", + eval("var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()") ); +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()", + "0", + eval("var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()") ); +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()", + "hello", + eval("var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()") ); +new TestCase( SECTION, + "var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()", + "", + eval("var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()") ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - - testcases[tc].actual = eval( testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()", - "", - "var tostr=String.prototype.toString; astring=new String(); astring.toString = tostr; astring.toString()" ); - array[item++] = new TestCase( SECTION, - "var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()", - "0", - "var tostr=String.prototype.toString; astring=new String(0); astring.toString = tostr; astring.toString()" ); - array[item++] = new TestCase( SECTION, - "var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()", - "hello", - "var tostr=String.prototype.toString; astring=new String('hello'); astring.toString = tostr; astring.toString()" ); - array[item++] = new TestCase( SECTION, - "var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()", - "", - "var tostr=String.prototype.toString; astring=new String(''); astring.toString = tostr; astring.toString()" ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.2.js b/mozilla/js/tests/ecma/String/15.5.4.2.js index 9d1ff32a405..60b380db006 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,74 +35,51 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.2.js - ECMA Section: 15.5.4.2 String.prototype.toString - - Description: - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - var SECTION = "15.5.4.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.tostring"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "String.prototype.toString.__proto__", Function.prototype, String.prototype.toString.__proto__ ); - array[item++] = new TestCase( SECTION, - "String.prototype.toString() == String.prototype.valueOf()", - true, - String.prototype.toString() == String.prototype.valueOf() ); - - array[item++] = new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); - array[item++] = new TestCase( SECTION, "String.prototype.toString.length", 0, String.prototype.toString.length ); - - - array[item++] = new TestCase( SECTION, - "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", - true, - eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, - "TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()", - true, - eval("TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, - "TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()", - true, - eval("TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, - "TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()", - true, - eval("TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()") ); - array[item++] = new TestCase( SECTION, - "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", - true, - eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); - - return ( array ); -} -function test( array ) { - for ( ; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - - stopTest(); - - // all tests must return an array of TestCase objects - return ( testcases ); -} +/** + File Name: 15.5.4.2.js + ECMA Section: 15.5.4.2 String.prototype.toString + + Description: + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var SECTION = "15.5.4.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.tostring"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.toString.__proto__", Function.prototype, String.prototype.toString.__proto__ ); +new TestCase( SECTION, + "String.prototype.toString() == String.prototype.valueOf()", + true, + String.prototype.toString() == String.prototype.valueOf() ); + +new TestCase( SECTION, "String.prototype.toString()", "", String.prototype.toString() ); +new TestCase( SECTION, "String.prototype.toString.length", 0, String.prototype.toString.length ); + + +new TestCase( SECTION, + "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); +new TestCase( SECTION, + "TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(true);TESTSTRING.valueOf() == TESTSTRING.toString()") ); +new TestCase( SECTION, + "TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(false);TESTSTRING.valueOf() == TESTSTRING.toString()") ); +new TestCase( SECTION, + "TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String(Math.PI);TESTSTRING.valueOf() == TESTSTRING.toString()") ); +new TestCase( SECTION, + "TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()", + true, + eval("TESTSTRING = new String();TESTSTRING.valueOf() == TESTSTRING.toString()") ); + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.3-1.js b/mozilla/js/tests/ecma/String/15.5.4.3-1.js index 8a1e742fb84..9abd617fc7f 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.3-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,52 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.3-1.js - ECMA Section: 15.5.4.3 String.prototype.valueOf() + File Name: 15.5.4.3-1.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() - Description: Returns this string value. + Description: Returns this string value. - The valueOf function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.4.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.valueOf"; +var SECTION = "15.5.4.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.valueOf"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, "String.prototype.valueOf.length", 0, String.prototype.valueOf.length ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); +new TestCase( SECTION, "(new String()).valueOf()", "", (new String()).valueOf() ); +new TestCase( SECTION, "(new String(\"\")).valueOf()", "", (new String("")).valueOf() ); +new TestCase( SECTION, "(new String( String() )).valueOf()","", (new String(String())).valueOf() ); +new TestCase( SECTION, "(new String( \"h e l l o\" )).valueOf()", "h e l l o", (new String("h e l l o")).valueOf() ); +new TestCase( SECTION, "(new String( 0 )).valueOf()", "0", (new String(0)).valueOf() ); - array[item++] = new TestCase( SECTION, "String.prototype.valueOf.length", 0, String.prototype.valueOf.length ); - - array[item++] = new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); - array[item++] = new TestCase( SECTION, "(new String()).valueOf()", "", (new String()).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String(\"\")).valueOf()", "", (new String("")).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String( String() )).valueOf()","", (new String(String())).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String( \"h e l l o\" )).valueOf()", "h e l l o", (new String("h e l l o")).valueOf() ); - array[item++] = new TestCase( SECTION, "(new String( 0 )).valueOf()", "0", (new String(0)).valueOf() ); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.3-2.js b/mozilla/js/tests/ecma/String/15.5.4.3-2.js index 123adfb78c6..f7172e9ce55 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.3-2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.3-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,71 +35,53 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.3-2.js - ECMA Section: 15.5.4.3 String.prototype.valueOf() - - Description: Returns this string value. - - The valueOf function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. - - Author: christine@netscape.com - Date: 1 october 1997 -*/ - - - var SECTION = "15.5.4.3-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.valueOf"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval(testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valof()", - "", - "var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valueOf()" ); - array[item++] = new TestCase( SECTION, - "var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valof()", - "0", - "var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valueOf()" ); - array[item++] = new TestCase( SECTION, - "var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valof()", - "hello", - "var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valueOf()" ); - array[item++] = new TestCase( SECTION, - "var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valof()", - "", - "var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valueOf()" ); -/* - array[item++] = new TestCase( SECTION, - "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", - "error", - "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()" ); -*/ - return ( array ); -} +/** + File Name: 15.5.4.3-2.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + + +var SECTION = "15.5.4.3-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.valueOf"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valof()", + "", + eval("var valof=String.prototype.valueOf; astring=new String(); astring.valueOf = valof; astring.valueOf()") ); + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valof()", + "0", + eval("var valof=String.prototype.valueOf; astring=new String(0); astring.valueOf = valof; astring.valueOf()") ); + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valof()", + "hello", + eval("var valof=String.prototype.valueOf; astring=new String('hello'); astring.valueOf = valof; astring.valueOf()") ); + +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valof()", + "", + eval("var valof=String.prototype.valueOf; astring=new String(''); astring.valueOf = valof; astring.valueOf()") ); +/* + new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", + "error", + eval("var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()") ); +*/ + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.3-3-n.js b/mozilla/js/tests/ecma/String/15.5.4.3-3-n.js index 09b6f762ce4..5c7a61ba1de 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.3-3-n.js +++ b/mozilla/js/tests/ecma/String/15.5.4.3-3-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.3-3-n.js - ECMA Section: 15.5.4.3 String.prototype.valueOf() + File Name: 15.5.4.3-3-n.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() - Description: Returns this string value. + Description: Returns this string value. - The valueOf function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "15.5.4.3-3-n"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.valueOf"; +var SECTION = "15.5.4.3-3-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.valueOf"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +DESCRIPTION = "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()"; +EXPECTED = "error"; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].actual = eval(testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, + "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", + "error", + eval("var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valof()", - "error", - "var valof=String.prototype.valueOf; astring=new Number(); astring.valueOf = valof; astring.valueOf()" ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.4-1.js b/mozilla/js/tests/ecma/String/15.5.4.4-1.js index 0410e264e9b..de1073d5d56 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.4-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,69 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.4-1.js - ECMA Section: 15.5.4.4 String.prototype.charAt(pos) - Description: Returns a string containing the character at position - pos in the string. If there is no character at that - string, the result is the empty string. The result is - a string value, not a String object. + File Name: 15.5.4.4-1.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. - When the charAt method is called with one argument, - pos, the following steps are taken: - 1. Call ToString, with this value as its argument - 2. Call ToInteger pos + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos - In this test, this is a String, pos is an integer, and - all pos are in range. + In this test, this is a String, pos is an integer, and + all pos are in range. - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.4.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.charAt"; +var SECTION = "15.5.4.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charAt"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); - var testcases = getTestCases(); - test(); +var item = 0; +var i; -function getTestCases() { - var array = new Array(); - var item = 0; - - for ( i = 0x0020; i < 0x007e; i++, item++) { - array[item] = new TestCase( SECTION, - "TEST_STRING.charAt("+item+")", - String.fromCharCode( i ), - TEST_STRING.charAt( item ) ); - } - for ( i = 0x0020; i < 0x007e; i++, item++) { - array[item] = new TestCase( SECTION, - "TEST_STRING.charAt("+item+") == TEST_STRING.substring( "+item +", "+ (item+1) + ")", - true, - TEST_STRING.charAt( item ) == TEST_STRING.substring( item, item+1 ) - ); - } - array[item++] = new TestCase( SECTION, "String.prototype.charAt.length", 1, String.prototype.charAt.length ); - - return array; +for ( i = 0x0020; i < 0x007e; i++, item++) { + new TestCase( SECTION, + "TEST_STRING.charAt("+item+")", + String.fromCharCode( i ), + TEST_STRING.charAt( item ) ); } -function test() { - writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - - return ( testcases ); +for ( i = 0x0020; i < 0x007e; i++, item++) { + new TestCase( SECTION, + "TEST_STRING.charAt("+item+") == TEST_STRING.substring( "+item +", "+ (item+1) + ")", + true, + TEST_STRING.charAt( item ) == TEST_STRING.substring( item, item+1 ) + ); } + +new TestCase( SECTION, "String.prototype.charAt.length", 1, String.prototype.charAt.length ); + +writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + +test(); + diff --git a/mozilla/js/tests/ecma/String/15.5.4.4-2.js b/mozilla/js/tests/ecma/String/15.5.4.4-2.js index 4845afbace1..1a905ff72e1 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.4-2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.4-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,123 +35,99 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.4-1.js - ECMA Section: 15.5.4.4 String.prototype.charAt(pos) - Description: Returns a string containing the character at position - pos in the string. If there is no character at that - string, the result is the empty string. The result is - a string value, not a String object. - - When the charAt method is called with one argument, - pos, the following steps are taken: - 1. Call ToString, with this value as its argument - 2. Call ToInteger pos - 3. Compute the number of characters in Result(1) - 4. If Result(2) is less than 0 is or not less than - Result(3), return the empty string - 5. Return a string of length 1 containing one character - from result (1), the character at position Result(2). - - Note that the charAt function is intentionally generic; - it does not require that its this value be a String - object. Therefore it can be transferred to other kinds - of objects for use as a method. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ - var SECTION = "15.5.4.4-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.charAt"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)", "u", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)", "e", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)") ); - - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)") ); - - array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(0)", "", eval("x=new String();x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(1)", "", eval("x=new String();x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(-1)", "", eval("x=new String();x.charAt(-1)") ); - - array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(NaN)", "", eval("x=new String();x.charAt(Number.NaN)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(Number.POSITIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.POSITIVE_INFINITY)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charAt(Number.NEGATIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.NEGATIVE_INFINITY)") ); - - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(0)", "1", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(0)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(1)", "2", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(1)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(2)", "3", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(2)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(3)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(3)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(4)", "5", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(4)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(5)", "6", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(5)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(6)", "7", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(6)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(7)", "8", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(7)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(8)", "9", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(8)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(9)", "0", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(9)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(10)", "", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(10)") ); - - array[item++] = new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)") ); - - // MyOtherObject.toString will return "[object Object] - - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)", "[", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)", "o", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)", " ", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)", "O", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)") ); - array[item++] = new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)", "]", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)") ); - - return (array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value " - } - - stopTest(); - return ( testcases ); -} - -function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return this.value +''" ); - this.charAt = String.prototype.charAt; -} -function MyOtherObject(value) { - this.value = value; - this.valueOf = new Function( "return this.value;" ); - this.charAt = String.prototype.charAt; -} +/** + File Name: 15.5.4.4-1.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.4-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(0)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(1)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)", "u", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(2)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)", "e", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(3)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(4)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)", "", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(-1)") ); + +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)", "r", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(true)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)", "t", eval("x = new Boolean(true); x.charAt=String.prototype.charAt;x.charAt(false)") ); + +new TestCase( SECTION, "x = new String(); x.charAt(0)", "", eval("x=new String();x.charAt(0)") ); +new TestCase( SECTION, "x = new String(); x.charAt(1)", "", eval("x=new String();x.charAt(1)") ); +new TestCase( SECTION, "x = new String(); x.charAt(-1)", "", eval("x=new String();x.charAt(-1)") ); + +new TestCase( SECTION, "x = new String(); x.charAt(NaN)", "", eval("x=new String();x.charAt(Number.NaN)") ); +new TestCase( SECTION, "x = new String(); x.charAt(Number.POSITIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.POSITIVE_INFINITY)") ); +new TestCase( SECTION, "x = new String(); x.charAt(Number.NEGATIVE_INFINITY)", "", eval("x=new String();x.charAt(Number.NEGATIVE_INFINITY)") ); + +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(0)", "1", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(0)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(1)", "2", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(1)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(2)", "3", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(2)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(3)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(3)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(4)", "5", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(4)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(5)", "6", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(5)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(6)", "7", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(6)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(7)", "8", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(7)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(8)", "9", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(8)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(9)", "0", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(9)") ); +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(10)", "", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(10)") ); + +new TestCase( SECTION, "var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)", "4", eval("var MYOB = new MyObject(1234567890); MYOB.charAt(Math.PI)") ); + +// MyOtherObject.toString will return "[object Object] + +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)", "[", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(0)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)", "o", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(1)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(2)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(3)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(4)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(5)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(6)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)", " ", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(7)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)", "O", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(8)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)", "b", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(9)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)", "j", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(10)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)", "e", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(11)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)", "c", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(12)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)", "t", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(13)") ); +new TestCase( SECTION, "var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)", "]", eval("var MYOB = new MyOtherObject(1234567890); MYOB.charAt(14)") ); + +test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return this.value +''" ); + this.charAt = String.prototype.charAt; +} +function MyOtherObject(value) { + this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.charAt = String.prototype.charAt; +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.4-3.js b/mozilla/js/tests/ecma/String/15.5.4.4-3.js index c98aa4e9fc9..5ffd0909dff 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.4-3.js +++ b/mozilla/js/tests/ecma/String/15.5.4.4-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,99 +35,75 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.4-3.js - ECMA Section: 15.5.4.4 String.prototype.charAt(pos) - Description: Returns a string containing the character at position - pos in the string. If there is no character at that - string, the result is the empty string. The result is - a string value, not a String object. - - When the charAt method is called with one argument, - pos, the following steps are taken: - 1. Call ToString, with this value as its argument - 2. Call ToInteger pos - 3. Compute the number of characters in Result(1) - 4. If Result(2) is less than 0 is or not less than - Result(3), return the empty string - 5. Return a string of length 1 containing one character - from result (1), the character at position Result(2). - - Note that the charAt function is intentionally generic; - it does not require that its this value be a String - object. Therefore it can be transferred to other kinds - of objects for use as a method. - - This tests assiging charAt to a user-defined function. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ - var SECTION = "15.5.4.4-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.charAt"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function MyObject (v) { - this.value = v; - this.toString = new Function( "return this.value +'';" ); - this.valueOf = new Function( "return this.value" ); - this.charAt = String.prototype.charAt; -} -function getTestCases() { - var array = new Array(); - var item = 0; - - var foo = new MyObject('hello'); - - - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "h", foo.charAt(0) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "e", foo.charAt(1) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(2) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(3) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "o", foo.charAt(4) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(-1) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(5) ); - - var boo = new MyObject(true); - - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "t", boo.charAt(0) ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "r", boo.charAt(1) ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "u", boo.charAt(2) ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true); ", "e", boo.charAt(3) ); - - var noo = new MyObject( Math.PI ); - - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "3", noo.charAt(0) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", ".", noo.charAt(1) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(2) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "4", noo.charAt(3) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(4) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "5", noo.charAt(5) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "9", noo.charAt(6) ); - - return array; -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value " - } - stopTest(); - - // all tests must return a boolean value - return ( testcases ); -} +/** + File Name: 15.5.4.4-3.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. + + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). + + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. + + This tests assiging charAt to a user-defined function. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.4-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var foo = new MyObject('hello'); + + +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "h", foo.charAt(0) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "e", foo.charAt(1) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(2) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "l", foo.charAt(3) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "o", foo.charAt(4) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(-1) ); +new TestCase( SECTION, "var foo = new MyObject('hello'); ", "", foo.charAt(5) ); + +var boo = new MyObject(true); + +new TestCase( SECTION, "var boo = new MyObject(true); ", "t", boo.charAt(0) ); +new TestCase( SECTION, "var boo = new MyObject(true); ", "r", boo.charAt(1) ); +new TestCase( SECTION, "var boo = new MyObject(true); ", "u", boo.charAt(2) ); +new TestCase( SECTION, "var boo = new MyObject(true); ", "e", boo.charAt(3) ); + +var noo = new MyObject( Math.PI ); + +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "3", noo.charAt(0) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", ".", noo.charAt(1) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(2) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "4", noo.charAt(3) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "1", noo.charAt(4) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "5", noo.charAt(5) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); ", "9", noo.charAt(6) ); + +test(); + +function MyObject (v) { + this.value = v; + this.toString = new Function( "return this.value +'';" ); + this.valueOf = new Function( "return this.value" ); + this.charAt = String.prototype.charAt; +} + diff --git a/mozilla/js/tests/ecma/String/15.5.4.4-4.js b/mozilla/js/tests/ecma/String/15.5.4.4-4.js index feeb7630c9e..d4d178030d1 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.4-4.js +++ b/mozilla/js/tests/ecma/String/15.5.4.4-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,141 +35,119 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.4-4.js - ECMA Section: 15.5.4.4 String.prototype.charAt(pos) - Description: Returns a string containing the character at position - pos in the string. If there is no character at that - string, the result is the empty string. The result is - a string value, not a String object. + File Name: 15.5.4.4-4.js + ECMA Section: 15.5.4.4 String.prototype.charAt(pos) + Description: Returns a string containing the character at position + pos in the string. If there is no character at that + string, the result is the empty string. The result is + a string value, not a String object. - When the charAt method is called with one argument, - pos, the following steps are taken: - 1. Call ToString, with this value as its argument - 2. Call ToInteger pos - 3. Compute the number of characters in Result(1) - 4. If Result(2) is less than 0 is or not less than - Result(3), return the empty string - 5. Return a string of length 1 containing one character - from result (1), the character at position Result(2). + When the charAt method is called with one argument, + pos, the following steps are taken: + 1. Call ToString, with this value as its argument + 2. Call ToInteger pos + 3. Compute the number of characters in Result(1) + 4. If Result(2) is less than 0 is or not less than + Result(3), return the empty string + 5. Return a string of length 1 containing one character + from result (1), the character at position Result(2). - Note that the charAt function is intentionally generic; - it does not require that its this value be a String - object. Therefore it can be transferred to other kinds - of objects for use as a method. + Note that the charAt function is intentionally generic; + it does not require that its this value be a String + object. Therefore it can be transferred to other kinds + of objects for use as a method. - This tests assiging charAt to primitive types.. + This tests assiging charAt to primitive types.. - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.4.4-4"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "String.prototype.charAt"; +var SECTION = "15.5.4.4-4"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "String.prototype.charAt"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; /* - array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "n", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "u", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "n", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "u", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + new TestCase( SECTION, "x = null; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "l", eval("x=null; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); - array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "u", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "n", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "d", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); + new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "u", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); + new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "n", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); + new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "d", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); + new TestCase( SECTION, "x = undefined; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=undefined; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); */ - array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "f", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "s", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); - array[item++] = new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(4)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "f", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "l", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "s", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = false; x.__proto.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=false; x.__proto__.charAt = String.prototype.charAt; x.charAt(4)") ); - array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "t", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "r", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "u", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "t", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "r", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "u", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = true; x.__proto.charAt = String.prototype.charAt; x.charAt(3)", "e", eval("x=true; x.__proto__.charAt = String.prototype.charAt; x.charAt(3)") ); - array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "a", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = NaN; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "N", eval("x=NaN; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = 123; x.__proto.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=123; x.__proto__.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)", "2", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)", "3", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)", "2", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)", ",", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)", "3", eval("x=new Array(1,2,3); x.charAt = String.prototype.charAt; x.charAt(4)") ); - array[item++] = new TestCase( SECTION, "x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)", "", eval("x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)", "", eval("x = new Array(); x.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)", "1", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)", "2", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)", "3", eval("x=new Number(123); x.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(3)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(4)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(5)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(6)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(7)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(8)", "O", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(8)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(9)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(9)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(10)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(10)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(11)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(11)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(12)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(12)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(13)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(13)") ); - array[item++] = new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(14)", "]", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(14)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(4)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(5)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(6)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(7)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(8)", "O", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(8)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(9)", "b", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(9)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(10)", "j", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(10)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(11)", "e", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(11)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(12)", "c", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(12)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(13)", "t", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(13)") ); +new TestCase( SECTION, "x = new Object(); x.charAt = String.prototype.charAt; x.charAt(14)", "]", eval("x=new Object(); x.charAt = String.prototype.charAt; x.charAt(14)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)", "F", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)", "u", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)", "i", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)", "]", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)") ); - array[item++] = new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)", "", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)", "[", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(0)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(1)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)", "b", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(2)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)", "j", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(3)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)", "e", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(4)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(5)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(6)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)", " ", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(7)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)", "F", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(8)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)", "u", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(9)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(10)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)", "c", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(11)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)", "t", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(12)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)", "i", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(13)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)", "o", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(14)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)", "n", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(15)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)", "]", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(16)") ); +new TestCase( SECTION, "x = new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)", "", eval("x=new Function(); x.toString = Object.prototype.toString; x.charAt = String.prototype.charAt; x.charAt(17)") ); - return array; -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.5-1.js b/mozilla/js/tests/ecma/String/15.5.4.5-1.js index 96ba4d975de..7b4bb68964f 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.5-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.5-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,71 +35,50 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.5.1.js - ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) - Description: Returns a number (a nonnegative integer less than 2^16) - representing the Unicode encoding of the character at - position pos in this string. If there is no character - at that position, the number is NaN. - - When the charCodeAt method is called with one argument - pos, the following steps are taken: - 1. Call ToString, giving it the theis value as its - argument - 2. Call ToInteger(pos) - 3. Compute the number of characters in result(1). - 4. If Result(2) is less than 0 or is not less than - Result(3), return NaN. - 5. Return a value of Number type, of positive sign, whose - magnitude is the Unicode encoding of one character - from result 1, namely the characer at position Result - (2), where the first character in Result(1) is - considered to be at position 0. - - Note that the charCodeAt funciton is intentionally - generic; it does not require that its this value be a - String object. Therefore it can be transferred to other - kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ - var SECTION = "15.5.4.5-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.charCodeAt"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - - for ( j = 0, i = 0x0020; i < 0x007e; i++, j++ ) { - array[j] = new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", i, TEST_STRING.charCodeAt( j ) ); - } - - item = array.length; - - array[item++] = new TestCase( SECTION, 'TEST_STRING.charCodeAt('+i+')', NaN, TEST_STRING.charCodeAt( i ) ); - return array; -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - - return ( testcases ); -} +/** + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.5-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + +for ( j = 0, i = 0x0020; i < 0x007e; i++, j++ ) { + new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", i, TEST_STRING.charCodeAt( j ) ); +} + +new TestCase( SECTION, 'TEST_STRING.charCodeAt('+i+')', NaN, TEST_STRING.charCodeAt( i ) ); + + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.5-2.js b/mozilla/js/tests/ecma/String/15.5.4.5-2.js index b3e57381e19..2f6f1963049 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.5-2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,110 +35,84 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.5.1.js - ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) - Description: Returns a number (a nonnegative integer less than 2^16) - representing the Unicode encoding of the character at - position pos in this string. If there is no character - at that position, the number is NaN. - - When the charCodeAt method is called with one argument - pos, the following steps are taken: - 1. Call ToString, giving it the theis value as its - argument - 2. Call ToInteger(pos) - 3. Compute the number of characters in result(1). - 4. If Result(2) is less than 0 or is not less than - Result(3), return NaN. - 5. Return a value of Number type, of positive sign, whose - magnitude is the Unicode encoding of one character - from result 1, namely the characer at position Result - (2), where the first character in Result(1) is - considered to be at position 0. - - Note that the charCodeAt funciton is intentionally - generic; it does not require that its this value be a - String object. Therefore it can be transferred to other - kinds of objects for use as a method. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ - var SECTION = "15.5.4.5-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.charCodeAt"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); - - var testcases = getTestCases(); - - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - var x; - - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); - - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); - - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); - - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); - - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)", 0x0031, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)", 0x0032, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)", 0x0033, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)") ); - array[item++] = new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)", NaN, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)") ); - - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)", 0x005B, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)", 0x006F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)") ); - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)", 0x0065, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)") ); - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)", 0x0063, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)") ); - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)", 0x0074, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)") ); - - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)", 0x0020, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)") ); - - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)", 0x004F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)") ); - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)") ); - array[item++] = new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)") ); - - return (array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value " - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. + + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. + + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.5-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + +var x; + +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); + +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); + +new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); + +new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); + +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)", 0x0031, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)", 0x0032, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(2)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)", 0x002C, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(3)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)", 0x0033, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(4)") ); +new TestCase( SECTION, "x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)", NaN, eval("x = new Array(1,2,3); x.charCodeAt = String.prototype.charCodeAt; x.charCodeAt(5)") ); + +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)", 0x005B, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(0)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)", 0x006F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(1)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(2)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(3)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)", 0x0065, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(4)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)", 0x0063, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(5)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)", 0x0074, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(6)") ); + +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)", 0x0020, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(7)") ); + +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)", 0x004F, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(8)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)", 0x0062, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(9)") ); +new TestCase( SECTION, "x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)", 0x006A, eval("x = new Function( 'this.charCodeAt = String.prototype.charCodeAt' ); f = new x(); f.charCodeAt(10)") ); + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.5-3.js b/mozilla/js/tests/ecma/String/15.5.4.5-3.js index be178efdad8..0afa91ce548 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.5-3.js +++ b/mozilla/js/tests/ecma/String/15.5.4.5-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,118 +35,95 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.5-3.js - ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) - Description: Returns a number (a nonnegative integer less than 2^16) - representing the Unicode encoding of the character at - position pos in this string. If there is no character - at that position, the number is NaN. + File Name: 15.5.4.5-3.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. - When the charCodeAt method is called with one argument - pos, the following steps are taken: - 1. Call ToString, giving it the theis value as its - argument - 2. Call ToInteger(pos) - 3. Compute the number of characters in result(1). - 4. If Result(2) is less than 0 or is not less than - Result(3), return NaN. - 5. Return a value of Number type, of positive sign, whose - magnitude is the Unicode encoding of one character - from result 1, namely the characer at position Result - (2), where the first character in Result(1) is - considered to be at position 0. + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. - Note that the charCodeAt funciton is intentionally - generic; it does not require that its this value be a - String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.4.5-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.charCodeAt"; +var SECTION = "15.5.4.5-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + + +var foo = new MyObject('hello'); + +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(0)", 0x0068, foo.charCodeAt(0) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(1)", 0x0065, foo.charCodeAt(1) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(2)", 0x006c, foo.charCodeAt(2) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(3)", 0x006c, foo.charCodeAt(3) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(4)", 0x006f, foo.charCodeAt(4) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(-1)", Number.NaN, foo.charCodeAt(-1) ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(5)", Number.NaN, foo.charCodeAt(5) ); + +var boo = new MyObject(true); + +new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(0)", 0x0074, boo.charCodeAt(0) ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(1)", 0x0072, boo.charCodeAt(1) ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(2)", 0x0075, boo.charCodeAt(2) ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(3)", 0x0065, boo.charCodeAt(3) ); + +var noo = new MyObject( Math.PI ); + +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(0)", 0x0033, noo.charCodeAt(0) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(1)", 0x002E, noo.charCodeAt(1) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(2)", 0x0031, noo.charCodeAt(2) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(3)", 0x0034, noo.charCodeAt(3) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(4)", 0x0031, noo.charCodeAt(4) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(5)", 0x0035, noo.charCodeAt(5) ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(6)", 0x0039, noo.charCodeAt(6) ); + +var noo = new MyObject( null ); + +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(0)", 0x006E, noo.charCodeAt(0) ); +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(1)", 0x0075, noo.charCodeAt(1) ); +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(2)", 0x006C, noo.charCodeAt(2) ); +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(3)", 0x006C, noo.charCodeAt(3) ); +new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(4)", NaN, noo.charCodeAt(4) ); + +var noo = new MyObject( void 0 ); + +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(0)", 0x0075, noo.charCodeAt(0) ); +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(1)", 0x006E, noo.charCodeAt(1) ); +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(2)", 0x0064, noo.charCodeAt(2) ); +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(3)", 0x0065, noo.charCodeAt(3) ); +new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(4)", 0x0066, noo.charCodeAt(4) ); + +test(); - var testcases = getTestCases(); - test(); function MyObject (v) { - this.value = v; - this.toString = new Function ( "return this.value +\"\"" ); - this.charCodeAt = String.prototype.charCodeAt; -} - -function getTestCases() { - var array = new Array(); - var item = 0; - - var foo = new MyObject('hello'); - - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(0)", 0x0068, foo.charCodeAt(0) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(1)", 0x0065, foo.charCodeAt(1) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(2)", 0x006c, foo.charCodeAt(2) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(3)", 0x006c, foo.charCodeAt(3) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(4)", 0x006f, foo.charCodeAt(4) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(-1)", Number.NaN, foo.charCodeAt(-1) ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.charCodeAt(5)", Number.NaN, foo.charCodeAt(5) ); - - var boo = new MyObject(true); - - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(0)", 0x0074, boo.charCodeAt(0) ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(1)", 0x0072, boo.charCodeAt(1) ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(2)", 0x0075, boo.charCodeAt(2) ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.charCodeAt(3)", 0x0065, boo.charCodeAt(3) ); - - var noo = new MyObject( Math.PI ); - - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(0)", 0x0033, noo.charCodeAt(0) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(1)", 0x002E, noo.charCodeAt(1) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(2)", 0x0031, noo.charCodeAt(2) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(3)", 0x0034, noo.charCodeAt(3) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(4)", 0x0031, noo.charCodeAt(4) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(5)", 0x0035, noo.charCodeAt(5) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI);noo.charCodeAt(6)", 0x0039, noo.charCodeAt(6) ); - - var noo = new MyObject( null ); - - array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(0)", 0x006E, noo.charCodeAt(0) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(1)", 0x0075, noo.charCodeAt(1) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(2)", 0x006C, noo.charCodeAt(2) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(3)", 0x006C, noo.charCodeAt(3) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(null);noo.charCodeAt(4)", NaN, noo.charCodeAt(4) ); - - var noo = new MyObject( void 0 ); - - array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(0)", 0x0075, noo.charCodeAt(0) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(1)", 0x006E, noo.charCodeAt(1) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(2)", 0x0064, noo.charCodeAt(2) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(3)", 0x0065, noo.charCodeAt(3) ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(void 0);noo.charCodeAt(4)", 0x0066, noo.charCodeAt(4) ); - - return array; -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value "; - - } - stopTest(); - return ( testcases ); + this.value = v; + this.toString = new Function ( "return this.value +\"\"" ); + this.charCodeAt = String.prototype.charCodeAt; } diff --git a/mozilla/js/tests/ecma/String/15.5.4.5-4.js b/mozilla/js/tests/ecma/String/15.5.4.5-4.js index 918999ee645..00d0e24690f 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.5-4.js +++ b/mozilla/js/tests/ecma/String/15.5.4.5-4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.5-4.js - ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) - - Description: Returns a nonnegative integer less than 2^16. - - Author: christine@netscape.com - Date: 28 october 1997 - -*/ - var VERSION = "0697"; - startTest(); - var SECTION = "15.5.4.5-4"; - - writeHeaderToLog( SECTION + " String.prototype.charCodeAt(pos)" ); - var tc= 0; - var testcases = getTestCases(); - -// all tests must call a function that returns an array of TestCase objects. - test(); - -function getTestCases() { - var array = new Array(); - var MAXCHARCODE = Math.pow(2,16); - var item=0, CHARCODE; - - for ( CHARCODE=0; CHARCODE <256; CHARCODE++ ) { - array[item++] = new TestCase( SECTION, - "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", - CHARCODE, - (String.fromCharCode(CHARCODE)).charCodeAt(0) ); - } - for ( CHARCODE=256; CHARCODE < 65536; CHARCODE+=999 ) { - array[item++] = new TestCase( SECTION, - "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", - CHARCODE, - (String.fromCharCode(CHARCODE)).charCodeAt(0) ); - } - - array[item++] = new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); - - return ( array ); -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - - } - - stopTest(); - - // all tests must return an array of TestCase objects - return ( testcases ); -} +/** + File Name: 15.5.4.5-4.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + + Description: Returns a nonnegative integer less than 2^16. + + Author: christine@netscape.com + Date: 28 october 1997 + +*/ +var VERSION = "0697"; +startTest(); +var SECTION = "15.5.4.5-4"; + +writeHeaderToLog( SECTION + " String.prototype.charCodeAt(pos)" ); + +var MAXCHARCODE = Math.pow(2,16); +var item=0, CHARCODE; + +for ( CHARCODE=0; CHARCODE <256; CHARCODE++ ) { + new TestCase( SECTION, + "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", + CHARCODE, + (String.fromCharCode(CHARCODE)).charCodeAt(0) ); +} +for ( CHARCODE=256; CHARCODE < 65536; CHARCODE+=999 ) { + new TestCase( SECTION, + "(String.fromCharCode("+CHARCODE+")).charCodeAt(0)", + CHARCODE, + (String.fromCharCode(CHARCODE)).charCodeAt(0) ); +} + +new TestCase( SECTION, "(String.fromCharCode(65535)).charCodeAt(0)", 65535, (String.fromCharCode(65535)).charCodeAt(0) ); + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.5-5.js b/mozilla/js/tests/ecma/String/15.5.4.5-5.js index 7d3b60c1173..89c47d76f98 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.5-5.js +++ b/mozilla/js/tests/ecma/String/15.5.4.5-5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,70 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.5.1.js - ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) - Description: Returns a number (a nonnegative integer less than 2^16) - representing the Unicode encoding of the character at - position pos in this string. If there is no character - at that position, the number is NaN. + File Name: 15.5.4.5.1.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. - When the charCodeAt method is called with one argument - pos, the following steps are taken: - 1. Call ToString, giving it the theis value as its - argument - 2. Call ToInteger(pos) - 3. Compute the number of characters in result(1). - 4. If Result(2) is less than 0 or is not less than - Result(3), return NaN. - 5. Return a value of Number type, of positive sign, whose - magnitude is the Unicode encoding of one character - from result 1, namely the characer at position Result - (2), where the first character in Result(1) is - considered to be at position 0. + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. - Note that the charCodeAt funciton is intentionally - generic; it does not require that its this value be a - String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.4.5-5"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.charCodeAt"; +var SECTION = "15.5.4.5-5"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var TEST_STRING = ""; +var TEST_STRING = ""; - for ( var i = 0x0000; i < 255; i++ ) { - TEST_STRING += String.fromCharCode( i ); - } - - - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); - - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); - array[item++] = new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); - - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); - - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); - array[item++] = new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); - - for ( var j = 0; j < 255; j++ ) { - array[item++] = new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", j, TEST_STRING.charCodeAt(j) ); - } - return (array ); +for ( var i = 0x0000; i < 255; i++ ) { + TEST_STRING += String.fromCharCode( i ); } -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)", 0x0075, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(2)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)", 0x0065, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(3)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(4)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)", Number.NaN, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(-1)") ); - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value " - } - stopTest(); - return ( testcases ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)", 0x0072, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(true)") ); +new TestCase( SECTION, "x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)", 0x0074, eval("x = new Boolean(true); x.charCodeAt=String.prototype.charCodeAt;x.charCodeAt(false)") ); + +new TestCase( SECTION, "x = new String(); x.charCodeAt(0)", Number.NaN, eval("x=new String();x.charCodeAt(0)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(1)", Number.NaN, eval("x=new String();x.charCodeAt(1)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(-1)", Number.NaN, eval("x=new String();x.charCodeAt(-1)") ); + +new TestCase( SECTION, "x = new String(); x.charCodeAt(NaN)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NaN)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.POSITIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.POSITIVE_INFINITY)") ); +new TestCase( SECTION, "x = new String(); x.charCodeAt(Number.NEGATIVE_INFINITY)", Number.NaN, eval("x=new String();x.charCodeAt(Number.NEGATIVE_INFINITY)") ); + +for ( var j = 0; j < 255; j++ ) { + new TestCase( SECTION, "TEST_STRING.charCodeAt("+j+")", j, TEST_STRING.charCodeAt(j) ); } + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.5-6.js b/mozilla/js/tests/ecma/String/15.5.4.5-6.js index f0db4bdb842..aee62d51bfd 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.5-6.js +++ b/mozilla/js/tests/ecma/String/15.5.4.5-6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,79 +35,58 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.5-6.js - ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) - Description: Returns a number (a nonnegative integer less than 2^16) - representing the Unicode encoding of the character at - position pos in this string. If there is no character - at that position, the number is NaN. + File Name: 15.5.4.5-6.js + ECMA Section: 15.5.4.5 String.prototype.charCodeAt(pos) + Description: Returns a number (a nonnegative integer less than 2^16) + representing the Unicode encoding of the character at + position pos in this string. If there is no character + at that position, the number is NaN. - When the charCodeAt method is called with one argument - pos, the following steps are taken: - 1. Call ToString, giving it the theis value as its - argument - 2. Call ToInteger(pos) - 3. Compute the number of characters in result(1). - 4. If Result(2) is less than 0 or is not less than - Result(3), return NaN. - 5. Return a value of Number type, of positive sign, whose - magnitude is the Unicode encoding of one character - from result 1, namely the characer at position Result - (2), where the first character in Result(1) is - considered to be at position 0. + When the charCodeAt method is called with one argument + pos, the following steps are taken: + 1. Call ToString, giving it the theis value as its + argument + 2. Call ToInteger(pos) + 3. Compute the number of characters in result(1). + 4. If Result(2) is less than 0 or is not less than + Result(3), return NaN. + 5. Return a value of Number type, of positive sign, whose + magnitude is the Unicode encoding of one character + from result 1, namely the characer at position Result + (2), where the first character in Result(1) is + considered to be at position 0. - Note that the charCodeAt funciton is intentionally - generic; it does not require that its this value be a - String object. Therefore it can be transferred to other - kinds of objects for use as a method. + Note that the charCodeAt funciton is intentionally + generic; it does not require that its this value be a + String object. Therefore it can be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.4.5-6"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "String.prototype.charCodeAt"; +var SECTION = "15.5.4.5-6"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "String.prototype.charCodeAt"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "true", + eval("var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); - array[item++] = new TestCase( SECTION, - "var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", - "true", - eval("var obj = true; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); +new TestCase( SECTION, + "var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "1234", + eval("var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); - array[item++] = new TestCase( SECTION, - "var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", - "1234", - eval("var obj = 1234; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 4; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); +new TestCase( SECTION, + "var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", + "hello", + eval("var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); - array[item++] = new TestCase( SECTION, - "var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s", - "hello", - eval("var obj = 'hello'; obj.__proto__.charCodeAt = String.prototype.charCodeAt; var s = ''; for ( var i = 0; i < 5; i++ ) s+= String.fromCharCode( obj.charCodeAt(i) ); s") ); - return (array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value " - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.6-1.js b/mozilla/js/tests/ecma/String/15.5.4.6-1.js index 2b4c6e374c8..6494c10fb9f 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.6-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.6-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,140 +35,118 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.6-1.js - ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) - Description: If the given searchString appears as a substring of the - result of converting this object to a string, at one or - more positions that are at or to the right of the - specified position, then the index of the leftmost such - position is returned; otherwise -1 is returned. If - positionis undefined or not supplied, 0 is assumed, so - as to search all of the string. - - When the indexOf method is called with two arguments, - searchString and pos, the following steps are taken: - - 1. Call ToString, giving it the this value as its - argument. - 2. Call ToString(searchString). - 3. Call ToInteger(position). (If position is undefined - or not supplied, this step produces the value 0). - 4. Compute the number of characters in Result(1). - 5. Compute min(max(Result(3), 0), Result(4)). - 6. Compute the number of characters in the string that - is Result(2). - 7. Compute the smallest possible integer k not smaller - than Result(5) such that k+Result(6) is not greater - than Result(4), and for all nonnegative integers j - less than Result(6), the character at position k+j - of Result(1) is the same as the character at position - j of Result(2); but if there is no such integer k, - then compute the value -1. - 8. Return Result(7). - - Note that the indexOf function is intentionally generic; - it does not require that its this value be a String object. - Therefore it can be transferred to other kinds of objects - for use as a method. - - Author: christine@netscape.com - Date: 2 october 1997 -*/ - var SECTION = "15.5.4.6-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.protoype.indexOf"; - - var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - - -function getTestCases() { - var array = new Array(); - var j = 0; - - for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.indexOf(" +String.fromCharCode(i)+ ", 0)", - k, - TEST_STRING.indexOf( String.fromCharCode(i), 0 ) ); - } - - for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.indexOf("+String.fromCharCode(i)+ ", "+ k +")", - k, - TEST_STRING.indexOf( String.fromCharCode(i), k ) ); - } - - for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.indexOf("+String.fromCharCode(i)+ ", "+k+1+")", - -1, - TEST_STRING.indexOf( String.fromCharCode(i), k+1 ) ); - } - - for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.indexOf("+(String.fromCharCode(i) + - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)) +", "+0+")", - k, - TEST_STRING.indexOf( (String.fromCharCode(i)+ - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)), - 0 ) ); - } - - for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.indexOf("+(String.fromCharCode(i) + - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)) +", "+ k +")", - k, - TEST_STRING.indexOf( (String.fromCharCode(i)+ - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)), - k ) ); - } - for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.indexOf("+(String.fromCharCode(i) + - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)) +", "+ k+1 +")", - -1, - TEST_STRING.indexOf( (String.fromCharCode(i)+ - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)), - k+1 ) ); - } - - array[j++] = new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.indexOf( TEST_STRING, 0 ) ); - array[j++] = new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 1 )", -1, TEST_STRING.indexOf( TEST_STRING, 1 )); - - return array; -} - -function test() { - writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); - - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - - } - stopTest(); - - return ( testcases ); -} - +/** + File Name: 15.5.4.6-1.js + ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) + Description: If the given searchString appears as a substring of the + result of converting this object to a string, at one or + more positions that are at or to the right of the + specified position, then the index of the leftmost such + position is returned; otherwise -1 is returned. If + positionis undefined or not supplied, 0 is assumed, so + as to search all of the string. + + When the indexOf method is called with two arguments, + searchString and pos, the following steps are taken: + + 1. Call ToString, giving it the this value as its + argument. + 2. Call ToString(searchString). + 3. Call ToInteger(position). (If position is undefined + or not supplied, this step produces the value 0). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(3), 0), Result(4)). + 6. Compute the number of characters in the string that + is Result(2). + 7. Compute the smallest possible integer k not smaller + than Result(5) such that k+Result(6) is not greater + than Result(4), and for all nonnegative integers j + less than Result(6), the character at position k+j + of Result(1) is the same as the character at position + j of Result(2); but if there is no such integer k, + then compute the value -1. + 8. Return Result(7). + + Note that the indexOf function is intentionally generic; + it does not require that its this value be a String object. + Therefore it can be transferred to other kinds of objects + for use as a method. + + Author: christine@netscape.com + Date: 2 october 1997 +*/ +var SECTION = "15.5.4.6-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.protoype.indexOf"; + +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); + +writeHeaderToLog( SECTION + " "+ TITLE); + +var j = 0; + +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf(" +String.fromCharCode(i)+ ", 0)", + k, + TEST_STRING.indexOf( String.fromCharCode(i), 0 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+String.fromCharCode(i)+ ", "+ k +")", + k, + TEST_STRING.indexOf( String.fromCharCode(i), k ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+String.fromCharCode(i)+ ", "+k+1+")", + -1, + TEST_STRING.indexOf( String.fromCharCode(i), k+1 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+0+")", + k, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + 0 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k +")", + k, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k ) ); +} +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.indexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k+1 +")", + -1, + TEST_STRING.indexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k+1 ) ); +} + +new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.indexOf( TEST_STRING, 0 ) ); + +new TestCase( SECTION, "String.indexOf(" +TEST_STRING + ", 1 )", -1, TEST_STRING.indexOf( TEST_STRING, 1 )); + +writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.6-2.js b/mozilla/js/tests/ecma/String/15.5.4.6-2.js index 251f469d791..22bf8ebffd6 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.6-2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.6-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,240 +36,213 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 15.5.4.6-1.js - ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) - Description: If the given searchString appears as a substring of the - result of converting this object to a string, at one or - more positions that are at or to the right of the - specified position, then the index of the leftmost such - position is returned; otherwise -1 is returned. If - positionis undefined or not supplied, 0 is assumed, so - as to search all of the string. + File Name: 15.5.4.6-1.js + ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos) + Description: If the given searchString appears as a substring of the + result of converting this object to a string, at one or + more positions that are at or to the right of the + specified position, then the index of the leftmost such + position is returned; otherwise -1 is returned. If + positionis undefined or not supplied, 0 is assumed, so + as to search all of the string. - When the indexOf method is called with two arguments, - searchString and pos, the following steps are taken: + When the indexOf method is called with two arguments, + searchString and pos, the following steps are taken: - 1. Call ToString, giving it the this value as its - argument. - 2. Call ToString(searchString). - 3. Call ToInteger(position). (If position is undefined - or not supplied, this step produces the value 0). - 4. Compute the number of characters in Result(1). - 5. Compute min(max(Result(3), 0), Result(4)). - 6. Compute the number of characters in the string that - is Result(2). - 7. Compute the smallest possible integer k not smaller - than Result(5) such that k+Result(6) is not greater - than Result(4), and for all nonnegative integers j - less than Result(6), the character at position k+j - of Result(1) is the same as the character at position - j of Result(2); but if there is no such integer k, - then compute the value -1. - 8. Return Result(7). + 1. Call ToString, giving it the this value as its + argument. + 2. Call ToString(searchString). + 3. Call ToInteger(position). (If position is undefined + or not supplied, this step produces the value 0). + 4. Compute the number of characters in Result(1). + 5. Compute min(max(Result(3), 0), Result(4)). + 6. Compute the number of characters in the string that + is Result(2). + 7. Compute the smallest possible integer k not smaller + than Result(5) such that k+Result(6) is not greater + than Result(4), and for all nonnegative integers j + less than Result(6), the character at position k+j + of Result(1) is the same as the character at position + j of Result(2); but if there is no such integer k, + then compute the value -1. + 8. Return Result(7). - Note that the indexOf function is intentionally generic; - it does not require that its this value be a String object. - Therefore it can be transferred to other kinds of objects - for use as a method. + Note that the indexOf function is intentionally generic; + it does not require that its this value be a String object. + Therefore it can be transferred to other kinds of objects + for use as a method. - Author: christine@netscape.com, pschwartau@netscape.com - Date: 02 October 1997 - Modified: 14 July 2002 - Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 - ECMA-262 Ed.3 Section 15.5.4.7 - The length property of the indexOf method is 1 -* -*/ - var SECTION = "15.5.4.6-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.protoype.indexOf"; - var BUGNUMBER="105721"; + Author: christine@netscape.com, pschwartau@netscape.com + Date: 02 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.7 + The length property of the indexOf method is 1 + * + */ +var SECTION = "15.5.4.6-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.protoype.indexOf"; +var BUGNUMBER="105721"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); +writeHeaderToLog( SECTION + " "+ TITLE); // the following test regresses http://scopus/bugsplat/show_bug.cgi?id=105721 +// regress http://scopus/bugsplat/show_bug.cgi?id=105721 + +new TestCase( SECTION, "function f() { return this; }; function g() { var h = f; return h(); }; g().toString()", GLOBAL, g().toString() ); + + +new TestCase( SECTION, "String.prototype.indexOf.length", 1, String.prototype.indexOf.length ); +new TestCase( SECTION, "String.prototype.indexOf.length = null; String.prototype.indexOf.length", 1, eval("String.prototype.indexOf.length = null; String.prototype.indexOf.length") ); +new TestCase( SECTION, "delete String.prototype.indexOf.length", false, delete String.prototype.indexOf.length ); +new TestCase( SECTION, "delete String.prototype.indexOf.length; String.prototype.indexOf.length", 1, eval("delete String.prototype.indexOf.length; String.prototype.indexOf.length") ); + +new TestCase( SECTION, "var s = new String(); s.indexOf()", -1, eval("var s = new String(); s.indexOf()") ); + +// some Unicode tests. + +// generate a test string. + +var TEST_STRING = ""; + +for ( var u = 0x00A1; u <= 0x00FF; u++ ) { + TEST_STRING += String.fromCharCode( u ); +} + +for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { + new TestCase( SECTION, + "TEST_STRING.indexOf( " + String.fromCharCode(u) + " )", + i, + TEST_STRING.indexOf( String.fromCharCode(u) ) ); +} +for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { + new TestCase( SECTION, + "TEST_STRING.indexOf( " + String.fromCharCode(u) + ", void 0 )", + i, + TEST_STRING.indexOf( String.fromCharCode(u), void 0 ) ); +} + + + +var foo = new MyObject('hello'); + +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('h')", 0, foo.indexOf("h") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('e')", 1, foo.indexOf("e") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('o')", 4, foo.indexOf("o") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('X')", -1, foo.indexOf("X") ); +new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf(5) ", -1, foo.indexOf(5) ); + +var boo = new MyObject(true); + +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('t')", 0, boo.indexOf("t") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('r')", 1, boo.indexOf("r") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('u')", 2, boo.indexOf("u") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('e')", 3, boo.indexOf("e") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('true')", 0, boo.indexOf("true") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('rue')", 1, boo.indexOf("rue") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('ue')", 2, boo.indexOf("ue") ); +new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('oy')", -1, boo.indexOf("oy") ); + + +var noo = new MyObject( Math.PI ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('3') ", 0, noo.indexOf('3') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('.') ", 1, noo.indexOf('.') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('4') ", 3, noo.indexOf('4') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('5') ", 5, noo.indexOf('5') ); +new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('9') ", 6, noo.indexOf('9') ); + +new TestCase( SECTION, + "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')", + 0, + eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')") ); + +new TestCase( SECTION, + "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')", + 3, + eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')", + 0, + eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')", + 2, + eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')") ); + +new TestCase( SECTION, + "var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')", + 0, + eval("var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')") ); + +new TestCase( SECTION, + "var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')", + 0, + eval("var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')") ); + +new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')", + -1, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')") ); + +new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)", + -1, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)") ); + +new TestCase( SECTION, + "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)", + 0, + eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)") ); + +new TestCase( SECTION, + "var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')", + 1, + eval("var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')") ); + +new TestCase( SECTION, + "var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')", + 0, + eval("var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')") ); + +new TestCase( SECTION, + "var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')", + 1, + eval("var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')") ); + +new TestCase( SECTION, + "var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )", + 8, + eval("var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )") ); + +// new Date(0) has '31' or '01' at index 8 depending on whether tester is (GMT-) or (GMT+), respectively +new TestCase( SECTION, + "var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')", + 8, + eval("var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')") ); + +test(); + function f() { - return this; + return this; } function g() { - var h = f; - return h(); + var h = f; + return h(); } function MyObject (v) { - this.value = v; - this.toString = new Function ( "return this.value +\"\""); - this.indexOf = String.prototype.indexOf; + this.value = v; + this.toString = new Function ( "return this.value +\"\""); + this.indexOf = String.prototype.indexOf; } -function getTestCases() { - var array = new Array(); - var item = 0; - - // regress http://scopus/bugsplat/show_bug.cgi?id=105721 - - array[item++] = new TestCase( SECTION, "function f() { return this; }; function g() { var h = f; return h(); }; g().toString()", GLOBAL, g().toString() ); - - - array[item++] = new TestCase( SECTION, "String.prototype.indexOf.length", 1, String.prototype.indexOf.length ); - array[item++] = new TestCase( SECTION, "String.prototype.indexOf.length = null; String.prototype.indexOf.length", 1, eval("String.prototype.indexOf.length = null; String.prototype.indexOf.length") ); - array[item++] = new TestCase( SECTION, "delete String.prototype.indexOf.length", false, delete String.prototype.indexOf.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.indexOf.length; String.prototype.indexOf.length", 1, eval("delete String.prototype.indexOf.length; String.prototype.indexOf.length") ); - - array[item++] = new TestCase( SECTION, "var s = new String(); s.indexOf()", -1, eval("var s = new String(); s.indexOf()") ); - - // some Unicode tests. - - // generate a test string. - - var TEST_STRING = ""; - - for ( var u = 0x00A1; u <= 0x00FF; u++ ) { - TEST_STRING += String.fromCharCode( u ); - } - - for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { - array[item++] = new TestCase( SECTION, - "TEST_STRING.indexOf( " + String.fromCharCode(u) + " )", - i, - TEST_STRING.indexOf( String.fromCharCode(u) ) ); - } - for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) { - array[item++] = new TestCase( SECTION, - "TEST_STRING.indexOf( " + String.fromCharCode(u) + ", void 0 )", - i, - TEST_STRING.indexOf( String.fromCharCode(u), void 0 ) ); - } - - - - var foo = new MyObject('hello'); - - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('h')", 0, foo.indexOf("h") ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('e')", 1, foo.indexOf("e") ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('o')", 4, foo.indexOf("o") ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('X')", -1, foo.indexOf("X") ); - array[item++] = new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf(5) ", -1, foo.indexOf(5) ); - - var boo = new MyObject(true); - - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('t')", 0, boo.indexOf("t") ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('r')", 1, boo.indexOf("r") ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('u')", 2, boo.indexOf("u") ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('e')", 3, boo.indexOf("e") ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('true')", 0, boo.indexOf("true") ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('rue')", 1, boo.indexOf("rue") ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('ue')", 2, boo.indexOf("ue") ); - array[item++] = new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('oy')", -1, boo.indexOf("oy") ); - - - var noo = new MyObject( Math.PI ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('3') ", 0, noo.indexOf('3') ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('.') ", 1, noo.indexOf('.') ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('4') ", 3, noo.indexOf('4') ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('5') ", 5, noo.indexOf('5') ); - array[item++] = new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('9') ", 6, noo.indexOf('9') ); - - array[item++] = new TestCase( SECTION, - "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')", - 0, - eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')") ); - - array[item++] = new TestCase( SECTION, - "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')", - 3, - eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')", - 0, - eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')", - 2, - eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')") ); - - array[item++] = new TestCase( SECTION, - "var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')", - 0, - eval("var f = new Object( String.prototype.indexOf ); f('"+GLOBAL+"')") ); - - array[item++] = new TestCase( SECTION, - "var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')", - 0, - eval("var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')") ); - - array[item++] = new TestCase( SECTION, - "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')", - -1, - eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')") ); - - array[item++] = new TestCase( SECTION, - "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)", - -1, - eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)") ); - - array[item++] = new TestCase( SECTION, - "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)", - 0, - eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)") ); - - array[item++] = new TestCase( SECTION, - "var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')", - 1, - eval("var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')") ); - - array[item++] = new TestCase( SECTION, - "var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')", - 0, - eval("var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')") ); - - array[item++] = new TestCase( SECTION, - "var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')", - 1, - eval("var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')") ); - - array[item++] = new TestCase( SECTION, - "var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )", - 8, - eval("var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )") ); - - // new Date(0) has '31' or '01' at index 8 depending on whether tester is (GMT-) or (GMT+), respectively - array[item++] = new TestCase( SECTION, - "var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')", - 8, - eval("var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')") ); - - - return array; -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) - ? "" - : "wrong value " - } - stopTest(); - - // all tests must return a boolean value - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/String/15.5.4.7-1.js b/mozilla/js/tests/ecma/String/15.5.4.7-1.js index c9548a6cfc0..831ea11e9c2 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.7-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.7-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,20 +35,21 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.7-1.js - ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) - Description: + File Name: 15.5.4.7-1.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: - If the given searchString appears as a substring of the result of - converting this object to a string, at one or more positions that are - at or to the left of the specified position, then the index of the - rightmost such position is returned; otherwise -1 is returned. If position - is undefined or not supplied, the length of this string value is assumed, - so as to search all of the string. + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. - When the lastIndexOf method is called with two arguments searchString and - position, the following steps are taken: + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: 1.Call ToString, giving it the this value as its argument. 2.Call ToString(searchString). @@ -57,180 +59,159 @@ 6.Compute min(max(Result(4), 0), Result(5)). 7.Compute the number of characters in the string that is Result(2). 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater - than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of - Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then - compute the value -1. + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. 1.Return Result(8). - Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a - String object. Therefore it can be transferred to other kinds of objects for use as a method. + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.4.7-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.protoype.lastIndexOf"; +var SECTION = "15.5.4.7-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.protoype.lastIndexOf"; - var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); +var TEST_STRING = new String( " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" ); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var j = 0; - -function getTestCases() { - var array = new Array(); - var j = 0; - - for ( k = 0, i = 0x0021; i < 0x007e; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.lastIndexOf(" +String.fromCharCode(i)+ ", 0)", - -1, - TEST_STRING.lastIndexOf( String.fromCharCode(i), 0 ) ); - } - - for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.lastIndexOf("+String.fromCharCode(i)+ ", "+ k +")", - k, - TEST_STRING.lastIndexOf( String.fromCharCode(i), k ) ); - } - - for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.lastIndexOf("+String.fromCharCode(i)+ ", "+k+1+")", - k, - TEST_STRING.lastIndexOf( String.fromCharCode(i), k+1 ) ); - } - - for ( k = 9, i = 0x0021; i < 0x007d; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - - "String.lastIndexOf("+(String.fromCharCode(i) + - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)) +", "+ 0 + ")", - LastIndexOf( TEST_STRING, String.fromCharCode(i) + - String.fromCharCode(i+1)+String.fromCharCode(i+2), 0), - TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)), - 0 ) ); - } - - for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.lastIndexOf("+(String.fromCharCode(i) + - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)) +", "+ k +")", - k, - TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)), - k ) ); - } - for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.lastIndexOf("+(String.fromCharCode(i) + - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)) +", "+ k+1 +")", - k, - TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)), - k+1 ) ); - } - for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { - array[j] = new TestCase( SECTION, - "String.lastIndexOf("+ - (String.fromCharCode(i) + - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)) +", "+ (k-1) +")", - LastIndexOf( TEST_STRING, String.fromCharCode(i) + - String.fromCharCode(i+1)+String.fromCharCode(i+2), k-1), - TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ - String.fromCharCode(i+1)+ - String.fromCharCode(i+2)), - k-1 ) ); - } - - array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 0 ) ); -// array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 1 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 1 )); - array[j++] = new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ")", 0, TEST_STRING.lastIndexOf( TEST_STRING )); - - return array; +for ( k = 0, i = 0x0021; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf(" +String.fromCharCode(i)+ ", 0)", + -1, + TEST_STRING.lastIndexOf( String.fromCharCode(i), 0 ) ); } -function test() { - writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); - - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - - } - stopTest(); - - return ( testcases ); +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+String.fromCharCode(i)+ ", "+ k +")", + k, + TEST_STRING.lastIndexOf( String.fromCharCode(i), k ) ); } +for ( k = 0, i = 0x0020; i < 0x007e; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+String.fromCharCode(i)+ ", "+k+1+")", + k, + TEST_STRING.lastIndexOf( String.fromCharCode(i), k+1 ) ); +} + +for ( k = 9, i = 0x0021; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ 0 + ")", + LastIndexOf( TEST_STRING, String.fromCharCode(i) + + String.fromCharCode(i+1)+String.fromCharCode(i+2), 0), + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + 0 ) ); +} + +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k +")", + k, + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k ) ); +} +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+(String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ k+1 +")", + k, + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k+1 ) ); +} +for ( k = 0, i = 0x0020; i < 0x007d; i++, j++, k++ ) { + new TestCase( SECTION, + "String.lastIndexOf("+ + (String.fromCharCode(i) + + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)) +", "+ (k-1) +")", + LastIndexOf( TEST_STRING, String.fromCharCode(i) + + String.fromCharCode(i+1)+String.fromCharCode(i+2), k-1), + TEST_STRING.lastIndexOf( (String.fromCharCode(i)+ + String.fromCharCode(i+1)+ + String.fromCharCode(i+2)), + k-1 ) ); +} + +new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 0 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 0 ) ); + +// new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ", 1 )", 0, TEST_STRING.lastIndexOf( TEST_STRING, 1 )); + +new TestCase( SECTION, "String.lastIndexOf(" +TEST_STRING + ")", 0, TEST_STRING.lastIndexOf( TEST_STRING )); + +writeLineToLog( "TEST_STRING = new String(\" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\")" ); + +test(); + function LastIndexOf( string, search, position ) { - string = String( string ); - search = String( search ); + string = String( string ); + search = String( search ); - position = Number( position ) + position = Number( position ) if ( isNaN( position ) ) { - position = Infinity; + position = Infinity; } else { - position = ToInteger( position ); + position = ToInteger( position ); } - result5= string.length; - result6 = Math.min(Math.max(position, 0), result5); - result7 = search.length; + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; - if (result7 == 0) { - return Math.min(position, result5); + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; } - - result8 = -1; - - for ( k = 0; k <= result6; k++ ) { - if ( k+ result7 > result5 ) { - break; - } - for ( j = 0; j < result7; j++ ) { - if ( string.charAt(k+j) != search.charAt(j) ){ - break; - } else { - if ( j == result7 -1 ) { - result8 = k; - } - } - } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } } + } - return result8; + return result8; } function ToInteger( n ) { - n = Number( n ); - if ( isNaN(n) ) { - return 0; - } - if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { - return n; - } + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } - var sign = ( n < 0 ) ? -1 : 1; + var sign = ( n < 0 ) ? -1 : 1; - return ( sign * Math.floor(Math.abs(n)) ); -} \ No newline at end of file + return ( sign * Math.floor(Math.abs(n)) ); +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.7-2.js b/mozilla/js/tests/ecma/String/15.5.4.7-2.js index 74c5a3363d9..5117875c4fa 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.7-2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.7-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,20 +35,21 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.7-2.js - ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) - Description: + File Name: 15.5.4.7-2.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: - If the given searchString appears as a substring of the result of - converting this object to a string, at one or more positions that are - at or to the left of the specified position, then the index of the - rightmost such position is returned; otherwise -1 is returned. If position - is undefined or not supplied, the length of this string value is assumed, - so as to search all of the string. + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. - When the lastIndexOf method is called with two arguments searchString and - position, the following steps are taken: + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: 1.Call ToString, giving it the this value as its argument. 2.Call ToString(searchString). @@ -57,179 +59,157 @@ 6.Compute min(max(Result(4), 0), Result(5)). 7.Compute the number of characters in the string that is Result(2). 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater - than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of - Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then - compute the value -1. + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. 1.Return Result(8). - Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a - String object. Therefore it can be transferred to other kinds of objects for use as a method. + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. - Author: christine@netscape.com, pschwartau@netscape.com - Date: 02 October 1997 - Modified: 14 July 2002 - Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 - ECMA-262 Ed.3 Section 15.5.4.8 - The length property of the lastIndexOf method is 1 -* -*/ - var SECTION = "15.5.4.7-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.protoype.lastIndexOf"; + Author: christine@netscape.com, pschwartau@netscape.com + Date: 02 October 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.8 + The length property of the lastIndexOf method is 1 + * + */ +var SECTION = "15.5.4.7-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.protoype.lastIndexOf"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); +writeHeaderToLog( SECTION + " "+ TITLE); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "String.prototype.lastIndexOf.length", 1, String.prototype.lastIndexOf.length ); +new TestCase( SECTION, "delete String.prototype.lastIndexOf.length", false, delete String.prototype.lastIndexOf.length ); +new TestCase( SECTION, "delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length", 1, eval("delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length" ) ); - array[item++] = new TestCase( SECTION, "String.prototype.lastIndexOf.length", 1, String.prototype.lastIndexOf.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.lastIndexOf.length", false, delete String.prototype.lastIndexOf.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length", 1, eval("delete String.prototype.lastIndexOf.length; String.prototype.lastIndexOf.length" ) ); +new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('', 0)", LastIndexOf("","",0), eval("var s = new String(''); s.lastIndexOf('', 0)") ); +new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('')", LastIndexOf("",""), eval("var s = new String(''); s.lastIndexOf('')") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('', 0)", LastIndexOf("hello","",0), eval("var s = new String('hello'); s.lastIndexOf('',0)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('')", LastIndexOf("hello",""), eval("var s = new String('hello'); s.lastIndexOf('')") ); - array[item++] = new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('', 0)", LastIndexOf("","",0), eval("var s = new String(''); s.lastIndexOf('', 0)") ); - array[item++] = new TestCase( SECTION, "var s = new String(''); s.lastIndexOf('')", LastIndexOf("",""), eval("var s = new String(''); s.lastIndexOf('')") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('', 0)", LastIndexOf("hello","",0), eval("var s = new String('hello'); s.lastIndexOf('',0)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('')", LastIndexOf("hello",""), eval("var s = new String('hello'); s.lastIndexOf('')") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll')", LastIndexOf("hello","ll"), eval("var s = new String('hello'); s.lastIndexOf('ll')") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 0)", LastIndexOf("hello","ll",0), eval("var s = new String('hello'); s.lastIndexOf('ll', 0)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1)", LastIndexOf("hello","ll",1), eval("var s = new String('hello'); s.lastIndexOf('ll', 1)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2)", LastIndexOf("hello","ll",2), eval("var s = new String('hello'); s.lastIndexOf('ll', 2)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 3)", LastIndexOf("hello","ll",3), eval("var s = new String('hello'); s.lastIndexOf('ll', 3)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 4)", LastIndexOf("hello","ll",4), eval("var s = new String('hello'); s.lastIndexOf('ll', 4)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 5)", LastIndexOf("hello","ll",5), eval("var s = new String('hello'); s.lastIndexOf('ll', 5)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 6)", LastIndexOf("hello","ll",6), eval("var s = new String('hello'); s.lastIndexOf('ll', 6)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll')", LastIndexOf("hello","ll"), eval("var s = new String('hello'); s.lastIndexOf('ll')") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 0)", LastIndexOf("hello","ll",0), eval("var s = new String('hello'); s.lastIndexOf('ll', 0)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1)", LastIndexOf("hello","ll",1), eval("var s = new String('hello'); s.lastIndexOf('ll', 1)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2)", LastIndexOf("hello","ll",2), eval("var s = new String('hello'); s.lastIndexOf('ll', 2)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 3)", LastIndexOf("hello","ll",3), eval("var s = new String('hello'); s.lastIndexOf('ll', 3)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 4)", LastIndexOf("hello","ll",4), eval("var s = new String('hello'); s.lastIndexOf('ll', 4)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 5)", LastIndexOf("hello","ll",5), eval("var s = new String('hello'); s.lastIndexOf('ll', 5)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 6)", LastIndexOf("hello","ll",6), eval("var s = new String('hello'); s.lastIndexOf('ll', 6)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1.5)", LastIndexOf('hello','ll', 1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 1.5)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2.5)", LastIndexOf('hello','ll', 2.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 2.5)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1)", LastIndexOf('hello','ll', -1), eval("var s = new String('hello'); s.lastIndexOf('ll', -1)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1.5)",LastIndexOf('hello','ll', -1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', -1.5)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 1.5)", LastIndexOf('hello','ll', 1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 1.5)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', 2.5)", LastIndexOf('hello','ll', 2.5), eval("var s = new String('hello'); s.lastIndexOf('ll', 2.5)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1)", LastIndexOf('hello','ll', -1), eval("var s = new String('hello'); s.lastIndexOf('ll', -1)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -1.5)",LastIndexOf('hello','ll', -1.5), eval("var s = new String('hello'); s.lastIndexOf('ll', -1.5)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -Infinity)", LastIndexOf("hello","ll",-Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', -Infinity)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', Infinity)", LastIndexOf("hello","ll",Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', Infinity)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', NaN)", LastIndexOf("hello","ll",NaN), eval("var s = new String('hello'); s.lastIndexOf('ll', NaN)") ); +new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -0)", LastIndexOf("hello","ll",-0), eval("var s = new String('hello'); s.lastIndexOf('ll', -0)") ); +for ( var i = 0; i < ( "[object Object]" ).length; i++ ) { + new TestCase( SECTION, + "var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")", + ( i < 2 ? -1 : ( i < 9 ? 2 : 9 )) , + eval("var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")") ); +} +for ( var i = 0; i < 5; i ++ ) { + new TestCase( SECTION, + "var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")", + ( i < 2 ? -1 : 2 ), + eval("var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")") ); +} +for ( var i = 0; i < 5; i ++ ) { + new TestCase( SECTION, + "var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")", + ( i < 1 ? -1 : ( i < 9 ? 1 : ( i < 10 ? 9 : 10 ) ) ), + eval("var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")") ); +} +for ( var i = 0; i < 9; i++ ) { + new TestCase( SECTION, + "var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )", + ( i < 3 ? -1 : ( i < 5 ? 3 : 5 ) ), + eval("var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )") ); +} +var a = new Array( "abc","def","ghi","jkl","mno","pqr","stu","vwx","yz" ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -Infinity)", LastIndexOf("hello","ll",-Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', -Infinity)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', Infinity)", LastIndexOf("hello","ll",Infinity), eval("var s = new String('hello'); s.lastIndexOf('ll', Infinity)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', NaN)", LastIndexOf("hello","ll",NaN), eval("var s = new String('hello'); s.lastIndexOf('ll', NaN)") ); - array[item++] = new TestCase( SECTION, "var s = new String('hello'); s.lastIndexOf('ll', -0)", LastIndexOf("hello","ll",-0), eval("var s = new String('hello'); s.lastIndexOf('ll', -0)") ); - for ( var i = 0; i < ( "[object Object]" ).length; i++ ) { - array[item++] = new TestCase( SECTION, - "var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")", - ( i < 2 ? -1 : ( i < 9 ? 2 : 9 )) , - eval("var o = new Object(); o.lastIndexOf = String.prototype.lastIndexOf; o.lastIndexOf('b', "+ i + ")") ); - } - for ( var i = 0; i < 5; i ++ ) { - array[item++] = new TestCase( SECTION, - "var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")", - ( i < 2 ? -1 : 2 ), - eval("var b = new Boolean(); b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('l', "+ i + ")") ); - } - for ( var i = 0; i < 5; i ++ ) { - array[item++] = new TestCase( SECTION, - "var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")", - ( i < 1 ? -1 : ( i < 9 ? 1 : ( i < 10 ? 9 : 10 ) ) ), - eval("var b = new Boolean(); b.toString = Object.prototype.toString; b.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('o', "+ i + ")") ); - } - for ( var i = 0; i < 9; i++ ) { - array[item++] = new TestCase( SECTION, - "var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )", - ( i < 3 ? -1 : ( i < 5 ? 3 : 5 ) ), - eval("var n = new Number(Infinity); n.lastIndexOf = String.prototype.lastIndexOf; n.lastIndexOf( 'i', " + i + " )") ); - } - var a = new Array( "abc","def","ghi","jkl","mno","pqr","stu","vwx","yz" ); +for ( var i = 0; i < (a.toString()).length; i++ ) { + new TestCase( SECTION, + "var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )", + ( i < 15 ? -1 : 15 ), + eval("var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )") ); +} - for ( var i = 0; i < (a.toString()).length; i++ ) { - array[item++] = new TestCase( SECTION, - "var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )", - ( i < 15 ? -1 : 15 ), - eval("var a = new Array( 'abc','def','ghi','jkl','mno','pqr','stu','vwx','yz' ); a.lastIndexOf = String.prototype.lastIndexOf; a.lastIndexOf( ',mno,p', "+i+" )") ); - } - - for ( var i = 0; i < 15; i ++ ) { - array[item++] = new TestCase( SECTION, - "var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")", - ( i < 6 ? -1 : ( i < 10 ? 6 : 10 ) ), - eval("var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")") ); - } +for ( var i = 0; i < 15; i ++ ) { + new TestCase( SECTION, + "var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")", + ( i < 6 ? -1 : ( i < 10 ? 6 : 10 ) ), + eval("var m = Math; m.lastIndexOf = String.prototype.lastIndexOf; m.lastIndexOf('t', "+ i + ")") ); +} /* - for ( var i = 0; i < 15; i++ ) { - array[item++] = new TestCase( SECTION, - "var d = new Date(); d.lastIndexOf = String.prototype.lastIndexOf; d.lastIndexOf( '0' )", - ) - } + for ( var i = 0; i < 15; i++ ) { + new TestCase( SECTION, + "var d = new Date(); d.lastIndexOf = String.prototype.lastIndexOf; d.lastIndexOf( '0' )", + ) + } */ - return array; -} -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - - return ( testcases ); -} +test(); function LastIndexOf( string, search, position ) { - string = String( string ); - search = String( search ); + string = String( string ); + search = String( search ); - position = Number( position ) + position = Number( position ) if ( isNaN( position ) ) { - position = Infinity; + position = Infinity; } else { - position = ToInteger( position ); + position = ToInteger( position ); } - result5= string.length; - result6 = Math.min(Math.max(position, 0), result5); - result7 = search.length; + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; - if (result7 == 0) { - return Math.min(position, result5); + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; } - - result8 = -1; - - for ( k = 0; k <= result6; k++ ) { - if ( k+ result7 > result5 ) { - break; - } - for ( j = 0; j < result7; j++ ) { - if ( string.charAt(k+j) != search.charAt(j) ){ - break; - } else { - if ( j == result7 -1 ) { - result8 = k; - } - } - } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } } + } - return result8; + return result8; } function ToInteger( n ) { - n = Number( n ); - if ( isNaN(n) ) { - return 0; - } - if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { - return n; - } + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } - var sign = ( n < 0 ) ? -1 : 1; + var sign = ( n < 0 ) ? -1 : 1; - return ( sign * Math.floor(Math.abs(n)) ); -} \ No newline at end of file + return ( sign * Math.floor(Math.abs(n)) ); +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.7-3.js b/mozilla/js/tests/ecma/String/15.5.4.7-3.js index fa9713e79f4..26c2abbae3c 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.7-3.js +++ b/mozilla/js/tests/ecma/String/15.5.4.7-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,20 +35,21 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.7-3.js - ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) - Description: + File Name: 15.5.4.7-3.js + ECMA Section: 15.5.4.7 String.prototype.lastIndexOf( searchString, pos) + Description: - If the given searchString appears as a substring of the result of - converting this object to a string, at one or more positions that are - at or to the left of the specified position, then the index of the - rightmost such position is returned; otherwise -1 is returned. If position - is undefined or not supplied, the length of this string value is assumed, - so as to search all of the string. + If the given searchString appears as a substring of the result of + converting this object to a string, at one or more positions that are + at or to the left of the specified position, then the index of the + rightmost such position is returned; otherwise -1 is returned. If position + is undefined or not supplied, the length of this string value is assumed, + so as to search all of the string. - When the lastIndexOf method is called with two arguments searchString and - position, the following steps are taken: + When the lastIndexOf method is called with two arguments searchString and + position, the following steps are taken: 1.Call ToString, giving it the this value as its argument. 2.Call ToString(searchString). @@ -57,125 +59,101 @@ 6.Compute min(max(Result(4), 0), Result(5)). 7.Compute the number of characters in the string that is Result(2). 8.Compute the largest possible integer k not larger than Result(6) such that k+Result(7) is not greater - than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of - Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then - compute the value -1. + than Result(5), and for all nonnegative integers j less than Result(7), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); but if there is no such integer k, then + compute the value -1. 1.Return Result(8). - Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a - String object. Therefore it can be transferred to other kinds of objects for use as a method. + Note that the lastIndexOf function is intentionally generic; it does not require that its this value be a + String object. Therefore it can be transferred to other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 2 october 1997 + Author: christine@netscape.com + Date: 2 october 1997 */ - var SECTION = "15.5.4.7-3"; - var VERSION = "ECMA_2"; - startTest(); - var TITLE = "String.protoype.lastIndexOf"; +var SECTION = "15.5.4.7-3"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "String.protoype.lastIndexOf"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )", + -1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )") ); +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )") ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )") ); - array[item++] = new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )", - -1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 0 )") ); +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )") ); - array[item++] = new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )", - 1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 1 )") ); +new TestCase( SECTION, + "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )", + 1, + eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )") ); - array[item++] = new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )", - 1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 2 )") ); - - array[item++] = new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )", - 1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r', 10 )") ); - - array[item++] = new TestCase( SECTION, - "var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )", - 1, - eval("var b = true; b.__proto__.lastIndexOf = String.prototype.lastIndexOf; b.lastIndexOf('r' )") ); - - return array; -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value " - } - stopTest(); - - return ( testcases ); -} +test(); function LastIndexOf( string, search, position ) { - string = String( string ); - search = String( search ); + string = String( string ); + search = String( search ); - position = Number( position ) + position = Number( position ) if ( isNaN( position ) ) { - position = Infinity; + position = Infinity; } else { - position = ToInteger( position ); + position = ToInteger( position ); } - result5= string.length; - result6 = Math.min(Math.max(position, 0), result5); - result7 = search.length; + result5= string.length; + result6 = Math.min(Math.max(position, 0), result5); + result7 = search.length; - if (result7 == 0) { - return Math.min(position, result5); + if (result7 == 0) { + return Math.min(position, result5); + } + + result8 = -1; + + for ( k = 0; k <= result6; k++ ) { + if ( k+ result7 > result5 ) { + break; } - - result8 = -1; - - for ( k = 0; k <= result6; k++ ) { - if ( k+ result7 > result5 ) { - break; - } - for ( j = 0; j < result7; j++ ) { - if ( string.charAt(k+j) != search.charAt(j) ){ - break; - } else { - if ( j == result7 -1 ) { - result8 = k; - } - } - } + for ( j = 0; j < result7; j++ ) { + if ( string.charAt(k+j) != search.charAt(j) ){ + break; + } else { + if ( j == result7 -1 ) { + result8 = k; + } + } } + } - return result8; + return result8; } function ToInteger( n ) { - n = Number( n ); - if ( isNaN(n) ) { - return 0; - } - if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { - return n; - } + n = Number( n ); + if ( isNaN(n) ) { + return 0; + } + if ( Math.abs(n) == 0 || Math.abs(n) == Infinity ) { + return n; + } - var sign = ( n < 0 ) ? -1 : 1; + var sign = ( n < 0 ) ? -1 : 1; - return ( sign * Math.floor(Math.abs(n)) ); -} \ No newline at end of file + return ( sign * Math.floor(Math.abs(n)) ); +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.8-1.js b/mozilla/js/tests/ecma/String/15.5.4.8-1.js index 83bf7280555..3b8e2386410 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.8-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.8-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,216 +35,195 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.8-1.js - ECMA Section: 15.5.4.8 String.prototype.split( separator ) - Description: - - Returns an Array object into which substrings of the result of converting - this object to a string have been stored. The substrings are determined by - searching from left to right for occurrences of the given separator; these - occurrences are not part of any substring in the returned array, but serve - to divide up this string value. The separator may be a string of any length. - - As a special case, if the separator is the empty string, the string is split - up into individual characters; the length of the result array equals the - length of the string, and each substring contains one character. - - If the separator is not supplied, then the result array contains just one - string, which is the string. - - Author: christine@netscape.com, pschwartau@netscape.com - Date: 12 November 1997 - Modified: 14 July 2002 - Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 - ECMA-262 Ed.3 Section 15.5.4.14 - The length property of the split method is 2 -* -*/ - - var SECTION = "15.5.4.8-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.split"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "String.prototype.split.length", 2, String.prototype.split.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.split.length", false, delete String.prototype.split.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.split.length; String.prototype.split.length", 2, eval("delete String.prototype.split.length; String.prototype.split.length") ); - - // test cases for when split is called with no arguments. - - // this is a string object - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); typeof s.split()", - "object", - eval("var s = new String('this is a string object'); typeof s.split()") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()", - "[object Array]", - eval("var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.split().length", - 1, - eval("var s = new String('this is a string object'); s.split().length") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.split()[0]", - "this is a string object", - eval("var s = new String('this is a string object'); s.split()[0]") ); - - // this is an object object - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()", - "object", - eval("var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", - "[object Array]", - eval("var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.split = String.prototype.split; obj.split().length", - 1, - eval("var obj = new Object(); obj.split = String.prototype.split; obj.split().length") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]", - "[object Object]", - eval("var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]") ); - - // this is a function object - array[item++] = new TestCase( SECTION, - "var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()", - "object", - eval("var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", - "[object Array]", - eval("var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Function(); obj.split = String.prototype.split; obj.split().length", - 1, - eval("var obj = new Function(); obj.split = String.prototype.split; obj.split().length") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]", - "[object Function]", - eval("var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]") ); - - // this is a number object - array[item++] = new TestCase( SECTION, - "var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()", - "object", - eval("var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", - "[object Array]", - eval("var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length", - 1, - eval("var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]", - "-1e+21", - eval("var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]") ); - - - // this is the Math object - array[item++] = new TestCase( SECTION, - "var obj = Math; obj.split = String.prototype.split; typeof obj.split()", - "object", - eval("var obj = Math; obj.split = String.prototype.split; typeof obj.split()") ); - - array[item++] = new TestCase( SECTION, - "var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", - "[object Array]", - eval("var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); - - array[item++] = new TestCase( SECTION, - "var obj = Math; obj.split = String.prototype.split; obj.split().length", - 1, - eval("var obj = Math; obj.split = String.prototype.split; obj.split().length") ); - - array[item++] = new TestCase( SECTION, - "var obj = Math; obj.split = String.prototype.split; obj.split()[0]", - "[object Math]", - eval("var obj = Math; obj.split = String.prototype.split; obj.split()[0]") ); - - // this is an array object - array[item++] = new TestCase( SECTION, - "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()", - "object", - eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", - "[object Array]", - eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length", - 1, - eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]", - "1,2,3,4,5", - eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]") ); - - // this is a Boolean object - - array[item++] = new TestCase( SECTION, - "var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()", - "object", - eval("var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", - "[object Array]", - eval("var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length", - 1, - eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length") ); - - array[item++] = new TestCase( SECTION, - "var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]", - "false", - eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]") ); - - - return array; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +/** + File Name: 15.5.4.8-1.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: + + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. + + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. + + If the separator is not supplied, then the result array contains just one + string, which is the string. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 12 November 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155289 + ECMA-262 Ed.3 Section 15.5.4.14 + The length property of the split method is 2 + * + */ + +var SECTION = "15.5.4.8-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.split"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.split.length", 2, String.prototype.split.length ); +new TestCase( SECTION, "delete String.prototype.split.length", false, delete String.prototype.split.length ); +new TestCase( SECTION, "delete String.prototype.split.length; String.prototype.split.length", 2, eval("delete String.prototype.split.length; String.prototype.split.length") ); + +// test cases for when split is called with no arguments. + +// this is a string object + +new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.split()", + "object", + eval("var s = new String('this is a string object'); typeof s.split()") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()", + "[object Array]", + eval("var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.split().length", + 1, + eval("var s = new String('this is a string object'); s.split().length") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.split()[0]", + "this is a string object", + eval("var s = new String('this is a string object'); s.split()[0]") ); + +// this is an object object +new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Object(); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]", + "[object Object]", + eval("var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]") ); + +// this is a function object +new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Function(); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]", + "[object Function]", + eval("var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]") ); + +// this is a number object +new TestCase( SECTION, + "var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]", + "-1e+21", + eval("var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]") ); + + +// this is the Math object +new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = Math; obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = Math; obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = Math; obj.split = String.prototype.split; obj.split()[0]", + "[object Math]", + eval("var obj = Math; obj.split = String.prototype.split; obj.split()[0]") ); + +// this is an array object +new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]", + "1,2,3,4,5", + eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]") ); + +// this is a Boolean object + +new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()", + "object", + eval("var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()") ); + +new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()", + "[object Array]", + eval("var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") ); + +new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length", + 1, + eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length") ); + +new TestCase( SECTION, + "var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]", + "false", + eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]") ); + + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.8-2.js b/mozilla/js/tests/ecma/String/15.5.4.8-2.js index 64b0bef5fa5..b5fba626512 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.8-2.js +++ b/mozilla/js/tests/ecma/String/15.5.4.8-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,230 +35,211 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.8-2.js - ECMA Section: 15.5.4.8 String.prototype.split( separator ) - Description: + File Name: 15.5.4.8-2.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: - Returns an Array object into which substrings of the result of converting - this object to a string have been stored. The substrings are determined by - searching from left to right for occurrences of the given separator; these - occurrences are not part of any substring in the returned array, but serve - to divide up this string value. The separator may be a string of any length. + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. - As a special case, if the separator is the empty string, the string is split - up into individual characters; the length of the result array equals the - length of the string, and each substring contains one character. + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. - If the separator is not supplied, then the result array contains just one - string, which is the string. + If the separator is not supplied, then the result array contains just one + string, which is the string. - When the split method is called with one argument separator, the following steps are taken: + When the split method is called with one argument separator, the following steps are taken: 1. Call ToString, giving it the this value as its argument. 2. Create a new Array object of length 0 and call it A. 3. If separator is not supplied, call the [[Put]] method of A with 0 and - Result(1) as arguments, and then return A. + Result(1) as arguments, and then return A. 4. Call ToString(separator). 5. Compute the number of characters in Result(1). 6. Compute the number of characters in the string that is Result(4). 7. Let p be 0. 8. If Result(6) is zero (the separator string is empty), go to step 17. 9. Compute the smallest possible integer k not smaller than p such that - k+Result(6) is not greater than Result(5), and for all nonnegative - integers j less than Result(6), the character at position k+j of - Result(1) is the same as the character at position j of Result(2); - but if there is no such integer k, then go to step 14. - 10. Compute a string value equal to the substring of Result(1), consisting - of the characters at positions p through k1, inclusive. - 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. - 12. Let p be k+Result(6). - 13. Go to step 9. - 14. Compute a string value equal to the substring of Result(1), consisting - of the characters from position p to the end of Result(1). - 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. - 16. Return A. - 17. If p equals Result(5), return A. - 18. Compute a string value equal to the substring of Result(1), consisting of - the single character at position p. - 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. - 20. Increase p by 1. - 21. Go to step 17. + k+Result(6) is not greater than Result(5), and for all nonnegative + integers j less than Result(6), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); + but if there is no such integer k, then go to step 14. + 10. Compute a string value equal to the substring of Result(1), consisting + of the characters at positions p through k1, inclusive. + 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. + 12. Let p be k+Result(6). + 13. Go to step 9. + 14. Compute a string value equal to the substring of Result(1), consisting + of the characters from position p to the end of Result(1). + 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. + 16. Return A. + 17. If p equals Result(5), return A. + 18. Compute a string value equal to the substring of Result(1), consisting of + the single character at position p. + 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. + 20. Increase p by 1. + 21. Go to step 17. -Note that the split function is intentionally generic; it does not require that its this value be a String -object. Therefore it can be transferred to other kinds of objects for use as a method. + Note that the split function is intentionally generic; it does not require that its this value be a String + object. Therefore it can be transferred to other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.8-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.split"; +var SECTION = "15.5.4.8-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.split"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// case where separator is the empty string. -function getTestCases() { - var array = new Array(); - var item = 0; +var TEST_STRING = "this is a string object"; - // case where separator is the empty string. +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split('').length", + TEST_STRING.length, + eval("var s = new String( TEST_STRING ); s.split('').length") ); - var TEST_STRING = "this is a string object"; +for ( var i = 0; i < TEST_STRING.length; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( "+ TEST_STRING +" ); s.split('').length", - TEST_STRING.length, - eval("var s = new String( TEST_STRING ); s.split('').length") ); - - for ( var i = 0; i < TEST_STRING.length; i++ ) { - - array[item++] = new TestCase( SECTION, - "var s = new String( "+TEST_STRING+" ); s.split('')["+i+"]", - TEST_STRING.charAt(i), - eval("var s = new String( TEST_STRING ); s.split('')["+i+"]") ); - } - - // case where the value of the separator is undefined. in this case. the value of the separator - // should be ToString( separator ), or "undefined". - - var TEST_STRING = "thisundefinedisundefinedaundefinedstringundefinedobject"; - var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); - - array[item++] = new TestCase( SECTION, - "var s = new String( "+ TEST_STRING +" ); s.split(void 0).length", - EXPECT_STRING.length, - eval("var s = new String( TEST_STRING ); s.split(void 0).length") ); - - for ( var i = 0; i < EXPECT_STRING.length; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( "+TEST_STRING+" ); s.split(void 0)["+i+"]", - EXPECT_STRING[i], - eval("var s = new String( TEST_STRING ); s.split(void 0)["+i+"]") ); - } - - // case where the value of the separator is null. in this case the value of the separator is "null". - TEST_STRING = "thisnullisnullanullstringnullobject"; - var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); - - array[item++] = new TestCase( SECTION, - "var s = new String( "+ TEST_STRING +" ); s.split(null).length", - EXPECT_STRING.length, - eval("var s = new String( TEST_STRING ); s.split(null).length") ); - - for ( var i = 0; i < EXPECT_STRING.length; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( "+TEST_STRING+" ); s.split(null)["+i+"]", - EXPECT_STRING[i], - eval("var s = new String( TEST_STRING ); s.split(null)["+i+"]") ); - } - - // case where the value of the separator is a boolean. - TEST_STRING = "thistrueistrueatruestringtrueobject"; - var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); - - array[item++] = new TestCase( SECTION, - "var s = new String( "+ TEST_STRING +" ); s.split(true).length", - EXPECT_STRING.length, - eval("var s = new String( TEST_STRING ); s.split(true).length") ); - - for ( var i = 0; i < EXPECT_STRING.length; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( "+TEST_STRING+" ); s.split(true)["+i+"]", - EXPECT_STRING[i], - eval("var s = new String( TEST_STRING ); s.split(true)["+i+"]") ); - } - - // case where the value of the separator is a number - TEST_STRING = "this123is123a123string123object"; - var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); - - array[item++] = new TestCase( SECTION, - "var s = new String( "+ TEST_STRING +" ); s.split(123).length", - EXPECT_STRING.length, - eval("var s = new String( TEST_STRING ); s.split(123).length") ); - - for ( var i = 0; i < EXPECT_STRING.length; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", - EXPECT_STRING[i], - eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); - } - - - // case where the value of the separator is a number - TEST_STRING = "this123is123a123string123object"; - var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); - - array[item++] = new TestCase( SECTION, - "var s = new String( "+ TEST_STRING +" ); s.split(123).length", - EXPECT_STRING.length, - eval("var s = new String( TEST_STRING ); s.split(123).length") ); - - for ( var i = 0; i < EXPECT_STRING.length; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", - EXPECT_STRING[i], - eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); - } - - // case where the separator is not in the string - TEST_STRING = "this is a string"; - EXPECT_STRING = new Array( "this is a string" ); - - array[item++] = new TestCase( SECTION, - "var s = new String( " + TEST_STRING + " ); s.split(':').length", - 1, - eval("var s = new String( TEST_STRING ); s.split(':').length") ); - - array[item++] = new TestCase( SECTION, - "var s = new String( " + TEST_STRING + " ); s.split(':')[0]", - TEST_STRING, - eval("var s = new String( TEST_STRING ); s.split(':')[0]") ); - - // case where part but not all of separator is in the string. - TEST_STRING = "this is a string"; - EXPECT_STRING = new Array( "this is a string" ); - array[item++] = new TestCase( SECTION, - "var s = new String( " + TEST_STRING + " ); s.split('strings').length", - 1, - eval("var s = new String( TEST_STRING ); s.split('strings').length") ); - - array[item++] = new TestCase( SECTION, - "var s = new String( " + TEST_STRING + " ); s.split('strings')[0]", - TEST_STRING, - eval("var s = new String( TEST_STRING ); s.split('strings')[0]") ); - - // case where the separator is at the end of the string - TEST_STRING = "this is a string"; - EXPECT_STRING = new Array( "this is a " ); - array[item++] = new TestCase( SECTION, - "var s = new String( " + TEST_STRING + " ); s.split('string').length", - 2, - eval("var s = new String( TEST_STRING ); s.split('string').length") ); - - for ( var i = 0; i < EXPECT_STRING.length; i++ ) { - array[item++] = new TestCase( SECTION, - "var s = new String( "+TEST_STRING+" ); s.split('string')["+i+"]", - EXPECT_STRING[i], - eval("var s = new String( TEST_STRING ); s.split('string')["+i+"]") ); - } - return array; + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split('')["+i+"]", + TEST_STRING.charAt(i), + eval("var s = new String( TEST_STRING ); s.split('')["+i+"]") ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +// case where the value of the separator is undefined. in this case. the value of the separator +// should be ToString( separator ), or "undefined". + +var TEST_STRING = "thisundefinedisundefinedaundefinedstringundefinedobject"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(void 0).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(void 0).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(void 0)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(void 0)["+i+"]") ); } + +// case where the value of the separator is null. in this case the value of the separator is "null". +TEST_STRING = "thisnullisnullanullstringnullobject"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(null).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(null).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(null)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(null)["+i+"]") ); +} + +// case where the value of the separator is a boolean. +TEST_STRING = "thistrueistrueatruestringtrueobject"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(true).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(true).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(true)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(true)["+i+"]") ); +} + +// case where the value of the separator is a number +TEST_STRING = "this123is123a123string123object"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(123).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(123).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); +} + + +// case where the value of the separator is a number +TEST_STRING = "this123is123a123string123object"; +var EXPECT_STRING = new Array( "this", "is", "a", "string", "object" ); + +new TestCase( SECTION, + "var s = new String( "+ TEST_STRING +" ); s.split(123).length", + EXPECT_STRING.length, + eval("var s = new String( TEST_STRING ); s.split(123).length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split(123)["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split(123)["+i+"]") ); +} + +// case where the separator is not in the string +TEST_STRING = "this is a string"; +EXPECT_STRING = new Array( "this is a string" ); + +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split(':').length", + 1, + eval("var s = new String( TEST_STRING ); s.split(':').length") ); + +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split(':')[0]", + TEST_STRING, + eval("var s = new String( TEST_STRING ); s.split(':')[0]") ); + +// case where part but not all of separator is in the string. +TEST_STRING = "this is a string"; +EXPECT_STRING = new Array( "this is a string" ); +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('strings').length", + 1, + eval("var s = new String( TEST_STRING ); s.split('strings').length") ); + +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('strings')[0]", + TEST_STRING, + eval("var s = new String( TEST_STRING ); s.split('strings')[0]") ); + +// case where the separator is at the end of the string +TEST_STRING = "this is a string"; +EXPECT_STRING = new Array( "this is a " ); +new TestCase( SECTION, + "var s = new String( " + TEST_STRING + " ); s.split('string').length", + 2, + eval("var s = new String( TEST_STRING ); s.split('string').length") ); + +for ( var i = 0; i < EXPECT_STRING.length; i++ ) { + new TestCase( SECTION, + "var s = new String( "+TEST_STRING+" ); s.split('string')["+i+"]", + EXPECT_STRING[i], + eval("var s = new String( TEST_STRING ); s.split('string')["+i+"]") ); +} + +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.4.8-3.js b/mozilla/js/tests/ecma/String/15.5.4.8-3.js index f5734e8889b..4c26c8364ab 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.8-3.js +++ b/mozilla/js/tests/ecma/String/15.5.4.8-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,187 +35,168 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.5.4.8-3.js - ECMA Section: 15.5.4.8 String.prototype.split( separator ) - Description: + File Name: 15.5.4.8-3.js + ECMA Section: 15.5.4.8 String.prototype.split( separator ) + Description: - Returns an Array object into which substrings of the result of converting - this object to a string have been stored. The substrings are determined by - searching from left to right for occurrences of the given separator; these - occurrences are not part of any substring in the returned array, but serve - to divide up this string value. The separator may be a string of any length. + Returns an Array object into which substrings of the result of converting + this object to a string have been stored. The substrings are determined by + searching from left to right for occurrences of the given separator; these + occurrences are not part of any substring in the returned array, but serve + to divide up this string value. The separator may be a string of any length. - As a special case, if the separator is the empty string, the string is split - up into individual characters; the length of the result array equals the - length of the string, and each substring contains one character. + As a special case, if the separator is the empty string, the string is split + up into individual characters; the length of the result array equals the + length of the string, and each substring contains one character. - If the separator is not supplied, then the result array contains just one - string, which is the string. + If the separator is not supplied, then the result array contains just one + string, which is the string. - When the split method is called with one argument separator, the following steps are taken: + When the split method is called with one argument separator, the following steps are taken: 1. Call ToString, giving it the this value as its argument. 2. Create a new Array object of length 0 and call it A. 3. If separator is not supplied, call the [[Put]] method of A with 0 and - Result(1) as arguments, and then return A. + Result(1) as arguments, and then return A. 4. Call ToString(separator). 5. Compute the number of characters in Result(1). 6. Compute the number of characters in the string that is Result(4). 7. Let p be 0. 8. If Result(6) is zero (the separator string is empty), go to step 17. 9. Compute the smallest possible integer k not smaller than p such that - k+Result(6) is not greater than Result(5), and for all nonnegative - integers j less than Result(6), the character at position k+j of - Result(1) is the same as the character at position j of Result(2); - but if there is no such integer k, then go to step 14. - 10. Compute a string value equal to the substring of Result(1), consisting - of the characters at positions p through k1, inclusive. - 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. - 12. Let p be k+Result(6). - 13. Go to step 9. - 14. Compute a string value equal to the substring of Result(1), consisting - of the characters from position p to the end of Result(1). - 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. - 16. Return A. - 17. If p equals Result(5), return A. - 18. Compute a string value equal to the substring of Result(1), consisting of - the single character at position p. - 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. - 20. Increase p by 1. - 21. Go to step 17. + k+Result(6) is not greater than Result(5), and for all nonnegative + integers j less than Result(6), the character at position k+j of + Result(1) is the same as the character at position j of Result(2); + but if there is no such integer k, then go to step 14. + 10. Compute a string value equal to the substring of Result(1), consisting + of the characters at positions p through k1, inclusive. + 11. Call the [[Put]] method of A with A.length and Result(10) as arguments. + 12. Let p be k+Result(6). + 13. Go to step 9. + 14. Compute a string value equal to the substring of Result(1), consisting + of the characters from position p to the end of Result(1). + 15. Call the [[Put]] method of A with A.length and Result(14) as arguments. + 16. Return A. + 17. If p equals Result(5), return A. + 18. Compute a string value equal to the substring of Result(1), consisting of + the single character at position p. + 19. Call the [[Put]] method of A with A.length and Result(18) as arguments. + 20. Increase p by 1. + 21. Go to step 17. -Note that the split function is intentionally generic; it does not require that its this value be a String -object. Therefore it can be transferred to other kinds of objects for use as a method. + Note that the split function is intentionally generic; it does not require that its this value be a String + object. Therefore it can be transferred to other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "15.5.4.8-3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.split"; +var SECTION = "15.5.4.8-3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.split"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +var TEST_STRING = ""; +var EXPECT = new Array(); -function getTestCases() { - var array = new Array(); - var item = 0; +// this.toString is the empty string. - var TEST_STRING = ""; - var EXPECT = new Array(); +new TestCase( SECTION, + "var s = new String(); s.split().length", + 1, + eval("var s = new String(); s.split().length") ); - // this.toString is the empty string. +new TestCase( SECTION, + "var s = new String(); s.split()[0]", + "", + eval("var s = new String(); s.split()[0]") ); - array[item++] = new TestCase( SECTION, - "var s = new String(); s.split().length", - 1, - eval("var s = new String(); s.split().length") ); +// this.toString() is the empty string, separator is specified. - array[item++] = new TestCase( SECTION, - "var s = new String(); s.split()[0]", - "", - eval("var s = new String(); s.split()[0]") ); +new TestCase( SECTION, + "var s = new String(); s.split('').length", + 0, + eval("var s = new String(); s.split('').length") ); - // this.toString() is the empty string, separator is specified. +new TestCase( SECTION, + "var s = new String(); s.split(' ').length", + 1, + eval("var s = new String(); s.split(' ').length") ); - array[item++] = new TestCase( SECTION, - "var s = new String(); s.split('').length", - 0, - eval("var s = new String(); s.split('').length") ); +// this to string is " " +new TestCase( SECTION, + "var s = new String(' '); s.split().length", + 1, + eval("var s = new String(' '); s.split().length") ); - array[item++] = new TestCase( SECTION, - "var s = new String(); s.split(' ').length", - 1, - eval("var s = new String(); s.split(' ').length") ); +new TestCase( SECTION, + "var s = new String(' '); s.split()[0]", + " ", + eval("var s = new String(' '); s.split()[0]") ); - // this to string is " " - array[item++] = new TestCase( SECTION, - "var s = new String(' '); s.split().length", - 1, - eval("var s = new String(' '); s.split().length") ); +new TestCase( SECTION, + "var s = new String(' '); s.split('').length", + 1, + eval("var s = new String(' '); s.split('').length") ); - array[item++] = new TestCase( SECTION, - "var s = new String(' '); s.split()[0]", - " ", - eval("var s = new String(' '); s.split()[0]") ); +new TestCase( SECTION, + "var s = new String(' '); s.split('')[0]", + " ", + eval("var s = new String(' '); s.split('')[0]") ); - array[item++] = new TestCase( SECTION, - "var s = new String(' '); s.split('').length", - 1, - eval("var s = new String(' '); s.split('').length") ); +new TestCase( SECTION, + "var s = new String(' '); s.split(' ').length", + 2, + eval("var s = new String(' '); s.split(' ').length") ); - array[item++] = new TestCase( SECTION, - "var s = new String(' '); s.split('')[0]", - " ", - eval("var s = new String(' '); s.split('')[0]") ); +new TestCase( SECTION, + "var s = new String(' '); s.split(' ')[0]", + "", + eval("var s = new String(' '); s.split(' ')[0]") ); - array[item++] = new TestCase( SECTION, - "var s = new String(' '); s.split(' ').length", - 2, - eval("var s = new String(' '); s.split(' ').length") ); +new TestCase( SECTION, + "\"\".split(\"\").length", + 0, + ("".split("")).length ); - array[item++] = new TestCase( SECTION, - "var s = new String(' '); s.split(' ')[0]", - "", - eval("var s = new String(' '); s.split(' ')[0]") ); +new TestCase( SECTION, + "\"\".split(\"x\").length", + 1, + ("".split("x")).length ); - array[item++] = new TestCase( SECTION, - "\"\".split(\"\").length", - 0, - ("".split("")).length ); +new TestCase( SECTION, + "\"\".split(\"x\")[0]", + "", + ("".split("x"))[0] ); - array[item++] = new TestCase( SECTION, - "\"\".split(\"x\").length", - 1, - ("".split("x")).length ); +test(); - array[item++] = new TestCase( SECTION, - "\"\".split(\"x\")[0]", - "", - ("".split("x"))[0] ); - - return array; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function Split( string, separator ) { - string = String( string ); + string = String( string ); - var A = new Array(); + var A = new Array(); - if ( arguments.length < 2 ) { - A[0] = string; - return A; - } - - separator = String( separator ); - - var str_len = String( string ).length; - var sep_len = String( separator ).length; - - var p = 0; - var k = 0; - - if ( sep_len == 0 ) { - for ( ; p < str_len; p++ ) { - A[A.length] = String( string.charAt(p) ); - } - } + if ( arguments.length < 2 ) { + A[0] = string; return A; + } + + separator = String( separator ); + + var str_len = String( string ).length; + var sep_len = String( separator ).length; + + var p = 0; + var k = 0; + + if ( sep_len == 0 ) { + for ( ; p < str_len; p++ ) { + A[A.length] = String( string.charAt(p) ); + } + } + return A; } diff --git a/mozilla/js/tests/ecma/String/15.5.4.9-1.js b/mozilla/js/tests/ecma/String/15.5.4.9-1.js index 7c3c678a208..0cccf0a315c 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.9-1.js +++ b/mozilla/js/tests/ecma/String/15.5.4.9-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,184 +35,166 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.9-1.js - ECMA Section: 15.5.4.9 String.prototype.substring( start ) - Description: - - 15.5.4.9 String.prototype.substring(start) - - Returns a substring of the result of converting this object to a string, - starting from character position start and running to the end of the - string. The result is a string value, not a String object. - - If the argument is NaN or negative, it is replaced with zero; if the - argument is larger than the length of the string, it is replaced with the - length of the string. - - When the substring method is called with one argument start, the following - steps are taken: - - 1.Call ToString, giving it the this value as its argument. - 2.Call ToInteger(start). - 3.Compute the number of characters in Result(1). - 4.Compute min(max(Result(2), 0), Result(3)). - 5.Return a string whose length is the difference between Result(3) and Result(4), - containing characters from Result(1), namely the characters with indices Result(4) - through Result(3)1, in ascending order. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ - - var SECTION = "15.5.4.9-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.prototype.substring( start )"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); - array[item++] = new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); - - // test cases for when substring is called with no arguments. - - // this is a string object - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); typeof s.substring()", - "string", - eval("var s = new String('this is a string object'); typeof s.substring()") ); - - array[item++] = new TestCase( SECTION, - "var s = new String(''); s.substring()", - "", - eval("var s = new String(''); s.substring()") ); - - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring()", - "this is a string object", - eval("var s = new String('this is a string object'); s.substring()") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(NaN)", - "this is a string object", - eval("var s = new String('this is a string object'); s.substring(NaN)") ); - - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(-0.01)", - "this is a string object", - eval("var s = new String('this is a string object'); s.substring(-0.01)") ); - - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(s.length)", - "", - eval("var s = new String('this is a string object'); s.substring(s.length)") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(s.length+1)", - "", - eval("var s = new String('this is a string object'); s.substring(s.length+1)") ); - - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(Infinity)", - "", - eval("var s = new String('this is a string object'); s.substring(Infinity)") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('this is a string object'); s.substring(-Infinity)", - "this is a string object", - eval("var s = new String('this is a string object'); s.substring(-Infinity)") ); - - // this is not a String object, start is not an integer - - - array[item++] = new TestCase( SECTION, - "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()", - "1,2,3,4,5", - eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()") ); - - array[item++] = new TestCase( SECTION, - "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)", - ",2,3,4,5", - eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)") ); - - array[item++] = new TestCase( SECTION, - "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')", - "3,4,5", - eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')") ); - - array[item++] = new TestCase( SECTION, - "var s = new Array(); s.substring = String.prototype.substring; s.substring('4')", - "", - eval("var s = new Array(); s.substring = String.prototype.substring; s.substring('4')") ); - - // this is an object object - array[item++] = new TestCase( SECTION, - "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)", - "Object]", - eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)") ); - - // this is a function object - array[item++] = new TestCase( SECTION, - "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)", - "Function]", - eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)") ); - // this is a number object - array[item++] = new TestCase( SECTION, - "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)", - "NaN", - eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)") ); - - // this is the Math object - array[item++] = new TestCase( SECTION, - "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)", - "ject Math]", - eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)") ); - - // this is a Boolean object - - array[item++] = new TestCase( SECTION, - "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())", - "false", - eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())") ); - - // this is a user defined object - - array[item++] = new TestCase( SECTION, - "var obj = new MyObject( null ); obj.substring(0)", - "null", - eval( "var obj = new MyObject( null ); obj.substring(0)") ); - - return array; -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function MyObject( value ) { - this.value = value; - this.substring = String.prototype.substring; - this.toString = new Function ( "return this.value+''" ); -} \ No newline at end of file + +/** + File Name: 15.5.4.9-1.js + ECMA Section: 15.5.4.9 String.prototype.substring( start ) + Description: + + 15.5.4.9 String.prototype.substring(start) + + Returns a substring of the result of converting this object to a string, + starting from character position start and running to the end of the + string. The result is a string value, not a String object. + + If the argument is NaN or negative, it is replaced with zero; if the + argument is larger than the length of the string, it is replaced with the + length of the string. + + When the substring method is called with one argument start, the following + steps are taken: + + 1.Call ToString, giving it the this value as its argument. + 2.Call ToInteger(start). + 3.Compute the number of characters in Result(1). + 4.Compute min(max(Result(2), 0), Result(3)). + 5.Return a string whose length is the difference between Result(3) and Result(4), + containing characters from Result(1), namely the characters with indices Result(4) + through Result(3)1, in ascending order. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.4.9-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.prototype.substring( start )"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, "String.prototype.substring.length", 2, String.prototype.substring.length ); +new TestCase( SECTION, "delete String.prototype.substring.length", false, delete String.prototype.substring.length ); +new TestCase( SECTION, "delete String.prototype.substring.length; String.prototype.substring.length", 2, eval("delete String.prototype.substring.length; String.prototype.substring.length") ); + +// test cases for when substring is called with no arguments. + +// this is a string object + +new TestCase( SECTION, + "var s = new String('this is a string object'); typeof s.substring()", + "string", + eval("var s = new String('this is a string object'); typeof s.substring()") ); + +new TestCase( SECTION, + "var s = new String(''); s.substring()", + "", + eval("var s = new String(''); s.substring()") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring()", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring()") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(NaN)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(NaN)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-0.01)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(-0.01)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length)") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(s.length+1)", + "", + eval("var s = new String('this is a string object'); s.substring(s.length+1)") ); + + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(Infinity)", + "", + eval("var s = new String('this is a string object'); s.substring(Infinity)") ); + +new TestCase( SECTION, + "var s = new String('this is a string object'); s.substring(-Infinity)", + "this is a string object", + eval("var s = new String('this is a string object'); s.substring(-Infinity)") ); + +// this is not a String object, start is not an integer + + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()", + "1,2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring()") ); + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)", + ",2,3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring(true)") ); + +new TestCase( SECTION, + "var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')", + "3,4,5", + eval("var s = new Array(1,2,3,4,5); s.substring = String.prototype.substring; s.substring('4')") ); + +new TestCase( SECTION, + "var s = new Array(); s.substring = String.prototype.substring; s.substring('4')", + "", + eval("var s = new Array(); s.substring = String.prototype.substring; s.substring('4')") ); + +// this is an object object +new TestCase( SECTION, + "var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)", + "Object]", + eval("var obj = new Object(); obj.substring = String.prototype.substring; obj.substring(8)") ); + +// this is a function object +new TestCase( SECTION, + "var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)", + "Function]", + eval("var obj = new Function(); obj.substring = String.prototype.substring; obj.toString = Object.prototype.toString; obj.substring(8)") ); +// this is a number object +new TestCase( SECTION, + "var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)", + "NaN", + eval("var obj = new Number(NaN); obj.substring = String.prototype.substring; obj.substring(false)") ); + +// this is the Math object +new TestCase( SECTION, + "var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)", + "ject Math]", + eval("var obj = Math; obj.substring = String.prototype.substring; obj.substring(Math.PI)") ); + +// this is a Boolean object + +new TestCase( SECTION, + "var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())", + "false", + eval("var obj = new Boolean(); obj.substring = String.prototype.substring; obj.substring(new Array())") ); + +// this is a user defined object + +new TestCase( SECTION, + "var obj = new MyObject( null ); obj.substring(0)", + "null", + eval( "var obj = new MyObject( null ); obj.substring(0)") ); + + +test(); + +function MyObject( value ) { + this.value = value; + this.substring = String.prototype.substring; + this.toString = new Function ( "return this.value+''" ); +} diff --git a/mozilla/js/tests/ecma/String/15.5.4.js b/mozilla/js/tests/ecma/String/15.5.4.js index e562550fe1e..2e8b27c1cb0 100644 --- a/mozilla/js/tests/ecma/String/15.5.4.js +++ b/mozilla/js/tests/ecma/String/15.5.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,56 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.4.js - ECMA Section: 15.5.4 Properties of the String prototype object - Description: - Author: christine@netscape.com - Date: 28 october 1997 +/** + File Name: 15.5.4.js + ECMA Section: 15.5.4 Properties of the String prototype object + + Description: + Author: christine@netscape.com + Date: 28 october 1997 */ - var SECTION = "15.5.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Properties of the String Prototype objecta"; +var SECTION = "15.5.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Properties of the String Prototype objecta"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()", - "[object String]", - eval("String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()") ); - - array[item++] = new TestCase( SECTION, "typeof String.prototype", "object", typeof String.prototype ); - array[item++] = new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); - array[item++] = new TestCase( SECTION, "String.prototype +''", "", String.prototype + '' ); - array[item++] = new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); -// array[item++] = new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); +writeHeaderToLog( SECTION + " "+ TITLE); - return ( array ); -} -function test( array ) { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase( SECTION, + "String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()", + "[object String]", + eval("String.prototype.getClass = Object.prototype.toString; String.prototype.getClass()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; +new TestCase( SECTION, "typeof String.prototype", "object", typeof String.prototype ); +new TestCase( SECTION, "String.prototype.valueOf()", "", String.prototype.valueOf() ); +new TestCase( SECTION, "String.prototype +''", "", String.prototype + '' ); +new TestCase( SECTION, "String.prototype.length", 0, String.prototype.length ); +// new TestCase( SECTION, "String.prototype.__proto__", Object.prototype, String.prototype.__proto__ ); - } - - stopTest(); - - // all tests must return an array of TestCase objects - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/ecma/String/15.5.5.1.js b/mozilla/js/tests/ecma/String/15.5.5.1.js index 91eaa5c7921..c9abcf174d0 100644 --- a/mozilla/js/tests/ecma/String/15.5.5.1.js +++ b/mozilla/js/tests/ecma/String/15.5.5.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 15.5.5.1 - ECMA Section: String.length - Description: - - The number of characters in the String value represented by this String - object. - - Once a String object is created, this property is unchanging. It has the - attributes { DontEnum, DontDelete, ReadOnly }. - - Author: christine@netscape.com - Date: 12 november 1997 -*/ - - var SECTION = "15.5.5.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "String.length"; - - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function getTestCases() { - var array = new Array(); - var item = 0; - - array[item++] = new TestCase( SECTION, - "var s = new String(); s.length", - 0, - eval("var s = new String(); s.length") ); - - array[item++] = new TestCase( SECTION, - "var s = new String(); s.length = 10; s.length", - 0, - eval("var s = new String(); s.length = 10; s.length") ); - - array[item++] = new TestCase( SECTION, - "var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props", - "", - eval("var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props") ); - - array[item++] = new TestCase( SECTION, - "var s = new String(); delete s.length", - false, - eval("var s = new String(); delete s.length") ); - - array[item++] = new TestCase( SECTION, - "var s = new String('hello'); delete s.length; s.length", - 5, - eval("var s = new String('hello'); delete s.length; s.length") ); - return array; - -} -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} + +/** + File Name: 15.5.5.1 + ECMA Section: String.length + Description: + + The number of characters in the String value represented by this String + object. + + Once a String object is created, this property is unchanging. It has the + attributes { DontEnum, DontDelete, ReadOnly }. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "15.5.5.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "String.length"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( SECTION, + "var s = new String(); s.length", + 0, + eval("var s = new String(); s.length") ); + +new TestCase( SECTION, + "var s = new String(); s.length = 10; s.length", + 0, + eval("var s = new String(); s.length = 10; s.length") ); + +new TestCase( SECTION, + "var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props", + "", + eval("var s = new String(); var props = ''; for ( var p in s ) { props += p; }; props") ); + +new TestCase( SECTION, + "var s = new String(); delete s.length", + false, + eval("var s = new String(); delete s.length") ); + +new TestCase( SECTION, + "var s = new String('hello'); delete s.length; s.length", + 5, + eval("var s = new String('hello'); delete s.length; s.length") ); + +test(); diff --git a/mozilla/js/tests/ecma/String/browser.js b/mozilla/js/tests/ecma/String/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/String/shell.js b/mozilla/js/tests/ecma/String/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/TypeConversion/9.2.js b/mozilla/js/tests/ecma/TypeConversion/9.2.js index 1b927d1eb98..981392287ea 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.2.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,79 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.2.js - ECMA Section: 9.2 Type Conversion: ToBoolean - Description: rules for converting an argument to a boolean. - undefined false - Null false - Boolean input argument( no conversion ) - Number returns false for 0, -0, and NaN - otherwise return true - String return false if the string is empty - (length is 0) otherwise the result is - true - Object all return true + File Name: 9.2.js + ECMA Section: 9.2 Type Conversion: ToBoolean + Description: rules for converting an argument to a boolean. + undefined false + Null false + Boolean input argument( no conversion ) + Number returns false for 0, -0, and NaN + otherwise return true + String return false if the string is empty + (length is 0) otherwise the result is + true + Object all return true - Author: christine@netscape.com - Date: 14 july 1997 + Author: christine@netscape.com + Date: 14 july 1997 */ - var SECTION = "9.2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "ToBoolean"; +var SECTION = "9.2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToBoolean"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// special cases here - // special cases here +new TestCase( SECTION, "Boolean()", false, Boolean() ); +new TestCase( SECTION, "Boolean(var x)", false, Boolean(eval("var x")) ); +new TestCase( SECTION, "Boolean(void 0)", false, Boolean(void 0) ); +new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); +new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); +new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); +new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); +new TestCase( SECTION, "Boolean(-0)", false, Boolean(-0) ); +new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); +new TestCase( SECTION, "Boolean('')", false, Boolean("") ); - testcases[tc++] = new TestCase( SECTION, "Boolean()", false, Boolean() ); - testcases[tc++] = new TestCase( SECTION, "Boolean(var x)", false, Boolean(eval("var x")) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(void 0)", false, Boolean(void 0) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(null)", false, Boolean(null) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(false)", false, Boolean(false) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(true)", true, Boolean(true) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(0)", false, Boolean(0) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(-0)", false, Boolean(-0) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(NaN)", false, Boolean(Number.NaN) ); - testcases[tc++] = new TestCase( SECTION, "Boolean('')", false, Boolean("") ); +// normal test cases here - // normal test cases here +new TestCase( SECTION, "Boolean(Infinity)", true, Boolean(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "Boolean(Math.PI)", true, Boolean(Math.PI) ); +new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); +new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); +new TestCase( SECTION, "Boolean([tab])", true, Boolean("\t") ); +new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); +new TestCase( SECTION, "Boolean('string')", true, Boolean("string") ); - testcases[tc++] = new TestCase( SECTION, "Boolean(Infinity)", true, Boolean(Number.POSITIVE_INFINITY) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(-Infinity)", true, Boolean(Number.NEGATIVE_INFINITY) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(Math.PI)", true, Boolean(Math.PI) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(1)", true, Boolean(1) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(-1)", true, Boolean(-1) ); - testcases[tc++] = new TestCase( SECTION, "Boolean([tab])", true, Boolean("\t") ); - testcases[tc++] = new TestCase( SECTION, "Boolean('0')", true, Boolean("0") ); - testcases[tc++] = new TestCase( SECTION, "Boolean('string')", true, Boolean("string") ); +// ToBoolean (object) should always return true. +new TestCase( SECTION, "Boolean(new String() )", true, Boolean(new String()) ); +new TestCase( SECTION, "Boolean(new String('') )", true, Boolean(new String("")) ); - // ToBoolean (object) should always return true. - testcases[tc++] = new TestCase( SECTION, "Boolean(new String() )", true, Boolean(new String()) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new String('') )", true, Boolean(new String("")) ); +new TestCase( SECTION, "Boolean(new Boolean(true))", true, Boolean(new Boolean(true)) ); +new TestCase( SECTION, "Boolean(new Boolean(false))", true, Boolean(new Boolean(false)) ); +new TestCase( SECTION, "Boolean(new Boolean() )", true, Boolean(new Boolean()) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean(true))", true, Boolean(new Boolean(true)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean(false))", true, Boolean(new Boolean(false)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Boolean() )", true, Boolean(new Boolean()) ); +new TestCase( SECTION, "Boolean(new Array())", true, Boolean(new Array()) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Array())", true, Boolean(new Array()) ); +new TestCase( SECTION, "Boolean(new Number())", true, Boolean(new Number()) ); +new TestCase( SECTION, "Boolean(new Number(-0))", true, Boolean(new Number(-0)) ); +new TestCase( SECTION, "Boolean(new Number(0))", true, Boolean(new Number(0)) ); +new TestCase( SECTION, "Boolean(new Number(NaN))", true, Boolean(new Number(Number.NaN)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Number())", true, Boolean(new Number()) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-0))", true, Boolean(new Number(-0)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(0))", true, Boolean(new Number(0)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(NaN))", true, Boolean(new Number(Number.NaN)) ); +new TestCase( SECTION, "Boolean(new Number(-1))", true, Boolean(new Number(-1)) ); +new TestCase( SECTION, "Boolean(new Number(Infinity))", true, Boolean(new Number(Number.POSITIVE_INFINITY)) ); +new TestCase( SECTION, "Boolean(new Number(-Infinity))",true, Boolean(new Number(Number.NEGATIVE_INFINITY)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-1))", true, Boolean(new Number(-1)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(Infinity))", true, Boolean(new Number(Number.POSITIVE_INFINITY)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Number(-Infinity))",true, Boolean(new Number(Number.NEGATIVE_INFINITY)) ); +new TestCase( SECTION, "Boolean(new Object())", true, Boolean(new Object()) ); +new TestCase( SECTION, "Boolean(new Function())", true, Boolean(new Function()) ); +new TestCase( SECTION, "Boolean(new Date())", true, Boolean(new Date()) ); +new TestCase( SECTION, "Boolean(new Date(0))", true, Boolean(new Date(0)) ); +new TestCase( SECTION, "Boolean(Math)", true, Boolean(Math) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Object())", true, Boolean(new Object()) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Function())", true, Boolean(new Function()) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Date())", true, Boolean(new Date()) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(new Date(0))", true, Boolean(new Date(0)) ); - testcases[tc++] = new TestCase( SECTION, "Boolean(Math)", true, Boolean(Math) ); +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/TypeConversion/9.3-1.js b/mozilla/js/tests/ecma/TypeConversion/9.3-1.js index 32e22abe663..59b459411b1 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.3-1.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,78 +35,77 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.3-1.js - ECMA Section: 9.3 Type Conversion: ToNumber - Description: rules for converting an argument to a number. - see 9.3.1 for cases for converting strings to numbers. - special cases: - undefined NaN - Null NaN - Boolean 1 if true; +0 if false - Number the argument ( no conversion ) - String see test 9.3.1 - Object see test 9.3-1 + File Name: 9.3-1.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 - This tests ToNumber applied to the object type, except - if object is string. See 9.3-2 for - ToNumber( String object). + This tests ToNumber applied to the object type, except + if object is string. See 9.3-2 for + ToNumber( String object). - Author: christine@netscape.com - Date: 10 july 1997 + Author: christine@netscape.com + Date: 10 july 1997 */ - var SECTION = "9.3-1"; - var VERSION = "ECMA_1"; - startTest(); - var TYPE = "number"; - var testcases = getTestCases(); +var SECTION = "9.3-1"; +var VERSION = "ECMA_1"; +startTest(); +var TYPE = "number"; - writeHeaderToLog( SECTION + " ToNumber"); - test(); +writeHeaderToLog( SECTION + " ToNumber"); +// object is Number +new TestCase( SECTION, "Number(new Number())", 0, Number(new Number()) ); +new TestCase( SECTION, "Number(new Number(Number.NaN))",Number.NaN, Number(new Number(Number.NaN)) ); +new TestCase( SECTION, "Number(new Number(0))", 0, Number(new Number(0)) ); +new TestCase( SECTION, "Number(new Number(null))", 0, Number(new Number(null)) ); +// new TestCase( SECTION, "Number(new Number(void 0))", Number.NaN, Number(new Number(void 0)) ); +new TestCase( SECTION, "Number(new Number(true))", 1, Number(new Number(true)) ); +new TestCase( SECTION, "Number(new Number(false))", 0, Number(new Number(false)) ); + +// object is boolean + +new TestCase( SECTION, "Number(new Boolean(true))", 1, Number(new Boolean(true)) ); +new TestCase( SECTION, "Number(new Boolean(false))", 0, Number(new Boolean(false)) ); + +// object is array +new TestCase( SECTION, "Number(new Array(2,4,8,16,32))", Number.NaN, Number(new Array(2,4,8,16,32)) ); + + + + +test(); + +// XXX bc replace test() function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); - testcases[tc].passed = writeTestCaseResult( - TYPE, - typeof(testcases[tc].actual), - "typeof( " + testcases[tc].description + - " ) = " + typeof(testcases[tc].actual) ) - ? testcases[tc].passed - : false; + testcases[tc].passed = writeTestCaseResult( + TYPE, + typeof(testcases[tc].actual), + "typeof( " + testcases[tc].description + + " ) = " + typeof(testcases[tc].actual) ) + ? testcases[tc].passed + : false; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - // object is Number - array[item++] = new TestCase( SECTION, "Number(new Number())", 0, Number(new Number()) ); - array[item++] = new TestCase( SECTION, "Number(new Number(Number.NaN))",Number.NaN, Number(new Number(Number.NaN)) ); - array[item++] = new TestCase( SECTION, "Number(new Number(0))", 0, Number(new Number(0)) ); - array[item++] = new TestCase( SECTION, "Number(new Number(null))", 0, Number(new Number(null)) ); -// array[item++] = new TestCase( SECTION, "Number(new Number(void 0))", Number.NaN, Number(new Number(void 0)) ); - array[item++] = new TestCase( SECTION, "Number(new Number(true))", 1, Number(new Number(true)) ); - array[item++] = new TestCase( SECTION, "Number(new Number(false))", 0, Number(new Number(false)) ); - - // object is boolean - - array[item++] = new TestCase( SECTION, "Number(new Boolean(true))", 1, Number(new Boolean(true)) ); - array[item++] = new TestCase( SECTION, "Number(new Boolean(false))", 0, Number(new Boolean(false)) ); - - // object is array - array[item++] = new TestCase( SECTION, "Number(new Array(2,4,8,16,32))", Number.NaN, Number(new Array(2,4,8,16,32)) ); - - return ( array ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); } diff --git a/mozilla/js/tests/ecma/TypeConversion/9.3.1-1.js b/mozilla/js/tests/ecma/TypeConversion/9.3.1-1.js index be9e00e6450..48fa6e40c3c 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.3.1-1.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.3.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,304 +36,284 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 9.3.1-1.js - ECMA Section: 9.3 Type Conversion: ToNumber - Description: rules for converting an argument to a number. - see 9.3.1 for cases for converting strings to numbers. - special cases: - undefined NaN - Null NaN - Boolean 1 if true; +0 if false - Number the argument ( no conversion ) - String see test 9.3.1 - Object see test 9.3-1 + File Name: 9.3.1-1.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 - This tests ToNumber applied to the string type + This tests ToNumber applied to the string type - Author: christine@netscape.com - Date: 10 july 1997 + Author: christine@netscape.com + Date: 10 july 1997 */ - var SECTION = "9.3.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "ToNumber applied to the String type"; - var BUGNUMBER="77391"; +var SECTION = "9.3.1-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToNumber applied to the String type"; +var BUGNUMBER="77391"; - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = getTestCases(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; - - // StringNumericLiteral:::StrWhiteSpace:::StrWhiteSpaceChar StrWhiteSpace::: - // - // Name Unicode Value Escape Sequence - // 0X0009 \t - // 0X0020 - // 0X000C \f - // 0X000B - // 0X000D \r - // 0X000A \n - array[item++] = new TestCase( SECTION, "Number('')", 0, Number("") ); - array[item++] = new TestCase( SECTION, "Number(' ')", 0, Number(" ") ); - array[item++] = new TestCase( SECTION, "Number(\\t)", 0, Number("\t") ); - array[item++] = new TestCase( SECTION, "Number(\\n)", 0, Number("\n") ); - array[item++] = new TestCase( SECTION, "Number(\\r)", 0, Number("\r") ); - array[item++] = new TestCase( SECTION, "Number(\\f)", 0, Number("\f") ); - - array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x0009)", 0, Number(String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x0020)", 0, Number(String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000C)", 0, Number(String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000B)", 0, Number(String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000D)", 0, Number(String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "Number(String.fromCharCode(0x000A)", 0, Number(String.fromCharCode(0x000A)) ); - - // a StringNumericLiteral may be preceeded or followed by whitespace and/or - // line terminators - - array[item++] = new TestCase( SECTION, "Number( ' ' + 999 )", 999, Number( ' '+999) ); - array[item++] = new TestCase( SECTION, "Number( '\\n' + 999 )", 999, Number( '\n' +999) ); - array[item++] = new TestCase( SECTION, "Number( '\\r' + 999 )", 999, Number( '\r' +999) ); - array[item++] = new TestCase( SECTION, "Number( '\\t' + 999 )", 999, Number( '\t' +999) ); - array[item++] = new TestCase( SECTION, "Number( '\\f' + 999 )", 999, Number( '\f' +999) ); - - array[item++] = new TestCase( SECTION, "Number( 999 + ' ' )", 999, Number( 999+' ') ); - array[item++] = new TestCase( SECTION, "Number( 999 + '\\n' )", 999, Number( 999+'\n' ) ); - array[item++] = new TestCase( SECTION, "Number( 999 + '\\r' )", 999, Number( 999+'\r' ) ); - array[item++] = new TestCase( SECTION, "Number( 999 + '\\t' )", 999, Number( 999+'\t' ) ); - array[item++] = new TestCase( SECTION, "Number( 999 + '\\f' )", 999, Number( 999+'\f' ) ); - - array[item++] = new TestCase( SECTION, "Number( '\\n' + 999 + '\\n' )", 999, Number( '\n' +999+'\n' ) ); - array[item++] = new TestCase( SECTION, "Number( '\\r' + 999 + '\\r' )", 999, Number( '\r' +999+'\r' ) ); - array[item++] = new TestCase( SECTION, "Number( '\\t' + 999 + '\\t' )", 999, Number( '\t' +999+'\t' ) ); - array[item++] = new TestCase( SECTION, "Number( '\\f' + 999 + '\\f' )", 999, Number( '\f' +999+'\f' ) ); - - array[item++] = new TestCase( SECTION, "Number( ' ' + '999' )", 999, Number( ' '+'999') ); - array[item++] = new TestCase( SECTION, "Number( '\\n' + '999' )", 999, Number( '\n' +'999') ); - array[item++] = new TestCase( SECTION, "Number( '\\r' + '999' )", 999, Number( '\r' +'999') ); - array[item++] = new TestCase( SECTION, "Number( '\\t' + '999' )", 999, Number( '\t' +'999') ); - array[item++] = new TestCase( SECTION, "Number( '\\f' + '999' )", 999, Number( '\f' +'999') ); - - array[item++] = new TestCase( SECTION, "Number( '999' + ' ' )", 999, Number( '999'+' ') ); - array[item++] = new TestCase( SECTION, "Number( '999' + '\\n' )", 999, Number( '999'+'\n' ) ); - array[item++] = new TestCase( SECTION, "Number( '999' + '\\r' )", 999, Number( '999'+'\r' ) ); - array[item++] = new TestCase( SECTION, "Number( '999' + '\\t' )", 999, Number( '999'+'\t' ) ); - array[item++] = new TestCase( SECTION, "Number( '999' + '\\f' )", 999, Number( '999'+'\f' ) ); - - array[item++] = new TestCase( SECTION, "Number( '\\n' + '999' + '\\n' )", 999, Number( '\n' +'999'+'\n' ) ); - array[item++] = new TestCase( SECTION, "Number( '\\r' + '999' + '\\r' )", 999, Number( '\r' +'999'+'\r' ) ); - array[item++] = new TestCase( SECTION, "Number( '\\t' + '999' + '\\t' )", 999, Number( '\t' +'999'+'\t' ) ); - array[item++] = new TestCase( SECTION, "Number( '\\f' + '999' + '\\f' )", 999, Number( '\f' +'999'+'\f' ) ); - - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' )", 99, Number( String.fromCharCode(0x0009) + '99' ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' )", 99, Number( String.fromCharCode(0x0020) + '99' ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' )", 99, Number( String.fromCharCode(0x000C) + '99' ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' )", 99, Number( String.fromCharCode(0x000B) + '99' ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' )", 99, Number( String.fromCharCode(0x000D) + '99' ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' )", 99, Number( String.fromCharCode(0x000A) + '99' ) ); - - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); - - array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0009)", 99, Number( '99' + String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0020)", 99, Number( '99' + String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000C)", 99, Number( '99' + String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000D)", 99, Number( '99' + String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000B)", 99, Number( '99' + String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000A)", 99, Number( '99' + String.fromCharCode(0x000A)) ); - - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 )", 99, Number( String.fromCharCode(0x0009) + 99 ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 )", 99, Number( String.fromCharCode(0x0020) + 99 ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 )", 99, Number( String.fromCharCode(0x000C) + 99 ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 )", 99, Number( String.fromCharCode(0x000B) + 99 ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 )", 99, Number( String.fromCharCode(0x000D) + 99 ) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 )", 99, Number( String.fromCharCode(0x000A) + 99 ) ); - - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); - - array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0009)", 99, Number( 99 + String.fromCharCode(0x0009)) ); - array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0020)", 99, Number( 99 + String.fromCharCode(0x0020)) ); - array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000C)", 99, Number( 99 + String.fromCharCode(0x000C)) ); - array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000D)", 99, Number( 99 + String.fromCharCode(0x000D)) ); - array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000B)", 99, Number( 99 + String.fromCharCode(0x000B)) ); - array[item++] = new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000A)", 99, Number( 99 + String.fromCharCode(0x000A)) ); +writeHeaderToLog( SECTION + " "+ TITLE); - // StrNumericLiteral:::StrDecimalLiteral:::Infinity +// StringNumericLiteral:::StrWhiteSpace:::StrWhiteSpaceChar StrWhiteSpace::: +// +// Name Unicode Value Escape Sequence +// 0X0009 \t +// 0X0020 +// 0X000C \f +// 0X000B +// 0X000D \r +// 0X000A \n +new TestCase( SECTION, "Number('')", 0, Number("") ); +new TestCase( SECTION, "Number(' ')", 0, Number(" ") ); +new TestCase( SECTION, "Number(\\t)", 0, Number("\t") ); +new TestCase( SECTION, "Number(\\n)", 0, Number("\n") ); +new TestCase( SECTION, "Number(\\r)", 0, Number("\r") ); +new TestCase( SECTION, "Number(\\f)", 0, Number("\f") ); - array[item++] = new TestCase( SECTION, "Number('Infinity')", Math.pow(10,10000), Number("Infinity") ); - array[item++] = new TestCase( SECTION, "Number('-Infinity')", -Math.pow(10,10000), Number("-Infinity") ); - array[item++] = new TestCase( SECTION, "Number('+Infinity')", Math.pow(10,10000), Number("+Infinity") ); +new TestCase( SECTION, "Number(String.fromCharCode(0x0009)", 0, Number(String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x0020)", 0, Number(String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x000C)", 0, Number(String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x000B)", 0, Number(String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x000D)", 0, Number(String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number(String.fromCharCode(0x000A)", 0, Number(String.fromCharCode(0x000A)) ); - // StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt +// a StringNumericLiteral may be preceeded or followed by whitespace and/or +// line terminators - array[item++] = new TestCase( SECTION, "Number('0')", 0, Number("0") ); - array[item++] = new TestCase( SECTION, "Number('-0')", -0, Number("-0") ); - array[item++] = new TestCase( SECTION, "Number('+0')", 0, Number("+0") ); +new TestCase( SECTION, "Number( ' ' + 999 )", 999, Number( ' '+999) ); +new TestCase( SECTION, "Number( '\\n' + 999 )", 999, Number( '\n' +999) ); +new TestCase( SECTION, "Number( '\\r' + 999 )", 999, Number( '\r' +999) ); +new TestCase( SECTION, "Number( '\\t' + 999 )", 999, Number( '\t' +999) ); +new TestCase( SECTION, "Number( '\\f' + 999 )", 999, Number( '\f' +999) ); - array[item++] = new TestCase( SECTION, "Number('1')", 1, Number("1") ); - array[item++] = new TestCase( SECTION, "Number('-1')", -1, Number("-1") ); - array[item++] = new TestCase( SECTION, "Number('+1')", 1, Number("+1") ); +new TestCase( SECTION, "Number( 999 + ' ' )", 999, Number( 999+' ') ); +new TestCase( SECTION, "Number( 999 + '\\n' )", 999, Number( 999+'\n' ) ); +new TestCase( SECTION, "Number( 999 + '\\r' )", 999, Number( 999+'\r' ) ); +new TestCase( SECTION, "Number( 999 + '\\t' )", 999, Number( 999+'\t' ) ); +new TestCase( SECTION, "Number( 999 + '\\f' )", 999, Number( 999+'\f' ) ); - array[item++] = new TestCase( SECTION, "Number('2')", 2, Number("2") ); - array[item++] = new TestCase( SECTION, "Number('-2')", -2, Number("-2") ); - array[item++] = new TestCase( SECTION, "Number('+2')", 2, Number("+2") ); +new TestCase( SECTION, "Number( '\\n' + 999 + '\\n' )", 999, Number( '\n' +999+'\n' ) ); +new TestCase( SECTION, "Number( '\\r' + 999 + '\\r' )", 999, Number( '\r' +999+'\r' ) ); +new TestCase( SECTION, "Number( '\\t' + 999 + '\\t' )", 999, Number( '\t' +999+'\t' ) ); +new TestCase( SECTION, "Number( '\\f' + 999 + '\\f' )", 999, Number( '\f' +999+'\f' ) ); - array[item++] = new TestCase( SECTION, "Number('3')", 3, Number("3") ); - array[item++] = new TestCase( SECTION, "Number('-3')", -3, Number("-3") ); - array[item++] = new TestCase( SECTION, "Number('+3')", 3, Number("+3") ); +new TestCase( SECTION, "Number( ' ' + '999' )", 999, Number( ' '+'999') ); +new TestCase( SECTION, "Number( '\\n' + '999' )", 999, Number( '\n' +'999') ); +new TestCase( SECTION, "Number( '\\r' + '999' )", 999, Number( '\r' +'999') ); +new TestCase( SECTION, "Number( '\\t' + '999' )", 999, Number( '\t' +'999') ); +new TestCase( SECTION, "Number( '\\f' + '999' )", 999, Number( '\f' +'999') ); - array[item++] = new TestCase( SECTION, "Number('4')", 4, Number("4") ); - array[item++] = new TestCase( SECTION, "Number('-4')", -4, Number("-4") ); - array[item++] = new TestCase( SECTION, "Number('+4')", 4, Number("+4") ); +new TestCase( SECTION, "Number( '999' + ' ' )", 999, Number( '999'+' ') ); +new TestCase( SECTION, "Number( '999' + '\\n' )", 999, Number( '999'+'\n' ) ); +new TestCase( SECTION, "Number( '999' + '\\r' )", 999, Number( '999'+'\r' ) ); +new TestCase( SECTION, "Number( '999' + '\\t' )", 999, Number( '999'+'\t' ) ); +new TestCase( SECTION, "Number( '999' + '\\f' )", 999, Number( '999'+'\f' ) ); - array[item++] = new TestCase( SECTION, "Number('5')", 5, Number("5") ); - array[item++] = new TestCase( SECTION, "Number('-5')", -5, Number("-5") ); - array[item++] = new TestCase( SECTION, "Number('+5')", 5, Number("+5") ); +new TestCase( SECTION, "Number( '\\n' + '999' + '\\n' )", 999, Number( '\n' +'999'+'\n' ) ); +new TestCase( SECTION, "Number( '\\r' + '999' + '\\r' )", 999, Number( '\r' +'999'+'\r' ) ); +new TestCase( SECTION, "Number( '\\t' + '999' + '\\t' )", 999, Number( '\t' +'999'+'\t' ) ); +new TestCase( SECTION, "Number( '\\f' + '999' + '\\f' )", 999, Number( '\f' +'999'+'\f' ) ); - array[item++] = new TestCase( SECTION, "Number('6')", 6, Number("6") ); - array[item++] = new TestCase( SECTION, "Number('-6')", -6, Number("-6") ); - array[item++] = new TestCase( SECTION, "Number('+6')", 6, Number("+6") ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' )", 99, Number( String.fromCharCode(0x0009) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' )", 99, Number( String.fromCharCode(0x0020) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' )", 99, Number( String.fromCharCode(0x000C) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' )", 99, Number( String.fromCharCode(0x000B) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' )", 99, Number( String.fromCharCode(0x000D) + '99' ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' )", 99, Number( String.fromCharCode(0x000A) + '99' ) ); - array[item++] = new TestCase( SECTION, "Number('7')", 7, Number("7") ); - array[item++] = new TestCase( SECTION, "Number('-7')", -7, Number("-7") ); - array[item++] = new TestCase( SECTION, "Number('+7')", 7, Number("+7") ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + '99' + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + '99' + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + '99' + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + '99' + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + '99' + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + '99' + String.fromCharCode(0x000A)) ); - array[item++] = new TestCase( SECTION, "Number('8')", 8, Number("8") ); - array[item++] = new TestCase( SECTION, "Number('-8')", -8, Number("-8") ); - array[item++] = new TestCase( SECTION, "Number('+8')", 8, Number("+8") ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0009)", 99, Number( '99' + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x0020)", 99, Number( '99' + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000C)", 99, Number( '99' + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000D)", 99, Number( '99' + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000B)", 99, Number( '99' + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number( '99' + String.fromCharCode(0x000A)", 99, Number( '99' + String.fromCharCode(0x000A)) ); - array[item++] = new TestCase( SECTION, "Number('9')", 9, Number("9") ); - array[item++] = new TestCase( SECTION, "Number('-9')", -9, Number("-9") ); - array[item++] = new TestCase( SECTION, "Number('+9')", 9, Number("+9") ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 )", 99, Number( String.fromCharCode(0x0009) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 )", 99, Number( String.fromCharCode(0x0020) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 )", 99, Number( String.fromCharCode(0x000C) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 )", 99, Number( String.fromCharCode(0x000B) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 )", 99, Number( String.fromCharCode(0x000D) + 99 ) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 )", 99, Number( String.fromCharCode(0x000A) + 99 ) ); - array[item++] = new TestCase( SECTION, "Number('3.14159')", 3.14159, Number("3.14159") ); - array[item++] = new TestCase( SECTION, "Number('-3.14159')", -3.14159, Number("-3.14159") ); - array[item++] = new TestCase( SECTION, "Number('+3.14159')", 3.14159, Number("+3.14159") ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x0020) + 99 + String.fromCharCode(0x0020)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000C) + 99 + String.fromCharCode(0x000C)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000D) + 99 + String.fromCharCode(0x000D)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000B) + 99 + String.fromCharCode(0x000B)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number( String.fromCharCode(0x000A) + 99 + String.fromCharCode(0x000A)", 99, Number( String.fromCharCode(0x0009) + 99 + String.fromCharCode(0x000A)) ); - array[item++] = new TestCase( SECTION, "Number('3.')", 3, Number("3.") ); - array[item++] = new TestCase( SECTION, "Number('-3.')", -3, Number("-3.") ); - array[item++] = new TestCase( SECTION, "Number('+3.')", 3, Number("+3.") ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0009)", 99, Number( 99 + String.fromCharCode(0x0009)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x0020)", 99, Number( 99 + String.fromCharCode(0x0020)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000C)", 99, Number( 99 + String.fromCharCode(0x000C)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000D)", 99, Number( 99 + String.fromCharCode(0x000D)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000B)", 99, Number( 99 + String.fromCharCode(0x000B)) ); +new TestCase( SECTION, "Number( 99 + String.fromCharCode(0x000A)", 99, Number( 99 + String.fromCharCode(0x000A)) ); - array[item++] = new TestCase( SECTION, "Number('3.e1')", 30, Number("3.e1") ); - array[item++] = new TestCase( SECTION, "Number('-3.e1')", -30, Number("-3.e1") ); - array[item++] = new TestCase( SECTION, "Number('+3.e1')", 30, Number("+3.e1") ); - array[item++] = new TestCase( SECTION, "Number('3.e+1')", 30, Number("3.e+1") ); - array[item++] = new TestCase( SECTION, "Number('-3.e+1')", -30, Number("-3.e+1") ); - array[item++] = new TestCase( SECTION, "Number('+3.e+1')", 30, Number("+3.e+1") ); +// StrNumericLiteral:::StrDecimalLiteral:::Infinity - array[item++] = new TestCase( SECTION, "Number('3.e-1')", .30, Number("3.e-1") ); - array[item++] = new TestCase( SECTION, "Number('-3.e-1')", -.30, Number("-3.e-1") ); - array[item++] = new TestCase( SECTION, "Number('+3.e-1')", .30, Number("+3.e-1") ); +new TestCase( SECTION, "Number('Infinity')", Math.pow(10,10000), Number("Infinity") ); +new TestCase( SECTION, "Number('-Infinity')", -Math.pow(10,10000), Number("-Infinity") ); +new TestCase( SECTION, "Number('+Infinity')", Math.pow(10,10000), Number("+Infinity") ); - // StrDecimalLiteral::: .DecimalDigits ExponentPart opt +// StrNumericLiteral::: StrDecimalLiteral ::: DecimalDigits . DecimalDigits opt ExponentPart opt - array[item++] = new TestCase( SECTION, "Number('.00001')", 0.00001, Number(".00001") ); - array[item++] = new TestCase( SECTION, "Number('+.00001')", 0.00001, Number("+.00001") ); - array[item++] = new TestCase( SECTION, "Number('-0.0001')", -0.00001, Number("-.00001") ); +new TestCase( SECTION, "Number('0')", 0, Number("0") ); +new TestCase( SECTION, "Number('-0')", -0, Number("-0") ); +new TestCase( SECTION, "Number('+0')", 0, Number("+0") ); - array[item++] = new TestCase( SECTION, "Number('.01e2')", 1, Number(".01e2") ); - array[item++] = new TestCase( SECTION, "Number('+.01e2')", 1, Number("+.01e2") ); - array[item++] = new TestCase( SECTION, "Number('-.01e2')", -1, Number("-.01e2") ); +new TestCase( SECTION, "Number('1')", 1, Number("1") ); +new TestCase( SECTION, "Number('-1')", -1, Number("-1") ); +new TestCase( SECTION, "Number('+1')", 1, Number("+1") ); - array[item++] = new TestCase( SECTION, "Number('.01e+2')", 1, Number(".01e+2") ); - array[item++] = new TestCase( SECTION, "Number('+.01e+2')", 1, Number("+.01e+2") ); - array[item++] = new TestCase( SECTION, "Number('-.01e+2')", -1, Number("-.01e+2") ); +new TestCase( SECTION, "Number('2')", 2, Number("2") ); +new TestCase( SECTION, "Number('-2')", -2, Number("-2") ); +new TestCase( SECTION, "Number('+2')", 2, Number("+2") ); - array[item++] = new TestCase( SECTION, "Number('.01e-2')", 0.0001, Number(".01e-2") ); - array[item++] = new TestCase( SECTION, "Number('+.01e-2')", 0.0001, Number("+.01e-2") ); - array[item++] = new TestCase( SECTION, "Number('-.01e-2')", -0.0001, Number("-.01e-2") ); +new TestCase( SECTION, "Number('3')", 3, Number("3") ); +new TestCase( SECTION, "Number('-3')", -3, Number("-3") ); +new TestCase( SECTION, "Number('+3')", 3, Number("+3") ); - // StrDecimalLiteral::: DecimalDigits ExponentPart opt +new TestCase( SECTION, "Number('4')", 4, Number("4") ); +new TestCase( SECTION, "Number('-4')", -4, Number("-4") ); +new TestCase( SECTION, "Number('+4')", 4, Number("+4") ); - array[item++] = new TestCase( SECTION, "Number('1234e5')", 123400000, Number("1234e5") ); - array[item++] = new TestCase( SECTION, "Number('+1234e5')", 123400000, Number("+1234e5") ); - array[item++] = new TestCase( SECTION, "Number('-1234e5')", -123400000, Number("-1234e5") ); +new TestCase( SECTION, "Number('5')", 5, Number("5") ); +new TestCase( SECTION, "Number('-5')", -5, Number("-5") ); +new TestCase( SECTION, "Number('+5')", 5, Number("+5") ); - array[item++] = new TestCase( SECTION, "Number('1234e+5')", 123400000, Number("1234e+5") ); - array[item++] = new TestCase( SECTION, "Number('+1234e+5')", 123400000, Number("+1234e+5") ); - array[item++] = new TestCase( SECTION, "Number('-1234e+5')", -123400000, Number("-1234e+5") ); +new TestCase( SECTION, "Number('6')", 6, Number("6") ); +new TestCase( SECTION, "Number('-6')", -6, Number("-6") ); +new TestCase( SECTION, "Number('+6')", 6, Number("+6") ); - array[item++] = new TestCase( SECTION, "Number('1234e-5')", 0.01234, Number("1234e-5") ); - array[item++] = new TestCase( SECTION, "Number('+1234e-5')", 0.01234, Number("+1234e-5") ); - array[item++] = new TestCase( SECTION, "Number('-1234e-5')", -0.01234, Number("-1234e-5") ); +new TestCase( SECTION, "Number('7')", 7, Number("7") ); +new TestCase( SECTION, "Number('-7')", -7, Number("-7") ); +new TestCase( SECTION, "Number('+7')", 7, Number("+7") ); - // StrNumericLiteral::: HexIntegerLiteral +new TestCase( SECTION, "Number('8')", 8, Number("8") ); +new TestCase( SECTION, "Number('-8')", -8, Number("-8") ); +new TestCase( SECTION, "Number('+8')", 8, Number("+8") ); - array[item++] = new TestCase( SECTION, "Number('0x0')", 0, Number("0x0")); - array[item++] = new TestCase( SECTION, "Number('0x1')", 1, Number("0x1")); - array[item++] = new TestCase( SECTION, "Number('0x2')", 2, Number("0x2")); - array[item++] = new TestCase( SECTION, "Number('0x3')", 3, Number("0x3")); - array[item++] = new TestCase( SECTION, "Number('0x4')", 4, Number("0x4")); - array[item++] = new TestCase( SECTION, "Number('0x5')", 5, Number("0x5")); - array[item++] = new TestCase( SECTION, "Number('0x6')", 6, Number("0x6")); - array[item++] = new TestCase( SECTION, "Number('0x7')", 7, Number("0x7")); - array[item++] = new TestCase( SECTION, "Number('0x8')", 8, Number("0x8")); - array[item++] = new TestCase( SECTION, "Number('0x9')", 9, Number("0x9")); - array[item++] = new TestCase( SECTION, "Number('0xa')", 10, Number("0xa")); - array[item++] = new TestCase( SECTION, "Number('0xb')", 11, Number("0xb")); - array[item++] = new TestCase( SECTION, "Number('0xc')", 12, Number("0xc")); - array[item++] = new TestCase( SECTION, "Number('0xd')", 13, Number("0xd")); - array[item++] = new TestCase( SECTION, "Number('0xe')", 14, Number("0xe")); - array[item++] = new TestCase( SECTION, "Number('0xf')", 15, Number("0xf")); - array[item++] = new TestCase( SECTION, "Number('0xA')", 10, Number("0xA")); - array[item++] = new TestCase( SECTION, "Number('0xB')", 11, Number("0xB")); - array[item++] = new TestCase( SECTION, "Number('0xC')", 12, Number("0xC")); - array[item++] = new TestCase( SECTION, "Number('0xD')", 13, Number("0xD")); - array[item++] = new TestCase( SECTION, "Number('0xE')", 14, Number("0xE")); - array[item++] = new TestCase( SECTION, "Number('0xF')", 15, Number("0xF")); +new TestCase( SECTION, "Number('9')", 9, Number("9") ); +new TestCase( SECTION, "Number('-9')", -9, Number("-9") ); +new TestCase( SECTION, "Number('+9')", 9, Number("+9") ); - array[item++] = new TestCase( SECTION, "Number('0X0')", 0, Number("0X0")); - array[item++] = new TestCase( SECTION, "Number('0X1')", 1, Number("0X1")); - array[item++] = new TestCase( SECTION, "Number('0X2')", 2, Number("0X2")); - array[item++] = new TestCase( SECTION, "Number('0X3')", 3, Number("0X3")); - array[item++] = new TestCase( SECTION, "Number('0X4')", 4, Number("0X4")); - array[item++] = new TestCase( SECTION, "Number('0X5')", 5, Number("0X5")); - array[item++] = new TestCase( SECTION, "Number('0X6')", 6, Number("0X6")); - array[item++] = new TestCase( SECTION, "Number('0X7')", 7, Number("0X7")); - array[item++] = new TestCase( SECTION, "Number('0X8')", 8, Number("0X8")); - array[item++] = new TestCase( SECTION, "Number('0X9')", 9, Number("0X9")); - array[item++] = new TestCase( SECTION, "Number('0Xa')", 10, Number("0Xa")); - array[item++] = new TestCase( SECTION, "Number('0Xb')", 11, Number("0Xb")); - array[item++] = new TestCase( SECTION, "Number('0Xc')", 12, Number("0Xc")); - array[item++] = new TestCase( SECTION, "Number('0Xd')", 13, Number("0Xd")); - array[item++] = new TestCase( SECTION, "Number('0Xe')", 14, Number("0Xe")); - array[item++] = new TestCase( SECTION, "Number('0Xf')", 15, Number("0Xf")); - array[item++] = new TestCase( SECTION, "Number('0XA')", 10, Number("0XA")); - array[item++] = new TestCase( SECTION, "Number('0XB')", 11, Number("0XB")); - array[item++] = new TestCase( SECTION, "Number('0XC')", 12, Number("0XC")); - array[item++] = new TestCase( SECTION, "Number('0XD')", 13, Number("0XD")); - array[item++] = new TestCase( SECTION, "Number('0XE')", 14, Number("0XE")); - array[item++] = new TestCase( SECTION, "Number('0XF')", 15, Number("0XF")); +new TestCase( SECTION, "Number('3.14159')", 3.14159, Number("3.14159") ); +new TestCase( SECTION, "Number('-3.14159')", -3.14159, Number("-3.14159") ); +new TestCase( SECTION, "Number('+3.14159')", 3.14159, Number("+3.14159") ); - return ( array ); -} +new TestCase( SECTION, "Number('3.')", 3, Number("3.") ); +new TestCase( SECTION, "Number('-3.')", -3, Number("-3.") ); +new TestCase( SECTION, "Number('+3.')", 3, Number("+3.") ); + +new TestCase( SECTION, "Number('3.e1')", 30, Number("3.e1") ); +new TestCase( SECTION, "Number('-3.e1')", -30, Number("-3.e1") ); +new TestCase( SECTION, "Number('+3.e1')", 30, Number("+3.e1") ); + +new TestCase( SECTION, "Number('3.e+1')", 30, Number("3.e+1") ); +new TestCase( SECTION, "Number('-3.e+1')", -30, Number("-3.e+1") ); +new TestCase( SECTION, "Number('+3.e+1')", 30, Number("+3.e+1") ); + +new TestCase( SECTION, "Number('3.e-1')", .30, Number("3.e-1") ); +new TestCase( SECTION, "Number('-3.e-1')", -.30, Number("-3.e-1") ); +new TestCase( SECTION, "Number('+3.e-1')", .30, Number("+3.e-1") ); + +// StrDecimalLiteral::: .DecimalDigits ExponentPart opt + +new TestCase( SECTION, "Number('.00001')", 0.00001, Number(".00001") ); +new TestCase( SECTION, "Number('+.00001')", 0.00001, Number("+.00001") ); +new TestCase( SECTION, "Number('-0.0001')", -0.00001, Number("-.00001") ); + +new TestCase( SECTION, "Number('.01e2')", 1, Number(".01e2") ); +new TestCase( SECTION, "Number('+.01e2')", 1, Number("+.01e2") ); +new TestCase( SECTION, "Number('-.01e2')", -1, Number("-.01e2") ); + +new TestCase( SECTION, "Number('.01e+2')", 1, Number(".01e+2") ); +new TestCase( SECTION, "Number('+.01e+2')", 1, Number("+.01e+2") ); +new TestCase( SECTION, "Number('-.01e+2')", -1, Number("-.01e+2") ); + +new TestCase( SECTION, "Number('.01e-2')", 0.0001, Number(".01e-2") ); +new TestCase( SECTION, "Number('+.01e-2')", 0.0001, Number("+.01e-2") ); +new TestCase( SECTION, "Number('-.01e-2')", -0.0001, Number("-.01e-2") ); + +// StrDecimalLiteral::: DecimalDigits ExponentPart opt + +new TestCase( SECTION, "Number('1234e5')", 123400000, Number("1234e5") ); +new TestCase( SECTION, "Number('+1234e5')", 123400000, Number("+1234e5") ); +new TestCase( SECTION, "Number('-1234e5')", -123400000, Number("-1234e5") ); + +new TestCase( SECTION, "Number('1234e+5')", 123400000, Number("1234e+5") ); +new TestCase( SECTION, "Number('+1234e+5')", 123400000, Number("+1234e+5") ); +new TestCase( SECTION, "Number('-1234e+5')", -123400000, Number("-1234e+5") ); + +new TestCase( SECTION, "Number('1234e-5')", 0.01234, Number("1234e-5") ); +new TestCase( SECTION, "Number('+1234e-5')", 0.01234, Number("+1234e-5") ); +new TestCase( SECTION, "Number('-1234e-5')", -0.01234, Number("-1234e-5") ); + +// StrNumericLiteral::: HexIntegerLiteral + +new TestCase( SECTION, "Number('0x0')", 0, Number("0x0")); +new TestCase( SECTION, "Number('0x1')", 1, Number("0x1")); +new TestCase( SECTION, "Number('0x2')", 2, Number("0x2")); +new TestCase( SECTION, "Number('0x3')", 3, Number("0x3")); +new TestCase( SECTION, "Number('0x4')", 4, Number("0x4")); +new TestCase( SECTION, "Number('0x5')", 5, Number("0x5")); +new TestCase( SECTION, "Number('0x6')", 6, Number("0x6")); +new TestCase( SECTION, "Number('0x7')", 7, Number("0x7")); +new TestCase( SECTION, "Number('0x8')", 8, Number("0x8")); +new TestCase( SECTION, "Number('0x9')", 9, Number("0x9")); +new TestCase( SECTION, "Number('0xa')", 10, Number("0xa")); +new TestCase( SECTION, "Number('0xb')", 11, Number("0xb")); +new TestCase( SECTION, "Number('0xc')", 12, Number("0xc")); +new TestCase( SECTION, "Number('0xd')", 13, Number("0xd")); +new TestCase( SECTION, "Number('0xe')", 14, Number("0xe")); +new TestCase( SECTION, "Number('0xf')", 15, Number("0xf")); +new TestCase( SECTION, "Number('0xA')", 10, Number("0xA")); +new TestCase( SECTION, "Number('0xB')", 11, Number("0xB")); +new TestCase( SECTION, "Number('0xC')", 12, Number("0xC")); +new TestCase( SECTION, "Number('0xD')", 13, Number("0xD")); +new TestCase( SECTION, "Number('0xE')", 14, Number("0xE")); +new TestCase( SECTION, "Number('0xF')", 15, Number("0xF")); + +new TestCase( SECTION, "Number('0X0')", 0, Number("0X0")); +new TestCase( SECTION, "Number('0X1')", 1, Number("0X1")); +new TestCase( SECTION, "Number('0X2')", 2, Number("0X2")); +new TestCase( SECTION, "Number('0X3')", 3, Number("0X3")); +new TestCase( SECTION, "Number('0X4')", 4, Number("0X4")); +new TestCase( SECTION, "Number('0X5')", 5, Number("0X5")); +new TestCase( SECTION, "Number('0X6')", 6, Number("0X6")); +new TestCase( SECTION, "Number('0X7')", 7, Number("0X7")); +new TestCase( SECTION, "Number('0X8')", 8, Number("0X8")); +new TestCase( SECTION, "Number('0X9')", 9, Number("0X9")); +new TestCase( SECTION, "Number('0Xa')", 10, Number("0Xa")); +new TestCase( SECTION, "Number('0Xb')", 11, Number("0Xb")); +new TestCase( SECTION, "Number('0Xc')", 12, Number("0Xc")); +new TestCase( SECTION, "Number('0Xd')", 13, Number("0Xd")); +new TestCase( SECTION, "Number('0Xe')", 14, Number("0Xe")); +new TestCase( SECTION, "Number('0Xf')", 15, Number("0Xf")); +new TestCase( SECTION, "Number('0XA')", 10, Number("0XA")); +new TestCase( SECTION, "Number('0XB')", 11, Number("0XB")); +new TestCase( SECTION, "Number('0XC')", 12, Number("0XC")); +new TestCase( SECTION, "Number('0XD')", 13, Number("0XD")); +new TestCase( SECTION, "Number('0XE')", 14, Number("0XE")); +new TestCase( SECTION, "Number('0XF')", 15, Number("0XF")); + +test(); diff --git a/mozilla/js/tests/ecma/TypeConversion/9.3.1-2.js b/mozilla/js/tests/ecma/TypeConversion/9.3.1-2.js index 824afce5b31..0b8ec1672ba 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.3.1-2.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.3.1-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,71 +35,51 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.3.1-2.js - ECMA Section: 9.3 Type Conversion: ToNumber - Description: rules for converting an argument to a number. - see 9.3.1 for cases for converting strings to numbers. - special cases: - undefined NaN - Null NaN - Boolean 1 if true; +0 if false - Number the argument ( no conversion ) - String see test 9.3.1 - Object see test 9.3-1 + File Name: 9.3.1-2.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 - This tests special cases of ToNumber(string) that are - not covered in 9.3.1-1.js. + This tests special cases of ToNumber(string) that are + not covered in 9.3.1-1.js. - Author: christine@netscape.com - Date: 10 july 1997 + Author: christine@netscape.com + Date: 10 july 1997 */ - var SECTION = "9.3.1-2"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "ToNumber applied to the String type"; +var SECTION = "9.3.1-2"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToNumber applied to the String type"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// A StringNumericLiteral may not use octal notation +new TestCase( SECTION, "Number(00)", 0, Number("00")); +new TestCase( SECTION, "Number(01)", 1, Number("01")); +new TestCase( SECTION, "Number(02)", 2, Number("02")); +new TestCase( SECTION, "Number(03)", 3, Number("03")); +new TestCase( SECTION, "Number(04)", 4, Number("04")); +new TestCase( SECTION, "Number(05)", 5, Number("05")); +new TestCase( SECTION, "Number(06)", 6, Number("06")); +new TestCase( SECTION, "Number(07)", 7, Number("07")); +new TestCase( SECTION, "Number(010)", 10, Number("010")); +new TestCase( SECTION, "Number(011)", 11, Number("011")); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +// A StringNumericLIteral may have any number of leading 0 digits - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Number(001)", 1, Number("001")); +new TestCase( SECTION, "Number(0001)", 1, Number("0001")); - // A StringNumericLiteral may not use octal notation +test(); - array[item++] = new TestCase( SECTION, "Number(00)", 0, Number("00")); - array[item++] = new TestCase( SECTION, "Number(01)", 1, Number("01")); - array[item++] = new TestCase( SECTION, "Number(02)", 2, Number("02")); - array[item++] = new TestCase( SECTION, "Number(03)", 3, Number("03")); - array[item++] = new TestCase( SECTION, "Number(04)", 4, Number("04")); - array[item++] = new TestCase( SECTION, "Number(05)", 5, Number("05")); - array[item++] = new TestCase( SECTION, "Number(06)", 6, Number("06")); - array[item++] = new TestCase( SECTION, "Number(07)", 7, Number("07")); - array[item++] = new TestCase( SECTION, "Number(010)", 10, Number("010")); - array[item++] = new TestCase( SECTION, "Number(011)", 11, Number("011")); - - // A StringNumericLIteral may have any number of leading 0 digits - - array[item++] = new TestCase( SECTION, "Number(001)", 1, Number("001")); - array[item++] = new TestCase( SECTION, "Number(0001)", 1, Number("0001")); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/TypeConversion/9.3.1-3.js b/mozilla/js/tests/ecma/TypeConversion/9.3.1-3.js index 34079c78a7e..adb8bed80bc 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.3.1-3.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.3.1-3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,47 +36,44 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: 9.3.1-3.js - ECMA Section: 9.3 Type Conversion: ToNumber - Description: rules for converting an argument to a number. - see 9.3.1 for cases for converting strings to numbers. - special cases: - undefined NaN - Null NaN - Boolean 1 if true; +0 if false - Number the argument ( no conversion ) - String see test 9.3.1 - Object see test 9.3-1 + File Name: 9.3.1-3.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 - Test cases provided by waldemar. + Test cases provided by waldemar. - Author: christine@netscape.com - Date: 10 june 1998 + Author: christine@netscape.com + Date: 10 june 1998 */ var SECTION = "9.3.1-3"; var VERSION = "ECMA_1"; - startTest(); +startTest(); var BUGNUMBER="129087"; var TITLE = "Number To String, String To Number"; writeHeaderToLog( SECTION + " "+ TITLE); -var testcases = new Array(); - - // test case from http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312954 var z = 0; -testcases[tc++] = new TestCase( - SECTION, - "var z = 0; print(1/-z)", - -Infinity, - 1/-z ); +new TestCase( + SECTION, + "var z = 0; writeLineToLog(1/-z)", + -Infinity, + 1/-z ); @@ -85,657 +83,645 @@ testcases[tc++] = new TestCase( -testcases[tc++] = new TestCase( SECTION, - '- -"0x80000000"', - 2147483648, - - -"0x80000000" ); +new TestCase( SECTION, + '- -"0x80000000"', + 2147483648, + - -"0x80000000" ); -testcases[tc++] = new TestCase( SECTION, - '- -"0x100000000"', - 4294967296, - - -"0x100000000" ); +new TestCase( SECTION, + '- -"0x100000000"', + 4294967296, + - -"0x100000000" ); -testcases[tc++] = new TestCase( SECTION, - '- "-0x123456789abcde8"', - 81985529216486880, - - "-0x123456789abcde8" ); +new TestCase( SECTION, + '- "-0x123456789abcde8"', + 81985529216486880, + - "-0x123456789abcde8" ); // Convert some large numbers to string -testcases[tc++] = new TestCase( SECTION, - "1e2000 +''", - "Infinity", - 1e2000 +"" ); +new TestCase( SECTION, + "1e2000 +''", + "Infinity", + 1e2000 +"" ); -testcases[tc++] = new TestCase( SECTION, - "1e2000", - Infinity, - 1e2000 ); +new TestCase( SECTION, + "1e2000", + Infinity, + 1e2000 ); -testcases[tc++] = new TestCase( SECTION, - "-1e2000 +''", - "-Infinity", - -1e2000 +"" ); +new TestCase( SECTION, + "-1e2000 +''", + "-Infinity", + -1e2000 +"" ); -testcases[tc++] = new TestCase( SECTION, - "-\"1e2000\"", - -Infinity, - -"1e2000" ); +new TestCase( SECTION, + "-\"1e2000\"", + -Infinity, + -"1e2000" ); -testcases[tc++] = new TestCase( SECTION, - "-\"-1e2000\" +''", - "Infinity", - -"-1e2000" +"" ); +new TestCase( SECTION, + "-\"-1e2000\" +''", + "Infinity", + -"-1e2000" +"" ); -testcases[tc++] = new TestCase( SECTION, - "1e-2000", - 0, - 1e-2000 ); +new TestCase( SECTION, + "1e-2000", + 0, + 1e-2000 ); -testcases[tc++] = new TestCase( SECTION, - "1/1e-2000", - Infinity, - 1/1e-2000 ); +new TestCase( SECTION, + "1/1e-2000", + Infinity, + 1/1e-2000 ); // convert some strings to large numbers -testcases[tc++] = new TestCase( SECTION, - "1/-1e-2000", - -Infinity, - 1/-1e-2000 ); +new TestCase( SECTION, + "1/-1e-2000", + -Infinity, + 1/-1e-2000 ); -testcases[tc++] = new TestCase( SECTION, - "1/\"1e-2000\"", - Infinity, - 1/"1e-2000" ); +new TestCase( SECTION, + "1/\"1e-2000\"", + Infinity, + 1/"1e-2000" ); -testcases[tc++] = new TestCase( SECTION, - "1/\"-1e-2000\"", - -Infinity, - 1/"-1e-2000" ); +new TestCase( SECTION, + "1/\"-1e-2000\"", + -Infinity, + 1/"-1e-2000" ); -testcases[tc++] = new TestCase( SECTION, - "parseFloat(\"1e2000\")", - Infinity, - parseFloat("1e2000") ); +new TestCase( SECTION, + "parseFloat(\"1e2000\")", + Infinity, + parseFloat("1e2000") ); -testcases[tc++] = new TestCase( SECTION, - "parseFloat(\"1e-2000\")", - 0, - parseFloat("1e-2000") ); +new TestCase( SECTION, + "parseFloat(\"1e-2000\")", + 0, + parseFloat("1e-2000") ); -testcases[tc++] = new TestCase( SECTION, - "1.7976931348623157E+308", - 1.7976931348623157e+308, - 1.7976931348623157E+308 ); +new TestCase( SECTION, + "1.7976931348623157E+308", + 1.7976931348623157e+308, + 1.7976931348623157E+308 ); -testcases[tc++] = new TestCase( SECTION, - "1.7976931348623158e+308", - 1.7976931348623157e+308, - 1.7976931348623158e+308 ); +new TestCase( SECTION, + "1.7976931348623158e+308", + 1.7976931348623157e+308, + 1.7976931348623158e+308 ); -testcases[tc++] = new TestCase( SECTION, - "1.7976931348623159e+308", - Infinity, - 1.7976931348623159e+308 ); +new TestCase( SECTION, + "1.7976931348623159e+308", + Infinity, + 1.7976931348623159e+308 ); s = "17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068"; -testcases[tc++] = new TestCase( SECTION, - "s = " + s +"; s +="+ -"\"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779\""+ +new TestCase( SECTION, + "s = " + s +"; s +="+ + "\"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779\""+ -+"; s", -"17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779", -s += -"190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779" -); + +"; s", + "17976931348623158079372897140530341507993413271003782693617377898044496829276475094664901797758720709633028641669288791094655554785194040263065748867150582068190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779", + s += + "190890200070838367627385484581771153176447573027006985557136695962284291481986083493647529271907416844436551070434271155969950809304288017790417449779" + ); s1 = s+1; -testcases[tc++] = new TestCase( SECTION, -"s1 = s+1; s1", -"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791", -s1 ); +new TestCase( SECTION, + "s1 = s+1; s1", + "179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791", + s1 ); /***** This answer is preferred but -Infinity is also acceptable here *****/ -testcases[tc++] = new TestCase( SECTION, -"-s1 == Infinity || s1 == 1.7976931348623157e+308", -true, --s1 == Infinity || s1 == 1.7976931348623157e+308 ); +new TestCase( SECTION, + "-s1 == Infinity || s1 == 1.7976931348623157e+308", + true, + -s1 == Infinity || s1 == 1.7976931348623157e+308 ); s2 = s + 2; -testcases[tc++] = new TestCase( SECTION, -"s2 = s+2; s2", -"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792", -s2 ); +new TestCase( SECTION, + "s2 = s+2; s2", + "179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497792", + s2 ); // ***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here ***** -testcases[tc++] = new TestCase( SECTION, -"-s2 == -Infinity || -s2 == -1.7976931348623157e+308 ", -true, --s2 == -Infinity || -s2 == -1.7976931348623157e+308 ); +new TestCase( SECTION, + "-s2 == -Infinity || -s2 == -1.7976931348623157e+308 ", + true, + -s2 == -Infinity || -s2 == -1.7976931348623157e+308 ); s3 = s+3; -testcases[tc++] = new TestCase( SECTION, -"s3 = s+3; s3", -"179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497793", -s3 ); +new TestCase( SECTION, + "s3 = s+3; s3", + "179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497793", + s3 ); //***** This answer is preferred but -1.7976931348623157e+308 is also acceptable here ***** -testcases[tc++] = new TestCase( SECTION, -"-s3 == -Infinity || -s3 == -1.7976931348623157e+308", -true, --s3 == -Infinity || -s3 == -1.7976931348623157e+308 ); +new TestCase( SECTION, + "-s3 == -Infinity || -s3 == -1.7976931348623157e+308", + true, + -s3 == -Infinity || -s3 == -1.7976931348623157e+308 ); //***** This answer is preferred but Infinity is also acceptable here ***** -testcases[tc++] = new TestCase( SECTION, -"parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity", -true, -parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity ); +new TestCase( SECTION, + "parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity", + true, + parseInt(s1,10) == 1.7976931348623157e+308 || parseInt(s1,10) == Infinity ); //***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here ***** -testcases[tc++] = new TestCase( SECTION, -"parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308", -true , -parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308 ); +new TestCase( SECTION, + "parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308", + true , + parseInt(s2,10) == Infinity || parseInt(s2,10) == 1.7976931348623157e+308 ); //***** This answer is preferred but Infinity is also acceptable here ***** -testcases[tc++] = new TestCase( SECTION, -"parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity", -true, -parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity); +new TestCase( SECTION, + "parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity", + true, + parseInt(s1) == 1.7976931348623157e+308 || parseInt(s1) == Infinity); //***** This answer is preferred but 1.7976931348623157e+308 is also acceptable here ***** -testcases[tc++] = new TestCase( SECTION, -"parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308", -true, -parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308 ); +new TestCase( SECTION, + "parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308", + true, + parseInt(s2) == Infinity || parseInt(s2) == 1.7976931348623157e+308 ); -testcases[tc++] = new TestCase( SECTION, - "0x12345678", - 305419896, - 0x12345678 ); +new TestCase( SECTION, + "0x12345678", + 305419896, + 0x12345678 ); -testcases[tc++] = new TestCase( SECTION, - "0x80000000", - 2147483648, - 0x80000000 ); +new TestCase( SECTION, + "0x80000000", + 2147483648, + 0x80000000 ); -testcases[tc++] = new TestCase( SECTION, - "0xffffffff", - 4294967295, - 0xffffffff ); +new TestCase( SECTION, + "0xffffffff", + 4294967295, + 0xffffffff ); -testcases[tc++] = new TestCase( SECTION, - "0x100000000", - 4294967296, - 0x100000000 ); +new TestCase( SECTION, + "0x100000000", + 4294967296, + 0x100000000 ); -testcases[tc++] = new TestCase( SECTION, - "077777777777777777", - 2251799813685247, - 077777777777777777 ); +new TestCase( SECTION, + "077777777777777777", + 2251799813685247, + 077777777777777777 ); -testcases[tc++] = new TestCase( SECTION, - "077777777777777776", - 2251799813685246, - 077777777777777776 ); +new TestCase( SECTION, + "077777777777777776", + 2251799813685246, + 077777777777777776 ); -testcases[tc++] = new TestCase( SECTION, - "0x1fffffffffffff", - 9007199254740991, - 0x1fffffffffffff ); +new TestCase( SECTION, + "0x1fffffffffffff", + 9007199254740991, + 0x1fffffffffffff ); -testcases[tc++] = new TestCase( SECTION, - "0x20000000000000", - 9007199254740992, - 0x20000000000000 ); +new TestCase( SECTION, + "0x20000000000000", + 9007199254740992, + 0x20000000000000 ); -testcases[tc++] = new TestCase( SECTION, - "0x20123456789abc", - 9027215253084860, - 0x20123456789abc ); +new TestCase( SECTION, + "0x20123456789abc", + 9027215253084860, + 0x20123456789abc ); -testcases[tc++] = new TestCase( SECTION, - "0x20123456789abd", - 9027215253084860, - 0x20123456789abd ); +new TestCase( SECTION, + "0x20123456789abd", + 9027215253084860, + 0x20123456789abd ); -testcases[tc++] = new TestCase( SECTION, - "0x20123456789abe", - 9027215253084862, - 0x20123456789abe ); +new TestCase( SECTION, + "0x20123456789abe", + 9027215253084862, + 0x20123456789abe ); -testcases[tc++] = new TestCase( SECTION, - "0x20123456789abf", - 9027215253084864, - 0x20123456789abf ); +new TestCase( SECTION, + "0x20123456789abf", + 9027215253084864, + 0x20123456789abf ); /***** These test the round-to-nearest-or-even-if-equally-close rule *****/ -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000080", - 1152921504606847000, - 0x1000000000000080 ); +new TestCase( SECTION, + "0x1000000000000080", + 1152921504606847000, + 0x1000000000000080 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000081", - 1152921504606847200, - 0x1000000000000081 ); +new TestCase( SECTION, + "0x1000000000000081", + 1152921504606847200, + 0x1000000000000081 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000100", - 1152921504606847200, - 0x1000000000000100 ); -testcases[tc++] = new TestCase( SECTION, - "0x100000000000017f", - 1152921504606847200, - 0x100000000000017f ); +new TestCase( SECTION, + "0x1000000000000100", + 1152921504606847200, + 0x1000000000000100 ); +new TestCase( SECTION, + "0x100000000000017f", + 1152921504606847200, + 0x100000000000017f ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000180", - 1152921504606847500, - 0x1000000000000180 ); +new TestCase( SECTION, + "0x1000000000000180", + 1152921504606847500, + 0x1000000000000180 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000181", - 1152921504606847500, - 0x1000000000000181 ); +new TestCase( SECTION, + "0x1000000000000181", + 1152921504606847500, + 0x1000000000000181 ); -testcases[tc++] = new TestCase( SECTION, - "0x10000000000001f0", - 1152921504606847500, - 0x10000000000001f0 ); +new TestCase( SECTION, + "0x10000000000001f0", + 1152921504606847500, + 0x10000000000001f0 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000200", - 1152921504606847500, - 0x1000000000000200 ); +new TestCase( SECTION, + "0x1000000000000200", + 1152921504606847500, + 0x1000000000000200 ); -testcases[tc++] = new TestCase( SECTION, - "0x100000000000027f", - 1152921504606847500, - 0x100000000000027f ); +new TestCase( SECTION, + "0x100000000000027f", + 1152921504606847500, + 0x100000000000027f ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000280", - 1152921504606847500, - 0x1000000000000280 ); +new TestCase( SECTION, + "0x1000000000000280", + 1152921504606847500, + 0x1000000000000280 ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000281", - 1152921504606847700, - 0x1000000000000281 ); +new TestCase( SECTION, + "0x1000000000000281", + 1152921504606847700, + 0x1000000000000281 ); -testcases[tc++] = new TestCase( SECTION, - "0x10000000000002ff", - 1152921504606847700, - 0x10000000000002ff ); +new TestCase( SECTION, + "0x10000000000002ff", + 1152921504606847700, + 0x10000000000002ff ); -testcases[tc++] = new TestCase( SECTION, - "0x1000000000000300", - 1152921504606847700, - 0x1000000000000300 ); +new TestCase( SECTION, + "0x1000000000000300", + 1152921504606847700, + 0x1000000000000300 ); -testcases[tc++] = new TestCase( SECTION, - "0x10000000000000000", - 18446744073709552000, - 0x10000000000000000 ); +new TestCase( SECTION, + "0x10000000000000000", + 18446744073709552000, + 0x10000000000000000 ); -testcases[tc++] = new TestCase( SECTION, -"parseInt(\"000000100000000100100011010001010110011110001001101010111100\",2)", -9027215253084860, -parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); +new TestCase( SECTION, + "parseInt(\"000000100000000100100011010001010110011110001001101010111100\",2)", + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111100",2) ); -testcases[tc++] = new TestCase( SECTION, -"parseInt(\"000000100000000100100011010001010110011110001001101010111101\",2)", -9027215253084860, -parseInt("000000100000000100100011010001010110011110001001101010111101",2) ); +new TestCase( SECTION, + "parseInt(\"000000100000000100100011010001010110011110001001101010111101\",2)", + 9027215253084860, + parseInt("000000100000000100100011010001010110011110001001101010111101",2) ); -testcases[tc++] = new TestCase( SECTION, -"parseInt(\"000000100000000100100011010001010110011110001001101010111111\",2)", -9027215253084864, -parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); +new TestCase( SECTION, + "parseInt(\"000000100000000100100011010001010110011110001001101010111111\",2)", + 9027215253084864, + parseInt("000000100000000100100011010001010110011110001001101010111111",2) ); -testcases[tc++] = new TestCase( SECTION, -"parseInt(\"0000001000000001001000110100010101100111100010011010101111010\",2)", -18054430506169720, -parseInt("0000001000000001001000110100010101100111100010011010101111010",2)); +new TestCase( SECTION, + "parseInt(\"0000001000000001001000110100010101100111100010011010101111010\",2)", + 18054430506169720, + parseInt("0000001000000001001000110100010101100111100010011010101111010",2)); -testcases[tc++] = new TestCase( SECTION, -"parseInt(\"0000001000000001001000110100010101100111100010011010101111011\",2)", -18054430506169724, -parseInt("0000001000000001001000110100010101100111100010011010101111011",2) ); +new TestCase( SECTION, + "parseInt(\"0000001000000001001000110100010101100111100010011010101111011\",2)", + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111011",2) ); -testcases[tc++] = new TestCase( SECTION, -"parseInt(\"0000001000000001001000110100010101100111100010011010101111100\",2)", -18054430506169724, -parseInt("0000001000000001001000110100010101100111100010011010101111100",2)); +new TestCase( SECTION, + "parseInt(\"0000001000000001001000110100010101100111100010011010101111100\",2)", + 18054430506169724, + parseInt("0000001000000001001000110100010101100111100010011010101111100",2)); -testcases[tc++] = new TestCase( SECTION, -"parseInt(\"0000001000000001001000110100010101100111100010011010101111110\",2)", -18054430506169728, -parseInt("0000001000000001001000110100010101100111100010011010101111110",2)); +new TestCase( SECTION, + "parseInt(\"0000001000000001001000110100010101100111100010011010101111110\",2)", + 18054430506169728, + parseInt("0000001000000001001000110100010101100111100010011010101111110",2)); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"yz\",35)", - 34, - parseInt("yz",35) ); +new TestCase( SECTION, + "parseInt(\"yz\",35)", + 34, + parseInt("yz",35) ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"yz\",36)", - 1259, - parseInt("yz",36) ); +new TestCase( SECTION, + "parseInt(\"yz\",36)", + 1259, + parseInt("yz",36) ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"yz\",37)", - NaN, - parseInt("yz",37) ); +new TestCase( SECTION, + "parseInt(\"yz\",37)", + NaN, + parseInt("yz",37) ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"+77\")", - 77, - parseInt("+77") ); +new TestCase( SECTION, + "parseInt(\"+77\")", + 77, + parseInt("+77") ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"-77\",9)", - -70, - parseInt("-77",9) ); +new TestCase( SECTION, + "parseInt(\"-77\",9)", + -70, + parseInt("-77",9) ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"\\u20001234\\u2000\")", - 1234, - parseInt("\u20001234\u2000") ); +new TestCase( SECTION, + "parseInt(\"\\u20001234\\u2000\")", + 1234, + parseInt("\u20001234\u2000") ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"123456789012345678\")", - 123456789012345680, - parseInt("123456789012345678") ); +new TestCase( SECTION, + "parseInt(\"123456789012345678\")", + 123456789012345680, + parseInt("123456789012345678") ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"9\",8)", - NaN, - parseInt("9",8) ); +new TestCase( SECTION, + "parseInt(\"9\",8)", + NaN, + parseInt("9",8) ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"1e2\")", - 1, - parseInt("1e2") ); +new TestCase( SECTION, + "parseInt(\"1e2\")", + 1, + parseInt("1e2") ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"1.9999999999999999999\")", - 1, - parseInt("1.9999999999999999999") ); +new TestCase( SECTION, + "parseInt(\"1.9999999999999999999\")", + 1, + parseInt("1.9999999999999999999") ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"0x10\")", - 16, - parseInt("0x10") ); +new TestCase( SECTION, + "parseInt(\"0x10\")", + 16, + parseInt("0x10") ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"0x10\",10)", - 0, - parseInt("0x10",10) ); +new TestCase( SECTION, + "parseInt(\"0x10\",10)", + 0, + parseInt("0x10",10) ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"0022\")", - 18, - parseInt("0022") ); +new TestCase( SECTION, + "parseInt(\"0022\")", + 18, + parseInt("0022") ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"0022\",10)", - 22, - parseInt("0022",10) ); +new TestCase( SECTION, + "parseInt(\"0022\",10)", + 22, + parseInt("0022",10) ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"0x1000000000000080\")", - 1152921504606847000, - parseInt("0x1000000000000080") ); +new TestCase( SECTION, + "parseInt(\"0x1000000000000080\")", + 1152921504606847000, + parseInt("0x1000000000000080") ); -testcases[tc++] = new TestCase( SECTION, - "parseInt(\"0x1000000000000081\")", - 1152921504606847200, - parseInt("0x1000000000000081") ); +new TestCase( SECTION, + "parseInt(\"0x1000000000000081\")", + 1152921504606847200, + parseInt("0x1000000000000081") ); s = "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; -testcases[tc++] = new TestCase( SECTION, "s = "+ -"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ -"s", -"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", -s ); +new TestCase( SECTION, "s = "+ + "\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ + "s", + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s ); -testcases[tc++] = new TestCase( SECTION, "s +="+ -"\"0000000000000000000000000000000000000\"; s", -"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", -s += "0000000000000000000000000000000000000" ); +new TestCase( SECTION, "s +="+ + "\"0000000000000000000000000000000000000\"; s", + "0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s += "0000000000000000000000000000000000000" ); -testcases[tc++] = new TestCase( SECTION, "-s", --1.7976931348623157e+308, --s ); +new TestCase( SECTION, "-s", + -1.7976931348623157e+308, + -s ); s = "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; -testcases[tc++] = new TestCase( SECTION, "s ="+ -"\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ -"s", -"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", -s ); +new TestCase( SECTION, "s ="+ + "\"0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ + "s", + "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s ); -testcases[tc++] = new TestCase( SECTION, -"s += \"0000000000000000000000000000000000001\"", -"0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", -s += "0000000000000000000000000000000000001" ); +new TestCase( SECTION, + "s += \"0000000000000000000000000000000000001\"", + "0xFFFFFFFFFFFFF800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", + s += "0000000000000000000000000000000000001" ); -testcases[tc++] = new TestCase( SECTION, -"-s", --1.7976931348623157e+308, --s ); +new TestCase( SECTION, + "-s", + -1.7976931348623157e+308, + -s ); s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; -testcases[tc++] = new TestCase( SECTION, -"s ="+ -"\"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ -"s", -"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", -s ); +new TestCase( SECTION, + "s ="+ + "\"0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";"+ + "s", + "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s ); -testcases[tc++] = new TestCase( SECTION, -"s += \"0000000000000000000000000000000000000\"", -"0xFFFFFFFFFFFFFC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", -s += "0000000000000000000000000000000000000"); +new TestCase( SECTION, + "s += \"0000000000000000000000000000000000000\"", + "0xFFFFFFFFFFFFFC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s += "0000000000000000000000000000000000000"); -testcases[tc++] = new TestCase( SECTION, -"-s", --Infinity, --s ); +new TestCase( SECTION, + "-s", + -Infinity, + -s ); s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; -testcases[tc++] = new TestCase( SECTION, -"s = "+ -"\"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";s", -"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", -s); +new TestCase( SECTION, + "s = "+ + "\"0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\";s", + "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + s); -testcases[tc++] = new TestCase( SECTION, -"s += \"0000000000000000000000000000000000001\"", -"0xFFFFFFFFFFFFFB00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", -s += "0000000000000000000000000000000000001" ); +new TestCase( SECTION, + "s += \"0000000000000000000000000000000000001\"", + "0xFFFFFFFFFFFFFB00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", + s += "0000000000000000000000000000000000001" ); -testcases[tc++] = new TestCase( SECTION, -"-s", --1.7976931348623157e+308, --s ); +new TestCase( SECTION, + "-s", + -1.7976931348623157e+308, + -s ); -testcases[tc++] = new TestCase( SECTION, -"s += \"0\"", -"0xFFFFFFFFFFFFFB000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010", -s += "0" ); +new TestCase( SECTION, + "s += \"0\"", + "0xFFFFFFFFFFFFFB000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010", + s += "0" ); -testcases[tc++] = new TestCase( SECTION, -"-s", --Infinity, --s ); +new TestCase( SECTION, + "-s", + -Infinity, + -s ); -testcases[tc++] = new TestCase( SECTION, -"parseInt(s)", -Infinity, -parseInt(s) ); +new TestCase( SECTION, + "parseInt(s)", + Infinity, + parseInt(s) ); -testcases[tc++] = new TestCase( SECTION, -"parseInt(s,32)", -0, -parseInt(s,32) ); +new TestCase( SECTION, + "parseInt(s,32)", + 0, + parseInt(s,32) ); -testcases[tc++] = new TestCase( SECTION, -"parseInt(s,36)", -Infinity, -parseInt(s,36) ); +new TestCase( SECTION, + "parseInt(s,36)", + Infinity, + parseInt(s,36) ); -testcases[tc++] = new TestCase( SECTION, - "-\"\"", - 0, - -"" ); +new TestCase( SECTION, + "-\"\"", + 0, + -"" ); -testcases[tc++] = new TestCase( SECTION, - "-\" \"", - 0, - -" " ); +new TestCase( SECTION, + "-\" \"", + 0, + -" " ); -testcases[tc++] = new TestCase( SECTION, - "-\"999\"", - -999, - -"999" ); +new TestCase( SECTION, + "-\"999\"", + -999, + -"999" ); -testcases[tc++] = new TestCase( SECTION, - "-\" 999\"", - -999, - -" 999" ); +new TestCase( SECTION, + "-\" 999\"", + -999, + -" 999" ); -testcases[tc++] = new TestCase( SECTION, - "-\"\\t999\"", - -999, - -"\t999" ); +new TestCase( SECTION, + "-\"\\t999\"", + -999, + -"\t999" ); -testcases[tc++] = new TestCase( SECTION, - "-\"013 \"", - -13, - -"013 " ); +new TestCase( SECTION, + "-\"013 \"", + -13, + -"013 " ); -testcases[tc++] = new TestCase( SECTION, - "-\"999\\t\"", - -999, - -"999\t" ); +new TestCase( SECTION, + "-\"999\\t\"", + -999, + -"999\t" ); -testcases[tc++] = new TestCase( SECTION, - "-\"-Infinity\"", - Infinity, - -"-Infinity" ); +new TestCase( SECTION, + "-\"-Infinity\"", + Infinity, + -"-Infinity" ); -testcases[tc++] = new TestCase( SECTION, - "-\"-infinity\"", - NaN, - -"-infinity" ); +new TestCase( SECTION, + "-\"-infinity\"", + NaN, + -"-infinity" ); -testcases[tc++] = new TestCase( SECTION, - "-\"+Infinity\"", - -Infinity, - -"+Infinity" ); +new TestCase( SECTION, + "-\"+Infinity\"", + -Infinity, + -"+Infinity" ); -testcases[tc++] = new TestCase( SECTION, - "-\"+Infiniti\"", - NaN, - -"+Infiniti" ); +new TestCase( SECTION, + "-\"+Infiniti\"", + NaN, + -"+Infiniti" ); -testcases[tc++] = new TestCase( SECTION, - "- -\"0x80000000\"", - 2147483648, - - -"0x80000000" ); +new TestCase( SECTION, + "- -\"0x80000000\"", + 2147483648, + - -"0x80000000" ); -testcases[tc++] = new TestCase( SECTION, - "- -\"0x100000000\"", - 4294967296, - - -"0x100000000" ); +new TestCase( SECTION, + "- -\"0x100000000\"", + 4294967296, + - -"0x100000000" ); -testcases[tc++] = new TestCase( SECTION, - "- \"-0x123456789abcde8\"", - 81985529216486880, - - "-0x123456789abcde8" ); +new TestCase( SECTION, + "- \"-0x123456789abcde8\"", + 81985529216486880, + - "-0x123456789abcde8" ); // the following two tests are not strictly ECMA 1.0 -testcases[tc++] = new TestCase( SECTION, - "-\"\\u20001234\\u2001\"", - -1234, - -"\u20001234\u2001" ); +new TestCase( SECTION, + "-\"\\u20001234\\u2001\"", + -1234, + -"\u20001234\u2001" ); -testcases[tc++] = new TestCase( SECTION, - "-\"\\u20001234\\0\"", - NaN, - -"\u20001234\0" ); +new TestCase( SECTION, + "-\"\\u20001234\\0\"", + NaN, + -"\u20001234\0" ); -testcases[tc++] = new TestCase( SECTION, - "-\"0x10\"", - -16, - -"0x10" ); +new TestCase( SECTION, + "-\"0x10\"", + -16, + -"0x10" ); -testcases[tc++] = new TestCase( SECTION, - "-\"+\"", - NaN, - -"+" ); +new TestCase( SECTION, + "-\"+\"", + NaN, + -"+" ); -testcases[tc++] = new TestCase( SECTION, - "-\"-\"", - NaN, - -"-" ); +new TestCase( SECTION, + "-\"-\"", + NaN, + -"-" ); -testcases[tc++] = new TestCase( SECTION, - "-\"-0-\"", - NaN, - -"-0-" ); +new TestCase( SECTION, + "-\"-0-\"", + NaN, + -"-0-" ); -testcases[tc++] = new TestCase( SECTION, - "-\"1e-\"", - NaN, - -"1e-" ); +new TestCase( SECTION, + "-\"1e-\"", + NaN, + -"1e-" ); -testcases[tc++] = new TestCase( SECTION, - "-\"1e-1\"", - -0.1, - -"1e-1" ); +new TestCase( SECTION, + "-\"1e-1\"", + -0.1, + -"1e-1" ); test(); -function test(){ - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/TypeConversion/9.3.js b/mozilla/js/tests/ecma/TypeConversion/9.3.js index 5f2a160c56d..c247ed87978 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.3.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,71 +35,51 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.3.js - ECMA Section: 9.3 Type Conversion: ToNumber - Description: rules for converting an argument to a number. - see 9.3.1 for cases for converting strings to numbers. - special cases: - undefined NaN - Null NaN - Boolean 1 if true; +0 if false - Number the argument ( no conversion ) - String see test 9.3.1 - Object see test 9.3-1 + File Name: 9.3.js + ECMA Section: 9.3 Type Conversion: ToNumber + Description: rules for converting an argument to a number. + see 9.3.1 for cases for converting strings to numbers. + special cases: + undefined NaN + Null NaN + Boolean 1 if true; +0 if false + Number the argument ( no conversion ) + String see test 9.3.1 + Object see test 9.3-1 - For ToNumber applied to the String type, see test 9.3.1. - For ToNumber applied to the object type, see test 9.3-1. + For ToNumber applied to the String type, see test 9.3.1. + For ToNumber applied to the object type, see test 9.3-1. - Author: christine@netscape.com - Date: 10 july 1997 + Author: christine@netscape.com + Date: 10 july 1997 */ - var SECTION = "9.3"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "ToNumber"; +var SECTION = "9.3"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToNumber"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// special cases here +new TestCase( SECTION, "Number()", 0, Number() ); +new TestCase( SECTION, "Number(eval('var x'))", Number.NaN, Number(eval("var x")) ); +new TestCase( SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); +new TestCase( SECTION, "Number(null)", 0, Number(null) ); +new TestCase( SECTION, "Number(true)", 1, Number(true) ); +new TestCase( SECTION, "Number(false)", 0, Number(false) ); +new TestCase( SECTION, "Number(0)", 0, Number(0) ); +new TestCase( SECTION, "Number(-0)", -0, Number(-0) ); +new TestCase( SECTION, "Number(1)", 1, Number(1) ); +new TestCase( SECTION, "Number(-1)", -1, Number(-1) ); +new TestCase( SECTION, "Number(Number.MAX_VALUE)", 1.7976931348623157e308, Number(Number.MAX_VALUE) ); +new TestCase( SECTION, "Number(Number.MIN_VALUE)", 5e-324, Number(Number.MIN_VALUE) ); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Number(Number.NaN)", Number.NaN, Number(Number.NaN) ); +new TestCase( SECTION, "Number(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, Number(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "Number(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, Number(Number.NEGATIVE_INFINITY) ); - // special cases here - - array[item++] = new TestCase( SECTION, "Number()", 0, Number() ); - array[item++] = new TestCase( SECTION, "Number(eval('var x'))", Number.NaN, Number(eval("var x")) ); - array[item++] = new TestCase( SECTION, "Number(void 0)", Number.NaN, Number(void 0) ); - array[item++] = new TestCase( SECTION, "Number(null)", 0, Number(null) ); - array[item++] = new TestCase( SECTION, "Number(true)", 1, Number(true) ); - array[item++] = new TestCase( SECTION, "Number(false)", 0, Number(false) ); - array[item++] = new TestCase( SECTION, "Number(0)", 0, Number(0) ); - array[item++] = new TestCase( SECTION, "Number(-0)", -0, Number(-0) ); - array[item++] = new TestCase( SECTION, "Number(1)", 1, Number(1) ); - array[item++] = new TestCase( SECTION, "Number(-1)", -1, Number(-1) ); - array[item++] = new TestCase( SECTION, "Number(Number.MAX_VALUE)", 1.7976931348623157e308, Number(Number.MAX_VALUE) ); - array[item++] = new TestCase( SECTION, "Number(Number.MIN_VALUE)", 5e-324, Number(Number.MIN_VALUE) ); - - array[item++] = new TestCase( SECTION, "Number(Number.NaN)", Number.NaN, Number(Number.NaN) ); - array[item++] = new TestCase( SECTION, "Number(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, Number(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "Number(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, Number(Number.NEGATIVE_INFINITY) ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/TypeConversion/9.4-1.js b/mozilla/js/tests/ecma/TypeConversion/9.4-1.js index 23192fe9f0c..19b279439f6 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.4-1.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.4-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,102 +35,76 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.4-1.js - ECMA Section: 9.4 ToInteger - Description: 1. Call ToNumber on the input argument - 2. If Result(1) is NaN, return +0 - 3. If Result(1) is +0, -0, Infinity, or -Infinity, - return Result(1). - 4. Compute sign(Result(1)) * floor(abs(Result(1))). - 5. Return Result(4). + File Name: 9.4-1.js + ECMA Section: 9.4 ToInteger + Description: 1. Call ToNumber on the input argument + 2. If Result(1) is NaN, return +0 + 3. If Result(1) is +0, -0, Infinity, or -Infinity, + return Result(1). + 4. Compute sign(Result(1)) * floor(abs(Result(1))). + 5. Return Result(4). - To test ToInteger, this test uses new Date(value), - 15.9.3.7. The Date constructor sets the [[Value]] - property of the new object to TimeClip(value), which - uses the rules: + To test ToInteger, this test uses new Date(value), + 15.9.3.7. The Date constructor sets the [[Value]] + property of the new object to TimeClip(value), which + uses the rules: - TimeClip(time) - 1. If time is not finite, return NaN - 2. If abs(Result(1)) > 8.64e15, return NaN - 3. Return an implementation dependent choice of either - ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) - (Adding a positive 0 converts -0 to +0). + TimeClip(time) + 1. If time is not finite, return NaN + 2. If abs(Result(1)) > 8.64e15, return NaN + 3. Return an implementation dependent choice of either + ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) + (Adding a positive 0 converts -0 to +0). - This tests ToInteger for values -8.64e15 > value > 8.64e15, - not including -0 and +0. + This tests ToInteger for values -8.64e15 > value > 8.64e15, + not including -0 and +0. - For additional special cases (0, +0, Infinity, -Infinity, - and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. + For additional special cases (0, +0, Infinity, -Infinity, + and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. - Author: christine@netscape.com - Date: 10 july 1997 + Author: christine@netscape.com + Date: 10 july 1997 */ - var SECTION = "9.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "ToInteger"; +var SECTION = "9.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToInteger"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// some special cases -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); +new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); +// value is not an integer - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); +new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); - // some special cases +// value is not a number - array[item++] = new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); - array[item++] = new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); +new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); - // value is not an integer +new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); +// edge cases +new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); - - // value is not a number - - array[item++] = new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); - array[item++] = new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); - - array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); - - // edge cases - array[item++] = new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/TypeConversion/9.4-2.js b/mozilla/js/tests/ecma/TypeConversion/9.4-2.js index 23192fe9f0c..19b279439f6 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.4-2.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.4-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,102 +35,76 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.4-1.js - ECMA Section: 9.4 ToInteger - Description: 1. Call ToNumber on the input argument - 2. If Result(1) is NaN, return +0 - 3. If Result(1) is +0, -0, Infinity, or -Infinity, - return Result(1). - 4. Compute sign(Result(1)) * floor(abs(Result(1))). - 5. Return Result(4). + File Name: 9.4-1.js + ECMA Section: 9.4 ToInteger + Description: 1. Call ToNumber on the input argument + 2. If Result(1) is NaN, return +0 + 3. If Result(1) is +0, -0, Infinity, or -Infinity, + return Result(1). + 4. Compute sign(Result(1)) * floor(abs(Result(1))). + 5. Return Result(4). - To test ToInteger, this test uses new Date(value), - 15.9.3.7. The Date constructor sets the [[Value]] - property of the new object to TimeClip(value), which - uses the rules: + To test ToInteger, this test uses new Date(value), + 15.9.3.7. The Date constructor sets the [[Value]] + property of the new object to TimeClip(value), which + uses the rules: - TimeClip(time) - 1. If time is not finite, return NaN - 2. If abs(Result(1)) > 8.64e15, return NaN - 3. Return an implementation dependent choice of either - ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) - (Adding a positive 0 converts -0 to +0). + TimeClip(time) + 1. If time is not finite, return NaN + 2. If abs(Result(1)) > 8.64e15, return NaN + 3. Return an implementation dependent choice of either + ToInteger(Result(2)) or ToInteger(Result(2)) + (+0) + (Adding a positive 0 converts -0 to +0). - This tests ToInteger for values -8.64e15 > value > 8.64e15, - not including -0 and +0. + This tests ToInteger for values -8.64e15 > value > 8.64e15, + not including -0 and +0. - For additional special cases (0, +0, Infinity, -Infinity, - and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. + For additional special cases (0, +0, Infinity, -Infinity, + and NaN, see 9.4-2.js). For value is String, see 9.4-3.js. - Author: christine@netscape.com - Date: 10 july 1997 + Author: christine@netscape.com + Date: 10 july 1997 */ - var SECTION = "9.4-1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "ToInteger"; +var SECTION = "9.4-1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "ToInteger"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = getTestCases(); - test(); +// some special cases -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); +new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); +// value is not an integer - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); +new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); +new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); - // some special cases +// value is not a number - array[item++] = new TestCase( SECTION, "td = new Date(Number.NaN); td.valueOf()", Number.NaN, eval("td = new Date(Number.NaN); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.POSITIVE_INFINITY); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-Infinity); td.valueOf()", Number.NaN, eval("td = new Date(Number.NEGATIVE_INFINITY); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-0); td.valueOf()", -0, eval("td = new Date(-0); td.valueOf()" ) ); - array[item++] = new TestCase( SECTION, "td = new Date(0); td.valueOf()", 0, eval("td = new Date(0); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); +new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); - // value is not an integer +new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(3.14159); td.valueOf()", 3, eval("td = new Date(3.14159); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(Math.PI); td.valueOf()", 3, eval("td = new Date(Math.PI); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-Math.PI);td.valueOf()", -3, eval("td = new Date(-Math.PI);td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(3.14159e2); td.valueOf()", 314, eval("td = new Date(3.14159e2); td.valueOf()") ); +// edge cases +new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); +new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(.692147e1); td.valueOf()", 6, eval("td = new Date(.692147e1);td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-.692147e1);td.valueOf()", -6, eval("td = new Date(-.692147e1);td.valueOf()") ); - - // value is not a number - - array[item++] = new TestCase( SECTION, "td = new Date(true); td.valueOf()", 1, eval("td = new Date(true); td.valueOf()" ) ); - array[item++] = new TestCase( SECTION, "td = new Date(false); td.valueOf()", 0, eval("td = new Date(false); td.valueOf()") ); - - array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(new Number(Math.PI)); td.valueOf()", 3, eval("td = new Date(new Number(Math.PI)); td.valueOf()") ); - - // edge cases - array[item++] = new TestCase( SECTION, "td = new Date(8.64e15); td.valueOf()", 8.64e15, eval("td = new Date(8.64e15); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-8.64e15); td.valueOf()", -8.64e15, eval("td = new Date(-8.64e15); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(8.64e-15); td.valueOf()", 0, eval("td = new Date(8.64e-15); td.valueOf()") ); - array[item++] = new TestCase( SECTION, "td = new Date(-8.64e-15); td.valueOf()", 0, eval("td = new Date(-8.64e-15); td.valueOf()") ); - - return ( array ); -} +test(); diff --git a/mozilla/js/tests/ecma/TypeConversion/9.5-2.js b/mozilla/js/tests/ecma/TypeConversion/9.5-2.js index 92bc85b6b1d..8b6f5fbab09 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.5-2.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.5-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,153 +35,137 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.5-2.js - ECMA Section: 9.5 Type Conversion: ToInt32 - Description: rules for converting an argument to a signed 32 bit integer + File Name: 9.5-2.js + ECMA Section: 9.5 Type Conversion: ToInt32 + Description: rules for converting an argument to a signed 32 bit integer - this test uses << 0 to convert the argument to a 32bit - integer. + this test uses << 0 to convert the argument to a 32bit + integer. - The operator ToInt32 converts its argument to one of 2^32 - integer values in the range -2^31 through 2^31 inclusive. - This operator functions as follows: + The operator ToInt32 converts its argument to one of 2^32 + integer values in the range -2^31 through 2^31 inclusive. + This operator functions as follows: - 1 call ToNumber on argument - 2 if result is NaN, 0, -0, return 0 - 3 compute (sign (result(1)) * floor(abs(result 1))) - 4 compute result(3) modulo 2^32: - 5 if result(4) is greater than or equal to 2^31, return - result(5)-2^32. otherwise, return result(5) + 1 call ToNumber on argument + 2 if result is NaN, 0, -0, return 0 + 3 compute (sign (result(1)) * floor(abs(result 1))) + 4 compute result(3) modulo 2^32: + 5 if result(4) is greater than or equal to 2^31, return + result(5)-2^32. otherwise, return result(5) - special cases: - -0 returns 0 - Infinity returns 0 - -Infinity returns 0 - ToInt32(ToUint32(x)) == ToInt32(x) for all values of x - Numbers greater than 2^31 (see step 5 above) - (note http://bugzilla.mozilla.org/show_bug.cgi?id=120083) + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + ToInt32(ToUint32(x)) == ToInt32(x) for all values of x + Numbers greater than 2^31 (see step 5 above) + (note http://bugzilla.mozilla.org/show_bug.cgi?id=120083) - Author: christine@netscape.com - Date: 17 july 1997 + Author: christine@netscape.com + Date: 17 july 1997 */ - var SECTION = "9.5-2"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "9.5-2"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " ToInt32"); - test(); +writeHeaderToLog( SECTION + " ToInt32"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "0 << 0", 0, 0 << 0 ); +new TestCase( SECTION, "-0 << 0", 0, -0 << 0 ); +new TestCase( SECTION, "Infinity << 0", 0, "Infinity" << 0 ); +new TestCase( SECTION, "-Infinity << 0", 0, "-Infinity" << 0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY << 0", 0, Number.POSITIVE_INFINITY << 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY << 0", 0, Number.NEGATIVE_INFINITY << 0 ); +new TestCase( SECTION, "Number.NaN << 0", 0, Number.NaN << 0 ); + +new TestCase( SECTION, "Number.MIN_VALUE << 0", 0, Number.MIN_VALUE << 0 ); +new TestCase( SECTION, "-Number.MIN_VALUE << 0", 0, -Number.MIN_VALUE << 0 ); +new TestCase( SECTION, "0.1 << 0", 0, 0.1 << 0 ); +new TestCase( SECTION, "-0.1 << 0", 0, -0.1 << 0 ); +new TestCase( SECTION, "1 << 0", 1, 1 << 0 ); +new TestCase( SECTION, "1.1 << 0", 1, 1.1 << 0 ); +new TestCase( SECTION, "-1 << 0", ToInt32(-1), -1 << 0 ); + + +new TestCase( SECTION, "2147483647 << 0", ToInt32(2147483647), 2147483647 << 0 ); +new TestCase( SECTION, "2147483648 << 0", ToInt32(2147483648), 2147483648 << 0 ); +new TestCase( SECTION, "2147483649 << 0", ToInt32(2147483649), 2147483649 << 0 ); + +new TestCase( SECTION, "(Math.pow(2,31)-1) << 0", ToInt32(2147483647), (Math.pow(2,31)-1) << 0 ); +new TestCase( SECTION, "Math.pow(2,31) << 0", ToInt32(2147483648), Math.pow(2,31) << 0 ); +new TestCase( SECTION, "(Math.pow(2,31)+1) << 0", ToInt32(2147483649), (Math.pow(2,31)+1) << 0 ); + +new TestCase( SECTION, "(Math.pow(2,32)-1) << 0", ToInt32(4294967295), (Math.pow(2,32)-1) << 0 ); +new TestCase( SECTION, "(Math.pow(2,32)) << 0", ToInt32(4294967296), (Math.pow(2,32)) << 0 ); +new TestCase( SECTION, "(Math.pow(2,32)+1) << 0", ToInt32(4294967297), (Math.pow(2,32)+1) << 0 ); + +new TestCase( SECTION, "4294967295 << 0", ToInt32(4294967295), 4294967295 << 0 ); +new TestCase( SECTION, "4294967296 << 0", ToInt32(4294967296), 4294967296 << 0 ); +new TestCase( SECTION, "4294967297 << 0", ToInt32(4294967297), 4294967297 << 0 ); + +new TestCase( SECTION, "'2147483647' << 0", ToInt32(2147483647), '2147483647' << 0 ); +new TestCase( SECTION, "'2147483648' << 0", ToInt32(2147483648), '2147483648' << 0 ); +new TestCase( SECTION, "'2147483649' << 0", ToInt32(2147483649), '2147483649' << 0 ); + +new TestCase( SECTION, "'4294967295' << 0", ToInt32(4294967295), '4294967295' << 0 ); +new TestCase( SECTION, "'4294967296' << 0", ToInt32(4294967296), '4294967296' << 0 ); +new TestCase( SECTION, "'4294967297' << 0", ToInt32(4294967297), '4294967297' << 0 ); + +new TestCase( SECTION, "-2147483647 << 0", ToInt32(-2147483647), -2147483647 << 0 ); +new TestCase( SECTION, "-2147483648 << 0", ToInt32(-2147483648), -2147483648 << 0 ); +new TestCase( SECTION, "-2147483649 << 0", ToInt32(-2147483649), -2147483649 << 0 ); + +new TestCase( SECTION, "-4294967295 << 0", ToInt32(-4294967295), -4294967295 << 0 ); +new TestCase( SECTION, "-4294967296 << 0", ToInt32(-4294967296), -4294967296 << 0 ); +new TestCase( SECTION, "-4294967297 << 0", ToInt32(-4294967297), -4294967297 << 0 ); + +/* + * Numbers between 2^31 and 2^32 will have a negative ToInt32 per ECMA (see step 5 of introduction) + * (These are by stevechapel@earthlink.net; cf. http://bugzilla.mozilla.org/show_bug.cgi?id=120083) + */ +new TestCase( SECTION, "2147483648.25 << 0", ToInt32(2147483648.25), 2147483648.25 << 0 ); +new TestCase( SECTION, "2147483648.5 << 0", ToInt32(2147483648.5), 2147483648.5 << 0 ); +new TestCase( SECTION, "2147483648.75 << 0", ToInt32(2147483648.75), 2147483648.75 << 0 ); +new TestCase( SECTION, "4294967295.25 << 0", ToInt32(4294967295.25), 4294967295.25 << 0 ); +new TestCase( SECTION, "4294967295.5 << 0", ToInt32(4294967295.5), 4294967295.5 << 0 ); +new TestCase( SECTION, "4294967295.75 << 0", ToInt32(4294967295.75), 4294967295.75 << 0 ); +new TestCase( SECTION, "3000000000.25 << 0", ToInt32(3000000000.25), 3000000000.25 << 0 ); +new TestCase( SECTION, "3000000000.5 << 0", ToInt32(3000000000.5), 3000000000.5 << 0 ); +new TestCase( SECTION, "3000000000.75 << 0", ToInt32(3000000000.75), 3000000000.75 << 0 ); + +/* + * Numbers between - 2^31 and - 2^32 + */ +new TestCase( SECTION, "-2147483648.25 << 0", ToInt32(-2147483648.25), -2147483648.25 << 0 ); +new TestCase( SECTION, "-2147483648.5 << 0", ToInt32(-2147483648.5), -2147483648.5 << 0 ); +new TestCase( SECTION, "-2147483648.75 << 0", ToInt32(-2147483648.75), -2147483648.75 << 0 ); +new TestCase( SECTION, "-4294967295.25 << 0", ToInt32(-4294967295.25), -4294967295.25 << 0 ); +new TestCase( SECTION, "-4294967295.5 << 0", ToInt32(-4294967295.5), -4294967295.5 << 0 ); +new TestCase( SECTION, "-4294967295.75 << 0", ToInt32(-4294967295.75), -4294967295.75 << 0 ); +new TestCase( SECTION, "-3000000000.25 << 0", ToInt32(-3000000000.25), -3000000000.25 << 0 ); +new TestCase( SECTION, "-3000000000.5 << 0", ToInt32(-3000000000.5), -3000000000.5 << 0 ); +new TestCase( SECTION, "-3000000000.75 << 0", ToInt32(-3000000000.75), -3000000000.75 << 0 ); + + +test(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function ToInt32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } - n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); - if ( sign == -1 ) { - n = ( n < -Math.pow(2,31) ) ? n + Math.pow(2,32) : n; - } else{ - n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; - } + n = (sign * Math.floor( Math.abs(n) )) % Math.pow(2,32); + if ( sign == -1 ) { + n = ( n < -Math.pow(2,31) ) ? n + Math.pow(2,32) : n; + } else{ + n = ( n >= Math.pow(2,31) ) ? n - Math.pow(2,32) : n; + } - return ( n ); + return ( n ); } -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "0 << 0", 0, 0 << 0 ); - array[item++] = new TestCase( SECTION, "-0 << 0", 0, -0 << 0 ); - array[item++] = new TestCase( SECTION, "Infinity << 0", 0, "Infinity" << 0 ); - array[item++] = new TestCase( SECTION, "-Infinity << 0", 0, "-Infinity" << 0 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY << 0", 0, Number.POSITIVE_INFINITY << 0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY << 0", 0, Number.NEGATIVE_INFINITY << 0 ); - array[item++] = new TestCase( SECTION, "Number.NaN << 0", 0, Number.NaN << 0 ); - - array[item++] = new TestCase( SECTION, "Number.MIN_VALUE << 0", 0, Number.MIN_VALUE << 0 ); - array[item++] = new TestCase( SECTION, "-Number.MIN_VALUE << 0", 0, -Number.MIN_VALUE << 0 ); - array[item++] = new TestCase( SECTION, "0.1 << 0", 0, 0.1 << 0 ); - array[item++] = new TestCase( SECTION, "-0.1 << 0", 0, -0.1 << 0 ); - array[item++] = new TestCase( SECTION, "1 << 0", 1, 1 << 0 ); - array[item++] = new TestCase( SECTION, "1.1 << 0", 1, 1.1 << 0 ); - array[item++] = new TestCase( SECTION, "-1 << 0", ToInt32(-1), -1 << 0 ); - - - array[item++] = new TestCase( SECTION, "2147483647 << 0", ToInt32(2147483647), 2147483647 << 0 ); - array[item++] = new TestCase( SECTION, "2147483648 << 0", ToInt32(2147483648), 2147483648 << 0 ); - array[item++] = new TestCase( SECTION, "2147483649 << 0", ToInt32(2147483649), 2147483649 << 0 ); - - array[item++] = new TestCase( SECTION, "(Math.pow(2,31)-1) << 0", ToInt32(2147483647), (Math.pow(2,31)-1) << 0 ); - array[item++] = new TestCase( SECTION, "Math.pow(2,31) << 0", ToInt32(2147483648), Math.pow(2,31) << 0 ); - array[item++] = new TestCase( SECTION, "(Math.pow(2,31)+1) << 0", ToInt32(2147483649), (Math.pow(2,31)+1) << 0 ); - - array[item++] = new TestCase( SECTION, "(Math.pow(2,32)-1) << 0", ToInt32(4294967295), (Math.pow(2,32)-1) << 0 ); - array[item++] = new TestCase( SECTION, "(Math.pow(2,32)) << 0", ToInt32(4294967296), (Math.pow(2,32)) << 0 ); - array[item++] = new TestCase( SECTION, "(Math.pow(2,32)+1) << 0", ToInt32(4294967297), (Math.pow(2,32)+1) << 0 ); - - array[item++] = new TestCase( SECTION, "4294967295 << 0", ToInt32(4294967295), 4294967295 << 0 ); - array[item++] = new TestCase( SECTION, "4294967296 << 0", ToInt32(4294967296), 4294967296 << 0 ); - array[item++] = new TestCase( SECTION, "4294967297 << 0", ToInt32(4294967297), 4294967297 << 0 ); - - array[item++] = new TestCase( SECTION, "'2147483647' << 0", ToInt32(2147483647), '2147483647' << 0 ); - array[item++] = new TestCase( SECTION, "'2147483648' << 0", ToInt32(2147483648), '2147483648' << 0 ); - array[item++] = new TestCase( SECTION, "'2147483649' << 0", ToInt32(2147483649), '2147483649' << 0 ); - - array[item++] = new TestCase( SECTION, "'4294967295' << 0", ToInt32(4294967295), '4294967295' << 0 ); - array[item++] = new TestCase( SECTION, "'4294967296' << 0", ToInt32(4294967296), '4294967296' << 0 ); - array[item++] = new TestCase( SECTION, "'4294967297' << 0", ToInt32(4294967297), '4294967297' << 0 ); - - array[item++] = new TestCase( SECTION, "-2147483647 << 0", ToInt32(-2147483647), -2147483647 << 0 ); - array[item++] = new TestCase( SECTION, "-2147483648 << 0", ToInt32(-2147483648), -2147483648 << 0 ); - array[item++] = new TestCase( SECTION, "-2147483649 << 0", ToInt32(-2147483649), -2147483649 << 0 ); - - array[item++] = new TestCase( SECTION, "-4294967295 << 0", ToInt32(-4294967295), -4294967295 << 0 ); - array[item++] = new TestCase( SECTION, "-4294967296 << 0", ToInt32(-4294967296), -4294967296 << 0 ); - array[item++] = new TestCase( SECTION, "-4294967297 << 0", ToInt32(-4294967297), -4294967297 << 0 ); - - /* - * Numbers between 2^31 and 2^32 will have a negative ToInt32 per ECMA (see step 5 of introduction) - * (These are by stevechapel@earthlink.net; cf. http://bugzilla.mozilla.org/show_bug.cgi?id=120083) - */ - array[item++] = new TestCase( SECTION, "2147483648.25 << 0", ToInt32(2147483648.25), 2147483648.25 << 0 ); - array[item++] = new TestCase( SECTION, "2147483648.5 << 0", ToInt32(2147483648.5), 2147483648.5 << 0 ); - array[item++] = new TestCase( SECTION, "2147483648.75 << 0", ToInt32(2147483648.75), 2147483648.75 << 0 ); - array[item++] = new TestCase( SECTION, "4294967295.25 << 0", ToInt32(4294967295.25), 4294967295.25 << 0 ); - array[item++] = new TestCase( SECTION, "4294967295.5 << 0", ToInt32(4294967295.5), 4294967295.5 << 0 ); - array[item++] = new TestCase( SECTION, "4294967295.75 << 0", ToInt32(4294967295.75), 4294967295.75 << 0 ); - array[item++] = new TestCase( SECTION, "3000000000.25 << 0", ToInt32(3000000000.25), 3000000000.25 << 0 ); - array[item++] = new TestCase( SECTION, "3000000000.5 << 0", ToInt32(3000000000.5), 3000000000.5 << 0 ); - array[item++] = new TestCase( SECTION, "3000000000.75 << 0", ToInt32(3000000000.75), 3000000000.75 << 0 ); - - /* - * Numbers between - 2^31 and - 2^32 - */ - array[item++] = new TestCase( SECTION, "-2147483648.25 << 0", ToInt32(-2147483648.25), -2147483648.25 << 0 ); - array[item++] = new TestCase( SECTION, "-2147483648.5 << 0", ToInt32(-2147483648.5), -2147483648.5 << 0 ); - array[item++] = new TestCase( SECTION, "-2147483648.75 << 0", ToInt32(-2147483648.75), -2147483648.75 << 0 ); - array[item++] = new TestCase( SECTION, "-4294967295.25 << 0", ToInt32(-4294967295.25), -4294967295.25 << 0 ); - array[item++] = new TestCase( SECTION, "-4294967295.5 << 0", ToInt32(-4294967295.5), -4294967295.5 << 0 ); - array[item++] = new TestCase( SECTION, "-4294967295.75 << 0", ToInt32(-4294967295.75), -4294967295.75 << 0 ); - array[item++] = new TestCase( SECTION, "-3000000000.25 << 0", ToInt32(-3000000000.25), -3000000000.25 << 0 ); - array[item++] = new TestCase( SECTION, "-3000000000.5 << 0", ToInt32(-3000000000.5), -3000000000.5 << 0 ); - array[item++] = new TestCase( SECTION, "-3000000000.75 << 0", ToInt32(-3000000000.75), -3000000000.75 << 0 ); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/TypeConversion/9.6.js b/mozilla/js/tests/ecma/TypeConversion/9.6.js index aff3e9053f0..bf3965bb151 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.6.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,121 +35,104 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.6.js - ECMA Section: 9.6 Type Conversion: ToUint32 - Description: rules for converting an argument to an unsigned - 32 bit integer + File Name: 9.6.js + ECMA Section: 9.6 Type Conversion: ToUint32 + Description: rules for converting an argument to an unsigned + 32 bit integer - this test uses >>> 0 to convert the argument to - an unsigned 32bit integer. + this test uses >>> 0 to convert the argument to + an unsigned 32bit integer. - 1 call ToNumber on argument - 2 if result is NaN, 0, -0, Infinity, -Infinity - return 0 - 3 compute (sign (result(1)) * floor(abs(result 1))) - 4 compute result(3) modulo 2^32: - 5 return result(4) + 1 call ToNumber on argument + 2 if result is NaN, 0, -0, Infinity, -Infinity + return 0 + 3 compute (sign (result(1)) * floor(abs(result 1))) + 4 compute result(3) modulo 2^32: + 5 return result(4) - special cases: - -0 returns 0 - Infinity returns 0 - -Infinity returns 0 - 0 returns 0 - ToInt32(ToUint32(x)) == ToInt32(x) for all values of x - ** NEED TO DO THIS PART IN A SEPARATE TEST FILE ** + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + 0 returns 0 + ToInt32(ToUint32(x)) == ToInt32(x) for all values of x + ** NEED TO DO THIS PART IN A SEPARATE TEST FILE ** - Author: christine@netscape.com - Date: 17 july 1997 + Author: christine@netscape.com + Date: 17 july 1997 */ - var SECTION = "9.6"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "9.6"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Type Conversion: ToUint32"); - test(); +writeHeaderToLog( SECTION + " Type Conversion: ToUint32"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "0 >>> 0", 0, 0 >>> 0 ); +// new TestCase( SECTION, "+0 >>> 0", 0, +0 >>> 0); +new TestCase( SECTION, "-0 >>> 0", 0, -0 >>> 0 ); +new TestCase( SECTION, "'Infinity' >>> 0", 0, "Infinity" >>> 0 ); +new TestCase( SECTION, "'-Infinity' >>> 0", 0, "-Infinity" >>> 0); +new TestCase( SECTION, "'+Infinity' >>> 0", 0, "+Infinity" >>> 0 ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY >>> 0", 0, Number.POSITIVE_INFINITY >>> 0 ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY >>> 0", 0, Number.NEGATIVE_INFINITY >>> 0 ); +new TestCase( SECTION, "Number.NaN >>> 0", 0, Number.NaN >>> 0 ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, "Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); +new TestCase( SECTION, "-Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); +new TestCase( SECTION, "0.1 >>> 0", 0, 0.1 >>> 0 ); +new TestCase( SECTION, "-0.1 >>> 0", 0, -0.1 >>> 0 ); +new TestCase( SECTION, "1 >>> 0", 1, 1 >>> 0 ); +new TestCase( SECTION, "1.1 >>> 0", 1, 1.1 >>> 0 ); + +new TestCase( SECTION, "-1.1 >>> 0", ToUint32(-1.1), -1.1 >>> 0 ); +new TestCase( SECTION, "-1 >>> 0", ToUint32(-1), -1 >>> 0 ); + +new TestCase( SECTION, "2147483647 >>> 0", ToUint32(2147483647), 2147483647 >>> 0 ); +new TestCase( SECTION, "2147483648 >>> 0", ToUint32(2147483648), 2147483648 >>> 0 ); +new TestCase( SECTION, "2147483649 >>> 0", ToUint32(2147483649), 2147483649 >>> 0 ); + +new TestCase( SECTION, "4294967295 >>> 0", ToUint32(4294967295), 4294967295 >>> 0 ); +new TestCase( SECTION, "4294967296 >>> 0", ToUint32(4294967296), 4294967296 >>> 0 ); +new TestCase( SECTION, "4294967297 >>> 0", ToUint32(4294967297), 4294967297 >>> 0 ); + +new TestCase( SECTION, "-2147483647 >>> 0", ToUint32(-2147483647), -2147483647 >>> 0 ); +new TestCase( SECTION, "-2147483648 >>> 0", ToUint32(-2147483648), -2147483648 >>> 0 ); +new TestCase( SECTION, "-2147483649 >>> 0", ToUint32(-2147483649), -2147483649 >>> 0 ); + +new TestCase( SECTION, "-4294967295 >>> 0", ToUint32(-4294967295), -4294967295 >>> 0 ); +new TestCase( SECTION, "-4294967296 >>> 0", ToUint32(-4294967296), -4294967296 >>> 0 ); +new TestCase( SECTION, "-4294967297 >>> 0", ToUint32(-4294967297), -4294967297 >>> 0 ); + +new TestCase( SECTION, "'2147483647' >>> 0", ToUint32(2147483647), '2147483647' >>> 0 ); +new TestCase( SECTION, "'2147483648' >>> 0", ToUint32(2147483648), '2147483648' >>> 0 ); +new TestCase( SECTION, "'2147483649' >>> 0", ToUint32(2147483649), '2147483649' >>> 0 ); + +new TestCase( SECTION, "'4294967295' >>> 0", ToUint32(4294967295), '4294967295' >>> 0 ); +new TestCase( SECTION, "'4294967296' >>> 0", ToUint32(4294967296), '4294967296' >>> 0 ); +new TestCase( SECTION, "'4294967297' >>> 0", ToUint32(4294967297), '4294967297' >>> 0 ); + + +test(); function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 || Math.abs( n ) == Number.POSITIVE_INFINITY) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); + return ( n ); } -function getTestCases() { - var array = new Array(); - var item = 0; - array[item++] = new TestCase( SECTION, "0 >>> 0", 0, 0 >>> 0 ); -// array[item++] = new TestCase( SECTION, "+0 >>> 0", 0, +0 >>> 0); - array[item++] = new TestCase( SECTION, "-0 >>> 0", 0, -0 >>> 0 ); - array[item++] = new TestCase( SECTION, "'Infinity' >>> 0", 0, "Infinity" >>> 0 ); - array[item++] = new TestCase( SECTION, "'-Infinity' >>> 0", 0, "-Infinity" >>> 0); - array[item++] = new TestCase( SECTION, "'+Infinity' >>> 0", 0, "+Infinity" >>> 0 ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY >>> 0", 0, Number.POSITIVE_INFINITY >>> 0 ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY >>> 0", 0, Number.NEGATIVE_INFINITY >>> 0 ); - array[item++] = new TestCase( SECTION, "Number.NaN >>> 0", 0, Number.NaN >>> 0 ); - - array[item++] = new TestCase( SECTION, "Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); - array[item++] = new TestCase( SECTION, "-Number.MIN_VALUE >>> 0", 0, Number.MIN_VALUE >>> 0 ); - array[item++] = new TestCase( SECTION, "0.1 >>> 0", 0, 0.1 >>> 0 ); - array[item++] = new TestCase( SECTION, "-0.1 >>> 0", 0, -0.1 >>> 0 ); - array[item++] = new TestCase( SECTION, "1 >>> 0", 1, 1 >>> 0 ); - array[item++] = new TestCase( SECTION, "1.1 >>> 0", 1, 1.1 >>> 0 ); - - array[item++] = new TestCase( SECTION, "-1.1 >>> 0", ToUint32(-1.1), -1.1 >>> 0 ); - array[item++] = new TestCase( SECTION, "-1 >>> 0", ToUint32(-1), -1 >>> 0 ); - - array[item++] = new TestCase( SECTION, "2147483647 >>> 0", ToUint32(2147483647), 2147483647 >>> 0 ); - array[item++] = new TestCase( SECTION, "2147483648 >>> 0", ToUint32(2147483648), 2147483648 >>> 0 ); - array[item++] = new TestCase( SECTION, "2147483649 >>> 0", ToUint32(2147483649), 2147483649 >>> 0 ); - - array[item++] = new TestCase( SECTION, "4294967295 >>> 0", ToUint32(4294967295), 4294967295 >>> 0 ); - array[item++] = new TestCase( SECTION, "4294967296 >>> 0", ToUint32(4294967296), 4294967296 >>> 0 ); - array[item++] = new TestCase( SECTION, "4294967297 >>> 0", ToUint32(4294967297), 4294967297 >>> 0 ); - - array[item++] = new TestCase( SECTION, "-2147483647 >>> 0", ToUint32(-2147483647), -2147483647 >>> 0 ); - array[item++] = new TestCase( SECTION, "-2147483648 >>> 0", ToUint32(-2147483648), -2147483648 >>> 0 ); - array[item++] = new TestCase( SECTION, "-2147483649 >>> 0", ToUint32(-2147483649), -2147483649 >>> 0 ); - - array[item++] = new TestCase( SECTION, "-4294967295 >>> 0", ToUint32(-4294967295), -4294967295 >>> 0 ); - array[item++] = new TestCase( SECTION, "-4294967296 >>> 0", ToUint32(-4294967296), -4294967296 >>> 0 ); - array[item++] = new TestCase( SECTION, "-4294967297 >>> 0", ToUint32(-4294967297), -4294967297 >>> 0 ); - - array[item++] = new TestCase( SECTION, "'2147483647' >>> 0", ToUint32(2147483647), '2147483647' >>> 0 ); - array[item++] = new TestCase( SECTION, "'2147483648' >>> 0", ToUint32(2147483648), '2147483648' >>> 0 ); - array[item++] = new TestCase( SECTION, "'2147483649' >>> 0", ToUint32(2147483649), '2147483649' >>> 0 ); - - array[item++] = new TestCase( SECTION, "'4294967295' >>> 0", ToUint32(4294967295), '4294967295' >>> 0 ); - array[item++] = new TestCase( SECTION, "'4294967296' >>> 0", ToUint32(4294967296), '4294967296' >>> 0 ); - array[item++] = new TestCase( SECTION, "'4294967297' >>> 0", ToUint32(4294967297), '4294967297' >>> 0 ); - - return ( array ); -} diff --git a/mozilla/js/tests/ecma/TypeConversion/9.7.js b/mozilla/js/tests/ecma/TypeConversion/9.7.js index 26b7acc0ca3..4725ec68f4a 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.7.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,140 +35,124 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.7.js - ECMA Section: 9.7 Type Conversion: ToInt16 - Description: rules for converting an argument to an unsigned - 16 bit integer in the range 0 to 2^16-1. + File Name: 9.7.js + ECMA Section: 9.7 Type Conversion: ToInt16 + Description: rules for converting an argument to an unsigned + 16 bit integer in the range 0 to 2^16-1. - this test uses String.prototype.fromCharCode() and - String.prototype.charCodeAt() to test ToInt16. + this test uses String.prototype.fromCharCode() and + String.prototype.charCodeAt() to test ToInt16. - special cases: - -0 returns 0 - Infinity returns 0 - -Infinity returns 0 - 0 returns 0 + special cases: + -0 returns 0 + Infinity returns 0 + -Infinity returns 0 + 0 returns 0 - Author: christine@netscape.com - Date: 17 july 1997 + Author: christine@netscape.com + Date: 17 july 1997 */ - var SECTION = "9.7"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "9.7"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " Type Conversion: ToInt16"); - test(); +writeHeaderToLog( SECTION + " Type Conversion: ToInt16"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function ToInt16( num ) { - num = Number( num ); - if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { - return 0; - } - - var sign = ( num < 0 ) ? -1 : 1; - - num = sign * Math.floor( Math.abs( num ) ); - - num = num % Math.pow(2,16); - - num = ( num > -65536 && num < 0) ? 65536 + num : num; - - return num; -} - -function getTestCases() { - var array = new Array(); - var item = 0; /* - array[item++] = new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", 0, String.fromCharCode(0).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", 0, String.fromCharCode(-0).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", 1, String.fromCharCode(1).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", 64, String.fromCharCode(64).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", 126, String.fromCharCode(126).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", 127, String.fromCharCode(127).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", 128, String.fromCharCode(128).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", 130, String.fromCharCode(130).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", 255, String.fromCharCode(255).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", 256, String.fromCharCode(256).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", 0, String.fromCharCode(0).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", 0, String.fromCharCode(-0).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", 1, String.fromCharCode(1).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", 64, String.fromCharCode(64).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", 126, String.fromCharCode(126).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", 127, String.fromCharCode(127).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", 128, String.fromCharCode(128).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", 130, String.fromCharCode(130).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", 255, String.fromCharCode(255).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", 256, String.fromCharCode(256).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); + new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); */ - array[item++] = new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", ToInt16(0), String.fromCharCode(0).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", ToInt16(0), String.fromCharCode(-0).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", ToInt16(1), String.fromCharCode(1).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", ToInt16(64), String.fromCharCode(64).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", ToInt16(126), String.fromCharCode(126).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", ToInt16(127), String.fromCharCode(127).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", ToInt16(128), String.fromCharCode(128).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", ToInt16(130), String.fromCharCode(130).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", ToInt16(255), String.fromCharCode(255).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", ToInt16(256), String.fromCharCode(256).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(0).charCodeAt(0)", ToInt16(0), String.fromCharCode(0).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-0).charCodeAt(0)", ToInt16(0), String.fromCharCode(-0).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(1).charCodeAt(0)", ToInt16(1), String.fromCharCode(1).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(64).charCodeAt(0)", ToInt16(64), String.fromCharCode(64).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(126).charCodeAt(0)", ToInt16(126), String.fromCharCode(126).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(127).charCodeAt(0)", ToInt16(127), String.fromCharCode(127).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(128).charCodeAt(0)", ToInt16(128), String.fromCharCode(128).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(130).charCodeAt(0)", ToInt16(130), String.fromCharCode(130).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(255).charCodeAt(0)", ToInt16(255), String.fromCharCode(255).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(256).charCodeAt(0)", ToInt16(256), String.fromCharCode(256).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(Math.pow(2,16)-1).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(Math.pow(2,16)).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(65535).charCodeAt(0)", ToInt16(65535), String.fromCharCode(65535).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(65536).charCodeAt(0)", ToInt16(65536), String.fromCharCode(65536).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(65537).charCodeAt(0)", ToInt16(65537), String.fromCharCode(65537).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(65535).charCodeAt(0)", ToInt16(65535), String.fromCharCode(65535).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(65536).charCodeAt(0)", ToInt16(65536), String.fromCharCode(65536).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(65537).charCodeAt(0)", ToInt16(65537), String.fromCharCode(65537).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(131071).charCodeAt(0)", ToInt16(131071), String.fromCharCode(131071).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(131072).charCodeAt(0)", ToInt16(131072), String.fromCharCode(131072).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(131073).charCodeAt(0)", ToInt16(131073), String.fromCharCode(131073).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(131071).charCodeAt(0)", ToInt16(131071), String.fromCharCode(131071).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(131072).charCodeAt(0)", ToInt16(131072), String.fromCharCode(131072).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(131073).charCodeAt(0)", ToInt16(131073), String.fromCharCode(131073).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode('65535').charCodeAt(0)", 65535, String.fromCharCode("65535").charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode('65536').charCodeAt(0)", 0, String.fromCharCode("65536").charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode('65535').charCodeAt(0)", 65535, String.fromCharCode("65535").charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode('65536').charCodeAt(0)", 0, String.fromCharCode("65536").charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-1).charCodeAt(0)", ToInt16(-1), String.fromCharCode(-1).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-64).charCodeAt(0)", ToInt16(-64), String.fromCharCode(-64).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-126).charCodeAt(0)", ToInt16(-126), String.fromCharCode(-126).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-127).charCodeAt(0)", ToInt16(-127), String.fromCharCode(-127).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-128).charCodeAt(0)", ToInt16(-128), String.fromCharCode(-128).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-130).charCodeAt(0)", ToInt16(-130), String.fromCharCode(-130).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-255).charCodeAt(0)", ToInt16(-255), String.fromCharCode(-255).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-256).charCodeAt(0)", ToInt16(-256), String.fromCharCode(-256).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-1).charCodeAt(0)", ToInt16(-1), String.fromCharCode(-1).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-64).charCodeAt(0)", ToInt16(-64), String.fromCharCode(-64).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-126).charCodeAt(0)", ToInt16(-126), String.fromCharCode(-126).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-127).charCodeAt(0)", ToInt16(-127), String.fromCharCode(-127).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-128).charCodeAt(0)", ToInt16(-128), String.fromCharCode(-128).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-130).charCodeAt(0)", ToInt16(-130), String.fromCharCode(-130).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-255).charCodeAt(0)", ToInt16(-255), String.fromCharCode(-255).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-256).charCodeAt(0)", ToInt16(-256), String.fromCharCode(-256).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(-Math.pow(2,16)).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0)", 65535, String.fromCharCode(-Math.pow(2,16)-1).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-Math.pow(2,16)).charCodeAt(0)", 0, String.fromCharCode(-Math.pow(2,16)).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-65535).charCodeAt(0)", ToInt16(-65535), String.fromCharCode(-65535).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-65536).charCodeAt(0)", ToInt16(-65536), String.fromCharCode(-65536).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-65537).charCodeAt(0)", ToInt16(-65537), String.fromCharCode(-65537).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-65535).charCodeAt(0)", ToInt16(-65535), String.fromCharCode(-65535).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-65536).charCodeAt(0)", ToInt16(-65536), String.fromCharCode(-65536).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-65537).charCodeAt(0)", ToInt16(-65537), String.fromCharCode(-65537).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-131071).charCodeAt(0)", ToInt16(-131071), String.fromCharCode(-131071).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-131072).charCodeAt(0)", ToInt16(-131072), String.fromCharCode(-131072).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode(-131073).charCodeAt(0)", ToInt16(-131073), String.fromCharCode(-131073).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-131071).charCodeAt(0)", ToInt16(-131071), String.fromCharCode(-131071).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-131072).charCodeAt(0)", ToInt16(-131072), String.fromCharCode(-131072).charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode(-131073).charCodeAt(0)", ToInt16(-131073), String.fromCharCode(-131073).charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode('-65535').charCodeAt(0)", ToInt16(-65535), String.fromCharCode("-65535").charCodeAt(0) ); - array[item++] = new TestCase( "9.7", "String.fromCharCode('-65536').charCodeAt(0)", ToInt16(-65536), String.fromCharCode("-65536").charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode('-65535').charCodeAt(0)", ToInt16(-65535), String.fromCharCode("-65535").charCodeAt(0) ); +new TestCase( "9.7", "String.fromCharCode('-65536').charCodeAt(0)", ToInt16(-65536), String.fromCharCode("-65536").charCodeAt(0) ); -// array[item++] = new TestCase( "9.7", "String.fromCharCode(2147483648).charCodeAt(0)", ToInt16(2147483648), String.fromCharCode(2147483648).charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(2147483648).charCodeAt(0)", ToInt16(2147483648), String.fromCharCode(2147483648).charCodeAt(0) ); // the following test cases cause a runtime error. see: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=78878 -// array[item++] = new TestCase( "9.7", "String.fromCharCode(Infinity).charCodeAt(0)", 0, String.fromCharCode("Infinity").charCodeAt(0) ); -// array[item++] = new TestCase( "9.7", "String.fromCharCode(-Infinity).charCodeAt(0)", 0, String.fromCharCode("-Infinity").charCodeAt(0) ); -// array[item++] = new TestCase( "9.7", "String.fromCharCode(NaN).charCodeAt(0)", 0, String.fromCharCode(Number.NaN).charCodeAt(0) ); -// array[item++] = new TestCase( "9.7", "String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) ); -// array[item++] = new TestCase( "9.7", "String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) ); - return ( array ); +// new TestCase( "9.7", "String.fromCharCode(Infinity).charCodeAt(0)", 0, String.fromCharCode("Infinity").charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(-Infinity).charCodeAt(0)", 0, String.fromCharCode("-Infinity").charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(NaN).charCodeAt(0)", 0, String.fromCharCode(Number.NaN).charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.POSITIVE_INFINITY).charCodeAt(0) ); +// new TestCase( "9.7", "String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0)", 0, String.fromCharCode(Number.NEGATIVE_INFINITY).charCodeAt(0) ); + +test(); + +function ToInt16( num ) { + num = Number( num ); + if ( isNaN( num ) || num == 0 || num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( num < 0 ) ? -1 : 1; + + num = sign * Math.floor( Math.abs( num ) ); + + num = num % Math.pow(2,16); + + num = ( num > -65536 && num < 0) ? 65536 + num : num; + + return num; } + diff --git a/mozilla/js/tests/ecma/TypeConversion/9.8.1.js b/mozilla/js/tests/ecma/TypeConversion/9.8.1.js index 94b81a943cb..bcdd41d2195 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.8.1.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.8.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,148 +35,131 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 9.8.1.js - ECMA Section: 9.8.1 ToString Applied to the Number Type - Description: The operator ToString convers a number m to string - as follows: + File Name: 9.8.1.js + ECMA Section: 9.8.1 ToString Applied to the Number Type + Description: The operator ToString convers a number m to string + as follows: - 1. if m is NaN, return the string "NaN" - 2. if m is +0 or -0, return the string "0" - 3. if m is less than zero, return the string - concatenation of the string "-" and ToString(-m). - 4. If m is Infinity, return the string "Infinity". - 5. Otherwise, let n, k, and s be integers such that - k >= 1, 10k1 <= s < 10k, the number value for s10nk - is m, and k is as small as possible. Note that k is - the number of digits in the decimal representation - of s, that s is not divisible by 10, and that the - least significant digit of s is not necessarily - uniquely determined by these criteria. - 6. If k <= n <= 21, return the string consisting of the - k digits of the decimal representation of s (in order, - with no leading zeroes), followed by n-k occurences - of the character '0'. - 7. If 0 < n <= 21, return the string consisting of the - most significant n digits of the decimal - representation of s, followed by a decimal point - '.', followed by the remaining kn digits of the - decimal representation of s. - 8. If 6 < n <= 0, return the string consisting of the - character '0', followed by a decimal point '.', - followed by n occurences of the character '0', - followed by the k digits of the decimal - representation of s. - 9. Otherwise, if k = 1, return the string consisting - of the single digit of s, followed by lowercase - character 'e', followed by a plus sign '+' or minus - sign '' according to whether n1 is positive or - negative, followed by the decimal representation - of the integer abs(n1) (with no leading zeros). - 10. Return the string consisting of the most significant - digit of the decimal representation of s, followed - by a decimal point '.', followed by the remaining k1 - digits of the decimal representation of s, followed - by the lowercase character 'e', followed by a plus - sign '+' or minus sign '' according to whether n1 is - positive or negative, followed by the decimal - representation of the integer abs(n1) (with no - leading zeros). + 1. if m is NaN, return the string "NaN" + 2. if m is +0 or -0, return the string "0" + 3. if m is less than zero, return the string + concatenation of the string "-" and ToString(-m). + 4. If m is Infinity, return the string "Infinity". + 5. Otherwise, let n, k, and s be integers such that + k >= 1, 10k1 <= s < 10k, the number value for s10nk + is m, and k is as small as possible. Note that k is + the number of digits in the decimal representation + of s, that s is not divisible by 10, and that the + least significant digit of s is not necessarily + uniquely determined by these criteria. + 6. If k <= n <= 21, return the string consisting of the + k digits of the decimal representation of s (in order, + with no leading zeroes), followed by n-k occurences + of the character '0'. + 7. If 0 < n <= 21, return the string consisting of the + most significant n digits of the decimal + representation of s, followed by a decimal point + '.', followed by the remaining kn digits of the + decimal representation of s. + 8. If 6 < n <= 0, return the string consisting of the + character '0', followed by a decimal point '.', + followed by n occurences of the character '0', + followed by the k digits of the decimal + representation of s. + 9. Otherwise, if k = 1, return the string consisting + of the single digit of s, followed by lowercase + character 'e', followed by a plus sign '+' or minus + sign '' according to whether n1 is positive or + negative, followed by the decimal representation + of the integer abs(n1) (with no leading zeros). + 10. Return the string consisting of the most significant + digit of the decimal representation of s, followed + by a decimal point '.', followed by the remaining k1 + digits of the decimal representation of s, followed + by the lowercase character 'e', followed by a plus + sign '+' or minus sign '' according to whether n1 is + positive or negative, followed by the decimal + representation of the integer abs(n1) (with no + leading zeros). - Note that if x is any number value other than 0, then - ToNumber(ToString(x)) is exactly the same number value as x. + Note that if x is any number value other than 0, then + ToNumber(ToString(x)) is exactly the same number value as x. - As noted, the least significant digit of s is not always - uniquely determined by the requirements listed in step 5. - The following specification for step 5 was considered, but - not adopted: + As noted, the least significant digit of s is not always + uniquely determined by the requirements listed in step 5. + The following specification for step 5 was considered, but + not adopted: - Author: christine@netscape.com - Date: 10 july 1997 + Author: christine@netscape.com + Date: 10 july 1997 */ - var SECTION = "9.8.1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "9.8.1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " ToString applied to the Number type"); - test(); +writeHeaderToLog( SECTION + " ToString applied to the Number type"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "Number.NaN", "NaN", Number.NaN + "" ); +new TestCase( SECTION, "0", "0", 0 + "" ); +new TestCase( SECTION, "-0", "0", -0 + "" ); +new TestCase( SECTION, "Number.POSITIVE_INFINITY", "Infinity", Number.POSITIVE_INFINITY + "" ); +new TestCase( SECTION, "Number.NEGATIVE_INFINITY", "-Infinity", Number.NEGATIVE_INFINITY + "" ); +new TestCase( SECTION, "-1", "-1", -1 + "" ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +// cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 - array[item++] = new TestCase( SECTION, "Number.NaN", "NaN", Number.NaN + "" ); - array[item++] = new TestCase( SECTION, "0", "0", 0 + "" ); - array[item++] = new TestCase( SECTION, "-0", "0", -0 + "" ); - array[item++] = new TestCase( SECTION, "Number.POSITIVE_INFINITY", "Infinity", Number.POSITIVE_INFINITY + "" ); - array[item++] = new TestCase( SECTION, "Number.NEGATIVE_INFINITY", "-Infinity", Number.NEGATIVE_INFINITY + "" ); - array[item++] = new TestCase( SECTION, "-1", "-1", -1 + "" ); +new TestCase( SECTION, "1", "1", 1 + "" ); +new TestCase( SECTION, "10", "10", 10 + "" ); +new TestCase( SECTION, "100", "100", 100 + "" ); +new TestCase( SECTION, "1000", "1000", 1000 + "" ); +new TestCase( SECTION, "10000", "10000", 10000 + "" ); +new TestCase( SECTION, "10000000000", "10000000000", 10000000000 + "" ); +new TestCase( SECTION, "10000000000000000000", "10000000000000000000", 10000000000000000000 + "" ); +new TestCase( SECTION, "100000000000000000000","100000000000000000000",100000000000000000000 + "" ); - // cases in step 6: integers 1e21 > x >= 1 or -1 >= x > -1e21 +new TestCase( SECTION, "12345", "12345", 12345 + "" ); +new TestCase( SECTION, "1234567890", "1234567890", 1234567890 + "" ); - array[item++] = new TestCase( SECTION, "1", "1", 1 + "" ); - array[item++] = new TestCase( SECTION, "10", "10", 10 + "" ); - array[item++] = new TestCase( SECTION, "100", "100", 100 + "" ); - array[item++] = new TestCase( SECTION, "1000", "1000", 1000 + "" ); - array[item++] = new TestCase( SECTION, "10000", "10000", 10000 + "" ); - array[item++] = new TestCase( SECTION, "10000000000", "10000000000", 10000000000 + "" ); - array[item++] = new TestCase( SECTION, "10000000000000000000", "10000000000000000000", 10000000000000000000 + "" ); - array[item++] = new TestCase( SECTION, "100000000000000000000","100000000000000000000",100000000000000000000 + "" ); +new TestCase( SECTION, "-1", "-1", -1 + "" ); +new TestCase( SECTION, "-10", "-10", -10 + "" ); +new TestCase( SECTION, "-100", "-100", -100 + "" ); +new TestCase( SECTION, "-1000", "-1000", -1000 + "" ); +new TestCase( SECTION, "-1000000000", "-1000000000", -1000000000 + "" ); +new TestCase( SECTION, "-1000000000000000", "-1000000000000000", -1000000000000000 + "" ); +new TestCase( SECTION, "-100000000000000000000", "-100000000000000000000", -100000000000000000000 + "" ); +new TestCase( SECTION, "-1000000000000000000000", "-1e+21", -1000000000000000000000 + "" ); - array[item++] = new TestCase( SECTION, "12345", "12345", 12345 + "" ); - array[item++] = new TestCase( SECTION, "1234567890", "1234567890", 1234567890 + "" ); +new TestCase( SECTION, "-12345", "-12345", -12345 + "" ); +new TestCase( SECTION, "-1234567890", "-1234567890", -1234567890 + "" ); - array[item++] = new TestCase( SECTION, "-1", "-1", -1 + "" ); - array[item++] = new TestCase( SECTION, "-10", "-10", -10 + "" ); - array[item++] = new TestCase( SECTION, "-100", "-100", -100 + "" ); - array[item++] = new TestCase( SECTION, "-1000", "-1000", -1000 + "" ); - array[item++] = new TestCase( SECTION, "-1000000000", "-1000000000", -1000000000 + "" ); - array[item++] = new TestCase( SECTION, "-1000000000000000", "-1000000000000000", -1000000000000000 + "" ); - array[item++] = new TestCase( SECTION, "-100000000000000000000", "-100000000000000000000", -100000000000000000000 + "" ); - array[item++] = new TestCase( SECTION, "-1000000000000000000000", "-1e+21", -1000000000000000000000 + "" ); +// cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, +new TestCase( SECTION, "1.0000001", "1.0000001", 1.0000001 + "" ); - array[item++] = new TestCase( SECTION, "-12345", "-12345", -12345 + "" ); - array[item++] = new TestCase( SECTION, "-1234567890", "-1234567890", -1234567890 + "" ); +// cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 - // cases in step 7: numbers with a fractional component, 1e21> x >1 or -1 > x > -1e21, - array[item++] = new TestCase( SECTION, "1.0000001", "1.0000001", 1.0000001 + "" ); +// cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 - // cases in step 8: fractions between 1 > x > -1, exclusive of 0 and -0 +new TestCase( SECTION, "1000000000000000000000", "1e+21", 1000000000000000000000 + "" ); +new TestCase( SECTION, "10000000000000000000000", "1e+22", 10000000000000000000000 + "" ); - // cases in step 9: numbers with 1 significant digit >= 1e+21 or <= 1e-6 +// cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 - array[item++] = new TestCase( SECTION, "1000000000000000000000", "1e+21", 1000000000000000000000 + "" ); - array[item++] = new TestCase( SECTION, "10000000000000000000000", "1e+22", 10000000000000000000000 + "" ); - - // cases in step 10: numbers with more than 1 significant digit >= 1e+21 or <= 1e-6 - - array[item++] = new TestCase( SECTION, "1.2345", "1.2345", String( 1.2345)); - array[item++] = new TestCase( SECTION, "1.234567890", "1.23456789", String( 1.234567890 )); +new TestCase( SECTION, "1.2345", "1.2345", String( 1.2345)); +new TestCase( SECTION, "1.234567890", "1.23456789", String( 1.234567890 )); - array[item++] = new TestCase( SECTION, ".12345", "0.12345", String(.12345 ) ); - array[item++] = new TestCase( SECTION, ".012345", "0.012345", String(.012345) ); - array[item++] = new TestCase( SECTION, ".0012345", "0.0012345", String(.0012345) ); - array[item++] = new TestCase( SECTION, ".00012345", "0.00012345", String(.00012345) ); - array[item++] = new TestCase( SECTION, ".000012345", "0.000012345", String(.000012345) ); - array[item++] = new TestCase( SECTION, ".0000012345", "0.0000012345", String(.0000012345) ); - array[item++] = new TestCase( SECTION, ".00000012345", "1.2345e-7", String(.00000012345)); +new TestCase( SECTION, ".12345", "0.12345", String(.12345 ) ); +new TestCase( SECTION, ".012345", "0.012345", String(.012345) ); +new TestCase( SECTION, ".0012345", "0.0012345", String(.0012345) ); +new TestCase( SECTION, ".00012345", "0.00012345", String(.00012345) ); +new TestCase( SECTION, ".000012345", "0.000012345", String(.000012345) ); +new TestCase( SECTION, ".0000012345", "0.0000012345", String(.0000012345) ); +new TestCase( SECTION, ".00000012345", "1.2345e-7", String(.00000012345)); + +new TestCase( SECTION, "-1e21", "-1e+21", String(-1e21) ); + +test(); - array[item++] = new TestCase( SECTION, "-1e21", "-1e+21", String(-1e21) ); - return ( array ); -} diff --git a/mozilla/js/tests/ecma/TypeConversion/9.9-1.js b/mozilla/js/tests/ecma/TypeConversion/9.9-1.js index 1332c6fb9d5..6c3711ebe3a 100644 --- a/mozilla/js/tests/ecma/TypeConversion/9.9-1.js +++ b/mozilla/js/tests/ecma/TypeConversion/9.9-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,125 +35,98 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: 9.9-1.js - ECMA Section: 9.9 Type Conversion: ToObject - Description: - undefined generate a runtime error - null generate a runtime error - boolean create a new Boolean object whose default - value is the value of the boolean. - number Create a new Number object whose default - value is the value of the number. - string Create a new String object whose default - value is the value of the string. - object Return the input argument (no conversion). - Author: christine@netscape.com - Date: 17 july 1997 +/** + File Name: 9.9-1.js + ECMA Section: 9.9 Type Conversion: ToObject + Description: + + undefined generate a runtime error + null generate a runtime error + boolean create a new Boolean object whose default + value is the value of the boolean. + number Create a new Number object whose default + value is the value of the number. + string Create a new String object whose default + value is the value of the string. + object Return the input argument (no conversion). + Author: christine@netscape.com + Date: 17 july 1997 */ - var VERSION = "ECMA_1"; - startTest(); - var SECTION = "9.9-1"; +var VERSION = "ECMA_1"; +startTest(); +var SECTION = "9.9-1"; - writeHeaderToLog( SECTION + " Type Conversion: ToObject" ); - var tc= 0; - var testcases = getTestCases(); +writeHeaderToLog( SECTION + " Type Conversion: ToObject" ); -// all tests must call a function that returns an array of TestCase objects. - test(); +new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); +new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); +new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); +new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); +new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(true).valueOf()", true, (Object(true)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(true)", "object", typeof Object(true) ); - array[item++] = new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); +new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); +new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); +new TestCase( SECTION, "(Object(0)).__proto__", Number.prototype, (Object(0)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(false).valueOf()", false, (Object(false)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(false)", "object", typeof Object(false) ); - array[item++] = new TestCase( SECTION, "(Object(true)).__proto__", Boolean.prototype, (Object(true)).__proto__ ); +new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); +new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); +new TestCase( SECTION, "(Object(-0)).__proto__", Number.prototype, (Object(-0)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(0).valueOf()", 0, (Object(0)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(0)", "object", typeof Object(0) ); - array[item++] = new TestCase( SECTION, "(Object(0)).__proto__", Number.prototype, (Object(0)).__proto__ ); +new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); +new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); +new TestCase( SECTION, "(Object(1)).__proto__", Number.prototype, (Object(1)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(-0).valueOf()", -0, (Object(-0)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(-0)", "object", typeof Object(-0) ); - array[item++] = new TestCase( SECTION, "(Object(-0)).__proto__", Number.prototype, (Object(-0)).__proto__ ); +new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); +new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); +new TestCase( SECTION, "(Object(-1)).__proto__", Number.prototype, (Object(-1)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(1).valueOf()", 1, (Object(1)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(1)", "object", typeof Object(1) ); - array[item++] = new TestCase( SECTION, "(Object(1)).__proto__", Number.prototype, (Object(1)).__proto__ ); +new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); +new TestCase( SECTION, "(Object(Number.MAX_VALUE)).__proto__", Number.prototype, (Object(Number.MAX_VALUE)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(-1).valueOf()", -1, (Object(-1)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(-1)", "object", typeof Object(-1) ); - array[item++] = new TestCase( SECTION, "(Object(-1)).__proto__", Number.prototype, (Object(-1)).__proto__ ); +new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); +new TestCase( SECTION, "(Object(Number.MIN_VALUE)).__proto__", Number.prototype, (Object(Number.MIN_VALUE)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(Number.MAX_VALUE).valueOf()", 1.7976931348623157e308, (Object(Number.MAX_VALUE)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.MAX_VALUE)", "object", typeof Object(Number.MAX_VALUE) ); - array[item++] = new TestCase( SECTION, "(Object(Number.MAX_VALUE)).__proto__", Number.prototype, (Object(Number.MAX_VALUE)).__proto__ ); +new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); +new TestCase( SECTION, "(Object(Number.POSITIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.POSITIVE_INFINITY)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(Number.MIN_VALUE).valueOf()", 5e-324, (Object(Number.MIN_VALUE)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.MIN_VALUE)", "object", typeof Object(Number.MIN_VALUE) ); - array[item++] = new TestCase( SECTION, "(Object(Number.MIN_VALUE)).__proto__", Number.prototype, (Object(Number.MIN_VALUE)).__proto__ ); +new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); +new TestCase( SECTION, "(Object(Number.NEGATIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.NEGATIVE_INFINITY)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(Number.POSITIVE_INFINITY).valueOf()", Number.POSITIVE_INFINITY, (Object(Number.POSITIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.POSITIVE_INFINITY)", "object", typeof Object(Number.POSITIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "(Object(Number.POSITIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.POSITIVE_INFINITY)).__proto__ ); +new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); +new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); +new TestCase( SECTION, "(Object(Number.NaN)).__proto__", Number.prototype, (Object(Number.NaN)).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(Number.NEGATIVE_INFINITY).valueOf()", Number.NEGATIVE_INFINITY, (Object(Number.NEGATIVE_INFINITY)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.NEGATIVE_INFINITY)", "object", typeof Object(Number.NEGATIVE_INFINITY) ); - array[item++] = new TestCase( SECTION, "(Object(Number.NEGATIVE_INFINITY)).__proto__", Number.prototype, (Object(Number.NEGATIVE_INFINITY)).__proto__ ); +new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); +new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); +new TestCase( SECTION, "(Object('a string')).__proto__", String.prototype, (Object("a string")).__proto__ ); - array[item++] = new TestCase( SECTION, "Object(Number.NaN).valueOf()", Number.NaN, (Object(Number.NaN)).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object(Number.NaN)", "object", typeof Object(Number.NaN) ); - array[item++] = new TestCase( SECTION, "(Object(Number.NaN)).__proto__", Number.prototype, (Object(Number.NaN)).__proto__ ); +new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); +new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); +new TestCase( SECTION, "(Object('')).__proto__", String.prototype, (Object("")).__proto__ ); - array[item++] = new TestCase( SECTION, "Object('a string').valueOf()", "a string", (Object("a string")).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object('a string')", "object", typeof (Object("a string")) ); - array[item++] = new TestCase( SECTION, "(Object('a string')).__proto__", String.prototype, (Object("a string")).__proto__ ); +new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); +new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); +new TestCase( SECTION, "(Object('\\r\\t\\b\\n\\v\\f')).__proto__", String.prototype, (Object("\\r\\t\\b\\n\\v\\f")).__proto__ ); - array[item++] = new TestCase( SECTION, "Object('').valueOf()", "", (Object("")).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object('')", "object", typeof (Object("")) ); - array[item++] = new TestCase( SECTION, "(Object('')).__proto__", String.prototype, (Object("")).__proto__ ); +new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); +new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); +new TestCase( SECTION, "Object( '\\\'\\\"\\' ).__proto__", String.prototype, (Object("\'\"\\")).__proto__ ); - array[item++] = new TestCase( SECTION, "Object('\\r\\t\\b\\n\\v\\f').valueOf()", "\r\t\b\n\v\f", (Object("\r\t\b\n\v\f")).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object('\\r\\t\\b\\n\\v\\f')", "object", typeof (Object("\\r\\t\\b\\n\\v\\f")) ); - array[item++] = new TestCase( SECTION, "(Object('\\r\\t\\b\\n\\v\\f')).__proto__", String.prototype, (Object("\\r\\t\\b\\n\\v\\f")).__proto__ ); +new TestCase( SECTION, "Object( new MyObject(true) ).valueOf()", true, eval("Object( new MyObject(true) ).valueOf()") ); +new TestCase( SECTION, "typeof Object( new MyObject(true) )", "object", eval("typeof Object( new MyObject(true) )") ); +new TestCase( SECTION, "(Object( new MyObject(true) )).toString()", "[object Object]", eval("(Object( new MyObject(true) )).toString()") ); - array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).valueOf()", "\'\"\\", (Object("\'\"\\")).valueOf() ); - array[item++] = new TestCase( SECTION, "typeof Object( '\\\'\\\"\\' )", "object", typeof Object("\'\"\\") ); - array[item++] = new TestCase( SECTION, "Object( '\\\'\\\"\\' ).__proto__", String.prototype, (Object("\'\"\\")).__proto__ ); +test(); - array[item++] = new TestCase( SECTION, "Object( new MyObject(true) ).valueOf()", true, eval("Object( new MyObject(true) ).valueOf()") ); - array[item++] = new TestCase( SECTION, "typeof Object( new MyObject(true) )", "object", eval("typeof Object( new MyObject(true) )") ); - array[item++] = new TestCase( SECTION, "(Object( new MyObject(true) )).toString()", "[object Object]", eval("(Object( new MyObject(true) )).toString()") ); - - return ( array ); -} - -function test() { - for ( tc = 0; tc < testcases.length; tc++ ) { - - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += - ( testcases[tc].passed ) ? "" : "wrong value "; - - } - stopTest(); - - // all tests must return an array of TestCase objects - return ( testcases ); -} function MyObject( value ) { - this.value = value; - this.valueOf = new Function ( "return this.value" ); -} \ No newline at end of file + this.value = value; + this.valueOf = new Function ( "return this.value" ); +} diff --git a/mozilla/js/tests/ecma/TypeConversion/browser.js b/mozilla/js/tests/ecma/TypeConversion/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/TypeConversion/shell.js b/mozilla/js/tests/ecma/TypeConversion/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Types/8.1.js b/mozilla/js/tests/ecma/Types/8.1.js index ed9c613dadb..0a1b555ca16 100644 --- a/mozilla/js/tests/ecma/Types/8.1.js +++ b/mozilla/js/tests/ecma/Types/8.1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,39 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 8.1.js - ECMA Section: The undefined type - Description: + File Name: 8.1.js + ECMA Section: The undefined type + Description: - The Undefined type has exactly one value, called undefined. Any variable - that has not been assigned a value is of type Undefined. + The Undefined type has exactly one value, called undefined. Any variable + that has not been assigned a value is of type Undefined. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "8.1"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The undefined type"; +var SECTION = "8.1"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The undefined type"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "var x; typeof x", + "undefined", + eval("var x; typeof x") ); - testcases[tc++] = new TestCase( SECTION, - "var x; typeof x", - "undefined", - eval("var x; typeof x") ); +new TestCase( SECTION, + "var x; typeof x == 'undefined", + true, + eval("var x; typeof x == 'undefined'") ); - testcases[tc++] = new TestCase( SECTION, - "var x; typeof x == 'undefined", - true, - eval("var x; typeof x == 'undefined'") ); +new TestCase( SECTION, + "var x; x == void 0", + true, + eval("var x; x == void 0") ); +test(); - testcases[tc++] = new TestCase( SECTION, - "var x; x == void 0", - true, - eval("var x; x == void 0") ); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Types/8.4.js b/mozilla/js/tests/ecma/Types/8.4.js index 3a432ea2f47..151410f27ef 100644 --- a/mozilla/js/tests/ecma/Types/8.4.js +++ b/mozilla/js/tests/ecma/Types/8.4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,107 +35,94 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 8.4.js - ECMA Section: The String type - Description: + File Name: 8.4.js + ECMA Section: The String type + Description: - The String type is the set of all finite ordered sequences of zero or more - Unicode characters. Each character is regarded as occupying a position - within the sequence. These positions are identified by nonnegative - integers. The leftmost character (if any) is at position 0, the next - character (if any) at position 1, and so on. The length of a string is the - number of distinct positions within it. The empty string has length zero - and therefore contains no characters. + The String type is the set of all finite ordered sequences of zero or more + Unicode characters. Each character is regarded as occupying a position + within the sequence. These positions are identified by nonnegative + integers. The leftmost character (if any) is at position 0, the next + character (if any) at position 1, and so on. The length of a string is the + number of distinct positions within it. The empty string has length zero + and therefore contains no characters. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "8.4"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "The String type"; +var SECTION = "8.4"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "The String type"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( SECTION, + "var s = ''; s.length", + 0, + eval("var s = ''; s.length") ); - testcases[tc++] = new TestCase( SECTION, - "var s = ''; s.length", - 0, - eval("var s = ''; s.length") ); - - testcases[tc++] = new TestCase( SECTION, - "var s = ''; s.charAt(0)", - "", - eval("var s = ''; s.charAt(0)") ); +new TestCase( SECTION, + "var s = ''; s.charAt(0)", + "", + eval("var s = ''; s.charAt(0)") ); - for ( var i = 0x0041, TEST_STRING = "", EXPECT_STRING = ""; i < 0x007B; i++ ) { - TEST_STRING += ("\\u"+ DecimalToHexString( i ) ); - EXPECT_STRING += String.fromCharCode(i); - } +for ( var i = 0x0041, TEST_STRING = "", EXPECT_STRING = ""; i < 0x007B; i++ ) { + TEST_STRING += ("\\u"+ DecimalToHexString( i ) ); + EXPECT_STRING += String.fromCharCode(i); +} - testcases[tc++] = new TestCase( SECTION, - "var s = '" + TEST_STRING+ "'; s", - EXPECT_STRING, - eval("var s = '" + TEST_STRING+ "'; s") ); +new TestCase( SECTION, + "var s = '" + TEST_STRING+ "'; s", + EXPECT_STRING, + eval("var s = '" + TEST_STRING+ "'; s") ); - testcases[tc++] = new TestCase( SECTION, - "var s = '" + TEST_STRING+ "'; s.length", - 0x007B-0x0041, - eval("var s = '" + TEST_STRING+ "'; s.length") ); +new TestCase( SECTION, + "var s = '" + TEST_STRING+ "'; s.length", + 0x007B-0x0041, + eval("var s = '" + TEST_STRING+ "'; s.length") ); + +test(); - test(); function DecimalToHexString( n ) { - n = Number( n ); - var h = ""; + n = Number( n ); + var h = ""; - for ( var i = 3; i >= 0; i-- ) { - if ( n >= Math.pow(16, i) ){ - var t = Math.floor( n / Math.pow(16, i)); - n -= t * Math.pow(16, i); - if ( t >= 10 ) { - if ( t == 10 ) { - h += "A"; - } - if ( t == 11 ) { - h += "B"; - } - if ( t == 12 ) { - h += "C"; - } - if ( t == 13 ) { - h += "D"; - } - if ( t == 14 ) { - h += "E"; - } - if ( t == 15 ) { - h += "F"; - } - } else { - h += String( t ); - } - } else { - h += "0"; - } + for ( var i = 3; i >= 0; i-- ) { + if ( n >= Math.pow(16, i) ){ + var t = Math.floor( n / Math.pow(16, i)); + n -= t * Math.pow(16, i); + if ( t >= 10 ) { + if ( t == 10 ) { + h += "A"; + } + if ( t == 11 ) { + h += "B"; + } + if ( t == 12 ) { + h += "C"; + } + if ( t == 13 ) { + h += "D"; + } + if ( t == 14 ) { + h += "E"; + } + if ( t == 15 ) { + h += "F"; + } + } else { + h += String( t ); + } + } else { + h += "0"; } + } - return h; + return h; } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma/Types/8.6.2.1-1.js b/mozilla/js/tests/ecma/Types/8.6.2.1-1.js index 7f1a6d4c233..aef57c59959 100644 --- a/mozilla/js/tests/ecma/Types/8.6.2.1-1.js +++ b/mozilla/js/tests/ecma/Types/8.6.2.1-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,87 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 8.6.2.1-1.js - ECMA Section: 8.6.2.1 Get (Value) - Description: + File Name: 8.6.2.1-1.js + ECMA Section: 8.6.2.1 Get (Value) + Description: - When the [[Get]] method of O is called with property name P, the following - steps are taken: + When the [[Get]] method of O is called with property name P, the following + steps are taken: - 1. If O doesn't have a property with name P, go to step 4. - 2. Get the value of the property. - 3. Return Result(2). - 4. If the [[Prototype]] of O is null, return undefined. - 5. Call the [[Get]] method of [[Prototype]] with property name P. - 6. Return Result(5). + 1. If O doesn't have a property with name P, go to step 4. + 2. Get the value of the property. + 3. Return Result(2). + 4. If the [[Prototype]] of O is null, return undefined. + 5. Call the [[Get]] method of [[Prototype]] with property name P. + 6. Return Result(5). - This tests [[Get]] (Value). + This tests [[Get]] (Value). - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "8.6.2.1-1"; - var VERSION = "ECMA_1"; - startTest(); - var testcases = getTestCases(); +var SECTION = "8.6.2.1-1"; +var VERSION = "ECMA_1"; +startTest(); - writeHeaderToLog( SECTION + " [[Get]] (Value)"); - test(); +writeHeaderToLog( SECTION + " [[Get]] (Value)"); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +new TestCase( SECTION, "var OBJ = new MyValuelessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyValuelessObject(true); OBJ.valueOf()") ); +// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(true); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); +new TestCase( SECTION, "var OBJ = new MyProtolessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyProtolessObject(true); OBJ.valueOf()") ); +new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -function getTestCases() { - var array = new Array(); - var item = 0; +new TestCase( SECTION, "var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); +// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(Number.POSITIVE_INFINITY); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); +new TestCase( SECTION, "var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); +new TestCase( SECTION, "var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyValuelessObject(true); OBJ.valueOf()") ); -// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(true); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyProtolessObject(true); OBJ.valueOf()") ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(true); OBJ.valueOf()", true, eval("var OBJ = new MyObject(true); OBJ.valueOf()") ); +new TestCase( SECTION, "var OBJ = new MyValuelessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyValuelessObject('string'); OBJ.valueOf()") ); +// new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject('string'); OJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); +new TestCase( SECTION, "var OBJ = new MyProtolessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyProtolessObject('string'); OBJ.valueOf()") ); +new TestCase( SECTION, "var OBJ = new MyObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyObject('string'); OBJ.valueOf()") ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyValuelessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); -// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject(Number.POSITIVE_INFINITY); OBJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyProtolessObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()", Number.POSITIVE_INFINITY, eval("var OBJ = new MyObject(Number.POSITIVE_INFINITY); OBJ.valueOf()") ); +test(); - array[item++] = new TestCase( SECTION, "var OBJ = new MyValuelessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyValuelessObject('string'); OBJ.valueOf()") ); -// array[item++] = new TestCase( SECTION, "var OBJ = new MyProtoValuelessObject('string'); OJ + ''", "undefined", eval("var OBJ = new MyProtoValuelessObject(); OBJ + ''") ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyProtolessObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyProtolessObject('string'); OBJ.valueOf()") ); - array[item++] = new TestCase( SECTION, "var OBJ = new MyObject('string'); OBJ.valueOf()", 'string', eval("var OBJ = new MyObject('string'); OBJ.valueOf()") ); - - return ( array ); -} function MyProtoValuelessObject(value) { - this.valueOf = new Function ( "" ); - this.__proto__ = null; + this.valueOf = new Function ( "" ); + this.__proto__ = null; } function MyProtolessObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.__proto__ = null; - this.value = value; + this.valueOf = new Function( "return this.value" ); + this.__proto__ = null; + this.value = value; } function MyValuelessObject(value) { - this.__proto__ = new MyPrototypeObject(value); + this.__proto__ = new MyPrototypeObject(value); } function MyPrototypeObject(value) { - this.valueOf = new Function( "return this.value;" ); - this.toString = new Function( "return (this.value + '');" ); - this.value = value; + this.valueOf = new Function( "return this.value;" ); + this.toString = new Function( "return (this.value + '');" ); + this.value = value; } function MyObject( value ) { - this.valueOf = new Function( "return this.value" ); - this.value = value; -} \ No newline at end of file + this.valueOf = new Function( "return this.value" ); + this.value = value; +} diff --git a/mozilla/js/tests/ecma/Types/browser.js b/mozilla/js/tests/ecma/Types/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/Types/shell.js b/mozilla/js/tests/ecma/Types/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma/browser.js b/mozilla/js/tests/ecma/browser.js index 922fb136e05..0f01407fc48 100644 --- a/mozilla/js/tests/ecma/browser.js +++ b/mozilla/js/tests/ecma/browser.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -49,47 +50,77 @@ * */ -onerror = err; - -function startTest() { - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; -} +var GLOBAL = "[object Window]"; function writeLineToLog( string ) { - document.write( string + "
\n"); + document.write( string + "
\n"); } -function writeHeaderToLog( string ) { - document.write( "

" + string + "

" ); -} -function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } - document.write( "
" ); -} -function writeFormattedResult( expect, actual, string, passed ) { - var s = ""+ string ; - s += "" ; - s += ( passed ) ? "  " + PASSED - : " " + FAILED + expect + ""; - writeLineToLog( s + "" ); - return passed; -} -function err( msg, page, line ) { - writeLineToLog( "Test failed with the message: " + msg ); - testcases[tc].actual = "error"; - testcases[tc].reason = msg; - writeTestCaseResult( testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual + - ": " + testcases[tc].reason ); - stopTest(); - return true; +function writeHeaderToLog( string ) { + document.write( "

" + string + "

" ); +} + +function writeFormattedResult( expect, actual, string, passed ) { + var s = ""+ string ; + s += "" ; + s += ( passed ) ? "  " + PASSED + : " " + FAILED + expect + ""; + writeLineToLog( s + "" ); + return passed; +} + +/* + * The earlier versions of the test code used exceptions + * to terminate the test script in "negative" test cases + * before the failure reporting code could run. In order + * to be able to capture errors for the "negative" case + * where the exception is a sign the test actually passed, + * the err online handler will assume that any error is a + * failure unless gExceptionExpected is true. + */ +window.onerror = err; +var gExceptionExpected = false; + +function err( msg, page, line ) { + var testcase; + + if (typeof(EXPECTED) == "undefined" || EXPECTED != "error") { + /* + * an unexpected exception occured + */ + writeLineToLog( "Test failed with the message: " + msg ); + testcase = new TestCase(SECTION, "unknown", "unknown", "unknown"); + testcase.passed = false; + testcase.reason = "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + return; + } + + if (typeof SECTION == 'undefined') + { + SECTION = 'Unknown'; + } + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + + testcase = new TestCase(SECTION, DESCRIPTION, EXPECTED, "error"); + testcase.reason += "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + stopTest(); +} + +var gVersion = 0; + +function version(v) +{ + if (v) { + gVersion = v; + } + return gVersion; } diff --git a/mozilla/js/tests/ecma/shell.js b/mozilla/js/tests/ecma/shell.js index d2ee1f69920..e997b94e12d 100644 --- a/mozilla/js/tests/ecma/shell.js +++ b/mozilla/js/tests/ecma/shell.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -40,31 +41,30 @@ * then load the test script. */ -var completed = false; -var testcases; -var tc = 0; +var completed = false; +var testcases = new Array(); +var tc = testcases.length; -SECTION = ""; -VERSION = ""; -BUGNUMBER = ""; +var SECTION = ""; +var VERSION = ""; +var BUGNUMBER = ""; /* * constant strings */ -var GLOBAL = "[object global]"; +var GLOBAL = "[object global]"; var PASSED = " PASSED!" var FAILED = " FAILED! expected: "; -var DEBUG = false; +var DEBUG = false; - - -/* wrapper for test cas constructor that doesn't require the SECTION +/* + * wrapper for test case constructor that doesn't require the SECTION * argument. */ function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); + new TestCase( SECTION, description, expect, actual ); } /* @@ -72,19 +72,28 @@ function AddTestCase( description, expect, actual ) { * */ -function TestCase( n, d, e, a ) { - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; - this.bugnumber = BUGNUMBER; +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; - this.passed = getTestCaseResult( this.expect, this.actual ); - if ( DEBUG ) { - writeLineToLog( "added " + this.description ); - } + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } + /* + * testcases are solely maintained in the TestCase + * constructor. tc will _always_ point to one past the + * last testcase. If an exception occurs during the call + * to the constructor, then we are assured that the tc + * index has not been incremented. + */ + + testcases[tc++] = this; } /* @@ -92,88 +101,92 @@ function TestCase( n, d, e, a ) { * */ function startTest() { - if ( version ) { - // JavaScript 1.3 is supposed to be compliant ecma version 1.0 - if ( VERSION == "ECMA_1" ) { - version ( "130" ); - } - if ( VERSION == "JS_1.3" ) { - version ( "130" ); - } - if ( VERSION == "JS_1.2" ) { - version ( "120" ); - } - if ( VERSION == "JS_1.1" ) { - version ( "110" ); - } - // for ecma version 2.0, we will leave the javascript version to - // the default ( for now ). + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); } - - // print out bugnumber - - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + if ( VERSION == "JS_1.3" ) { + version ( "130" ); } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + } - testcases = new Array(); - tc = 0; + // print out bugnumber + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } } - function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + for ( tc=0; tc < testcases.length; tc++ ) { + // temporary hack to work around some unknown issue in 1.7 + try + { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; } - stopTest(); - return ( testcases ); + catch(e) + { + writeLineToLog('test(): empty testcase for tc = ' + tc + ' ' + e); + } + } + stopTest(); + return ( testcases ); } /* * Compare expected result to the actual result and figure out whether * the test case passed. */ -function getTestCaseResult( expect, actual ) { - // because ( NaN == NaN ) always returns false, need to do - // a special compare to see if we got the right result. - if ( actual != actual ) { - if ( typeof actual == "object" ) { - actual = "NaN object"; - } else { - actual = "NaN number"; - } - } - if ( expect != expect ) { - if ( typeof expect == "object" ) { - expect = "NaN object"; - } else { - expect = "NaN number"; - } - } +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } - var passed = ( expect == actual ) ? true : false; + var passed = ( expect == actual ) ? true : false; - // if both objects are numbers - // need to replace w/ IEEE standard for rounding - if ( !passed - && typeof(actual) == "number" - && typeof(expect) == "number" - ) { - if ( Math.abs(actual-expect) < 0.0000001 ) { - passed = true; - } - } + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } - // verify type is the same - if ( typeof(expect) != typeof(actual) ) { - passed = false; - } + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } - return passed; + return passed; } /* @@ -184,21 +197,21 @@ function getTestCaseResult( expect, actual ) { */ function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; } function writeFormattedResult( expect, actual, string, passed ) { - var s = string ; - s += ( passed ) ? PASSED : FAILED + expect; - writeLineToLog( s); - return passed; + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; } -function writeLineToLog( string ) { - print( string ); +function writeLineToLog( string ) { + print( string ); } -function writeHeaderToLog( string ) { - print( string ); +function writeHeaderToLog( string ) { + print( string ); } /* end of print functions */ @@ -208,11 +221,11 @@ function writeHeaderToLog( string ) { * test has completed. */ -function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } } /* @@ -221,29 +234,29 @@ function stopTest() { * */ function getFailedCases() { - for ( var i = 0; i < testcases.length; i++ ) { - if ( ! testcases[i].passed ) { - print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); - } + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + writeLineToLog( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } } } - /* - * Date functions used by tests in Date suite - * - */ -var msPerDay = 86400000; -var HoursPerDay = 24; -var MinutesPerHour = 60; -var SecondsPerMinute = 60; -var msPerSecond = 1000; -var msPerMinute = 60000; // msPerSecond * SecondsPerMinute -var msPerHour = 3600000; // msPerMinute * MinutesPerHour -var TZ_DIFF = getTimeZoneDiff(); // offset of tester's timezone from UTC -var TZ_PST = -8; // offset of Pacific Standard Time from UTC -var PST_DIFF = TZ_DIFF - TZ_PST; // offset of tester's timezone from PST -var TIME_1970 = 0; -var TIME_2000 = 946684800000; -var TIME_1900 = -2208988800000; +/* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour +var TZ_DIFF = getTimeZoneDiff(); // offset of tester's timezone from UTC +var TZ_PST = -8; // offset of Pacific Standard Time from UTC +var PST_DIFF = TZ_DIFF - TZ_PST; // offset of tester's timezone from PST +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; /* @@ -251,7 +264,7 @@ var TIME_1900 = -2208988800000; * But that was only valid for testers in the Pacific Standard Time Zone! * We calculate the proper number dynamically for any tester. We just * have to be careful not to use a date subject to Daylight Savings Time... -*/ + */ function getTimeZoneDiff() { return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; @@ -279,7 +292,7 @@ function adjustResultArray(ResultArray, msMode) * like dt.getHours() etc. No correction is necessary for dt.getUTCHours() etc. * * In the second case, it is exactly the other way around - - */ + */ if (msMode) { // The hard-coded UTC milliseconds from Time 0 derives from a UTC date. @@ -310,382 +323,383 @@ function adjustResultArray(ResultArray, msMode) } -function Day( t ) { - return ( Math.floor(t/msPerDay ) ); +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); } function DaysInYear( y ) { - if ( y % 4 != 0 ) { - return 365; - } - if ( (y % 4 == 0) && (y % 100 != 0) ) { - return 366; - } - if ( (y % 100 == 0) && (y % 400 != 0) ) { - return 365; - } - if ( (y % 400 == 0) ){ - return 366; - } else { - return "ERROR: DaysInYear(" + y + ") case not covered"; - } + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } } function TimeInYear( y ) { - return ( DaysInYear(y) * msPerDay ); + return ( DaysInYear(y) * msPerDay ); } -function DayNumber( t ) { - return ( Math.floor( t / msPerDay ) ); +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); } -function TimeWithinDay( t ) { - if ( t < 0 ) { - return ( (t % msPerDay) + msPerDay ); - } else { - return ( t % msPerDay ); - } +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } } function YearNumber( t ) { } function TimeFromYear( y ) { - return ( msPerDay * DayFromYear(y) ); + return ( msPerDay * DayFromYear(y) ); } -function DayFromYear( y ) { - return ( 365*(y-1970) + - Math.floor((y-1969)/4) - - Math.floor((y-1901)/100) + - Math.floor((y-1601)/400) ); +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); } function InLeapYear( t ) { - if ( DaysInYear(YearFromTime(t)) == 365 ) { - return 0; - } - if ( DaysInYear(YearFromTime(t)) == 366 ) { - return 1; - } else { - return "ERROR: InLeapYear("+ t + ") case not covered"; - } + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+ t + ") case not covered"; + } } function YearFromTime( t ) { - t = Number( t ); - var sign = ( t < 0 ) ? -1 : 1; - var year = ( sign < 0 ) ? 1969 : 1970; - for ( var timeToTimeZero = t; ; ) { - // subtract the current year's time from the time that's left. - timeToTimeZero -= sign * TimeInYear(year) + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) - // if there's less than the current year's worth of time left, then break. - if ( sign < 0 ) { - if ( sign * timeToTimeZero <= 0 ) { - break; - } else { - year += sign; - } - } else { - if ( sign * timeToTimeZero < 0 ) { - break; - } else { - year += sign; - } - } - } - return ( year ); + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); } -function MonthFromTime( t ) { - // i know i could use switch but i'd rather not until it's part of ECMA - var day = DayWithinYear( t ); - var leap = InLeapYear(t); +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); - if ( (0 <= day) && (day < 31) ) { - return 0; - } - if ( (31 <= day) && (day < (59+leap)) ) { - return 1; - } - if ( ((59+leap) <= day) && (day < (90+leap)) ) { - return 2; - } - if ( ((90+leap) <= day) && (day < (120+leap)) ) { - return 3; - } - if ( ((120+leap) <= day) && (day < (151+leap)) ) { - return 4; - } - if ( ((151+leap) <= day) && (day < (181+leap)) ) { - return 5; - } - if ( ((181+leap) <= day) && (day < (212+leap)) ) { - return 6; - } - if ( ((212+leap) <= day) && (day < (243+leap)) ) { - return 7; - } - if ( ((243+leap) <= day) && (day < (273+leap)) ) { - return 8; - } - if ( ((273+leap) <= day) && (day < (304+leap)) ) { - return 9; - } - if ( ((304+leap) <= day) && (day < (334+leap)) ) { - return 10; - } - if ( ((334+leap) <= day) && (day < (365+leap)) ) { - return 11; - } else { - return "ERROR: MonthFromTime("+t+") not known"; - } + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } } -function DayWithinYear( t ) { - return( Day(t) - DayFromYear(YearFromTime(t))); +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); } function DateFromTime( t ) { - var day = DayWithinYear(t); - var month = MonthFromTime(t); + var day = DayWithinYear(t); + var month = MonthFromTime(t); - if ( month == 0 ) { - return ( day + 1 ); - } - if ( month == 1 ) { - return ( day - 30 ); - } - if ( month == 2 ) { - return ( day - 58 - InLeapYear(t) ); - } - if ( month == 3 ) { - return ( day - 89 - InLeapYear(t)); - } - if ( month == 4 ) { - return ( day - 119 - InLeapYear(t)); - } - if ( month == 5 ) { - return ( day - 150- InLeapYear(t)); - } - if ( month == 6 ) { - return ( day - 180- InLeapYear(t)); - } - if ( month == 7 ) { - return ( day - 211- InLeapYear(t)); - } - if ( month == 8 ) { - return ( day - 242- InLeapYear(t)); - } - if ( month == 9 ) { - return ( day - 272- InLeapYear(t)); - } - if ( month == 10 ) { - return ( day - 303- InLeapYear(t)); - } - if ( month == 11 ) { - return ( day - 333- InLeapYear(t)); - } + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } - return ("ERROR: DateFromTime("+t+") not known" ); + return ("ERROR: DateFromTime("+t+") not known" ); } -function WeekDay( t ) { - var weekday = (Day(t)+4) % 7; - return( weekday < 0 ? 7 + weekday : weekday ); +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); } -// missing daylight savins time adjustment +// missing daylight savings time adjustment function HourFromTime( t ) { - var h = Math.floor( t / msPerHour ) % HoursPerDay; - return ( (h<0) ? HoursPerDay + h : h ); + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); } -function MinFromTime( t ) { - var min = Math.floor( t / msPerMinute ) % MinutesPerHour; - return( ( min < 0 ) ? MinutesPerHour + min : min ); +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); } -function SecFromTime( t ) { - var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; - return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); } function msFromTime( t ) { - var ms = t % msPerSecond; - return ( (ms < 0 ) ? msPerSecond + ms : ms ); + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); } -function LocalTZA() { - return ( TZ_DIFF * msPerHour ); +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); } -function UTC( t ) { - return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); } function DaylightSavingTA( t ) { - t = t - LocalTZA(); + t = t - LocalTZA(); - var dst_start = GetFirstSundayInApril(t) + 2*msPerHour; - var dst_end = GetLastSundayInOctober(t)+ 2*msPerHour; + var dst_start = GetFirstSundayInApril(t) + 2*msPerHour; + var dst_end = GetLastSundayInOctober(t)+ 2*msPerHour; - if ( t >= dst_start && t < dst_end ) { - return msPerHour; - } else { - return 0; - } + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } - // Daylight Savings Time starts on the first Sunday in April at 2:00AM in - // PST. Other time zones will need to override this function. + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. - print( new Date( UTC(dst_start + LocalTZA())) ); + writeLineToLog( new Date( UTC(dst_start + LocalTZA())) ); - return UTC(dst_start + LocalTZA()); + return UTC(dst_start + LocalTZA()); } -function GetFirstSundayInApril( t ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); - var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + - TimeInMonth(2,leap); + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); - for ( var first_sunday = april; WeekDay(first_sunday) > 0; - first_sunday += msPerDay ) - { - ; - } + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } - return first_sunday; + return first_sunday; } function GetLastSundayInOctober( t ) { - var year = YearFromTime(t); - var leap = InLeapYear(t); + var year = YearFromTime(t); + var leap = InLeapYear(t); - for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { - oct += TimeInMonth(m, leap); - } - for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; - last_sunday -= msPerDay ) - { - ; - } - return last_sunday; + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; } -function LocalTime( t ) { - return ( t + LocalTZA() + DaylightSavingTA(t) ); +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); } -function MakeTime( hour, min, sec, ms ) { - if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { - return Number.NaN; - } +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } - hour = ToInteger(hour); - min = ToInteger( min); - sec = ToInteger( sec); - ms = ToInteger( ms ); + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); - return( (hour*msPerHour) + (min*msPerMinute) + - (sec*msPerSecond) + ms ); + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); } -function MakeDay( year, month, date ) { - if ( isNaN(year) || isNaN(month) || isNaN(date) ) { - return Number.NaN; - } - year = ToInteger(year); - month = ToInteger(month); - date = ToInteger(date ); +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); - var sign = ( year < 1970 ) ? -1 : 1; - var t = ( year < 1970 ) ? 1 : 0; - var y = ( year < 1970 ) ? 1969 : 1970; + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; - var result5 = year + Math.floor( month/12 ); - var result6 = month % 12; + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; - if ( year < 1970 ) { - for ( y = 1969; y >= year; y += sign ) { - t += sign * TimeInYear(y); - } - } else { - for ( y = 1970 ; y < year; y += sign ) { - t += sign * TimeInYear(y); - } - } + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } - var leap = InLeapYear( t ); + var leap = InLeapYear( t ); - for ( var m = 0; m < month; m++ ) { - t += TimeInMonth( m, leap ); - } + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } - if ( YearFromTime(t) != result5 ) { - return Number.NaN; - } - if ( MonthFromTime(t) != result6 ) { - return Number.NaN; - } - if ( DateFromTime(t) != 1 ) { - return Number.NaN; - } + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } - return ( (Day(t)) + date - 1 ); + return ( (Day(t)) + date - 1 ); } -function TimeInMonth( month, leap ) { - // september april june november - // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 - // aug 7 sep 8 oct 9 nov 10 dec 11 +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 - if ( month == 3 || month == 5 || month == 8 || month == 10 ) { - return ( 30*msPerDay ); - } + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } - // all the rest - if ( month == 0 || month == 2 || month == 4 || month == 6 || - month == 7 || month == 9 || month == 11 ) { - return ( 31*msPerDay ); - } + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } - // save february - return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); } -function MakeDate( day, time ) { - if ( day == Number.POSITIVE_INFINITY || - day == Number.NEGATIVE_INFINITY || - day == Number.NaN ) { - return Number.NaN; - } - if ( time == Number.POSITIVE_INFINITY || - time == Number.POSITIVE_INFINITY || - day == Number.NaN) { - return Number.NaN; - } - return ( day * msPerDay ) + time; +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; } function TimeClip( t ) { - if ( isNaN( t ) ) { - return ( Number.NaN ); - } - if ( Math.abs( t ) > 8.64e15 ) { - return ( Number.NaN ); - } + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } - return ( ToInteger( t ) ); + return ( ToInteger( t ) ); } -function ToInteger( t ) { - t = Number( t ); +function ToInteger( t ) { + t = Number( t ); - if ( isNaN( t ) ){ - return ( Number.NaN ); - } - if ( t == 0 || t == -0 || - t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { - return 0; - } + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } - var sign = ( t < 0 ) ? -1 : 1; + var sign = ( t < 0 ) ? -1 : 1; - return ( sign * Math.floor( Math.abs( t ) ) ); + return ( sign * Math.floor( Math.abs( t ) ) ); } function Enumerate ( o ) { - var p; - for ( p in o ) { - print( p +": " + o[p] ); - } + var p; + for ( p in o ) { + writeLineToLog( p +": " + o[p] ); + } } /* these functions are useful for running tests manually in Rhino */ function GetContext() { - return Packages.com.netscape.javascript.Context.getCurrentContext(); + return Packages.com.netscape.javascript.Context.getCurrentContext(); } function OptLevel( i ) { - i = Number(i); - var cx = GetContext(); - cx.setOptimizationLevel(i); + i = Number(i); + var cx = GetContext(); + cx.setOptimizationLevel(i); } /* end of Rhino functions */ + diff --git a/mozilla/js/tests/ecma/template.js b/mozilla/js/tests/ecma/template.js new file mode 100644 index 00000000000..511bcb4b4af --- /dev/null +++ b/mozilla/js/tests/ecma/template.js @@ -0,0 +1,53 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/** + * File Name: template.js + * Reference: ** replace with bugzilla URL or document reference ** + * Description: ** replace with description of test ** + * Author: ** replace with your e-mail address ** + */ + +var SECTION = ""; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA"; // Version of JavaScript or ECMA +var TITLE = ""; // Provide ECMA section title or a description +var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report + +startTest(); // leave this alone + +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * AddTestCase("** description", + * "** expected value", + * "** actual value"); + */ + +// leave this alone. this executes the test cases and +// displays results. +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/boolean-001.js b/mozilla/js/tests/ecma_2/Exceptions/boolean-001.js index 1645ad456c4..67b7390d2a1 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/boolean-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/boolean-001.js @@ -1,43 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: boolean-001.js - Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js + File Name: boolean-001.js + Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js - The toString function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: june 27, 1997 + Author: christine@netscape.com + Date: june 27, 1997 */ - var SECTION = "boolean-001.js"; - var VERSION = "JS1_4"; - var TITLE = "Boolean.prototype.toString()"; - startTest(); - writeHeaderToLog( SECTION +" "+ TITLE ); +var SECTION = "boolean-001.js"; +var VERSION = "JS1_4"; +var TITLE = "Boolean.prototype.toString()"; +startTest(); +writeHeaderToLog( SECTION +" "+ TITLE ); - var tc = 0; - var testcases = new Array(); +var exception = "No exception thrown"; +var result = "Failed"; - var exception = "No exception thrown"; - var result = "Failed"; +var TO_STRING = Boolean.prototype.toString; - var TO_STRING = Boolean.prototype.toString; +try { + var s = new String("Not a Boolean"); + s.toString = TO_STRING; + s.toString(); +} catch ( e ) { + result = "Passed!"; + exception = e.toString(); +} - try { - var s = new String("Not a Boolean"); - s.toString = TO_STRING; - s.toString(); - } catch ( e ) { - result = "Passed!"; - exception = e.toString(); - } +new TestCase( + SECTION, + "Assigning Boolean.prototype.toString to a String object "+ + "(threw " +exception +")", + "Passed!", + result ); - testcases[tc++] = new TestCase( - SECTION, - "Assigning Boolean.prototype.toString to a String object "+ - "(threw " +exception +")", - "Passed!", - result ); +test(); - test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/boolean-002.js b/mozilla/js/tests/ecma_2/Exceptions/boolean-002.js index be31b99dea4..ca5cea08c12 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/boolean-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/boolean-002.js @@ -1,47 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: boolean-001.js - Description: Corresponds to ecma/Boolean/15.6.4.3-4-n.js + File Name: boolean-001.js + Description: Corresponds to ecma/Boolean/15.6.4.3-4-n.js - 15.6.4.3 Boolean.prototype.valueOf() - Returns this boolean value. + 15.6.4.3 Boolean.prototype.valueOf() + Returns this boolean value. - The valueOf function is not generic; it generates - a runtime error if its this value is not a Boolean - object. Therefore it cannot be transferred to other - kinds of objects for use as a method. + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. - Author: christine@netscape.com - Date: 09 september 1998 + Author: christine@netscape.com + Date: 09 september 1998 */ - var SECTION = "boolean-002.js"; - var VERSION = "JS1_4"; - var TITLE = "Boolean.prototype.valueOf()"; - startTest(); - writeHeaderToLog( SECTION +" "+ TITLE ); +var SECTION = "boolean-002.js"; +var VERSION = "JS1_4"; +var TITLE = "Boolean.prototype.valueOf()"; +startTest(); +writeHeaderToLog( SECTION +" "+ TITLE ); - var tc = 0; - var testcases = new Array(); - var exception = "No exception thrown"; - var result = "Failed"; +var exception = "No exception thrown"; +var result = "Failed"; - var VALUE_OF = Boolean.prototype.valueOf; +var VALUE_OF = Boolean.prototype.valueOf; - try { - var s = new String("Not a Boolean"); - s.valueOf = VALUE_0F; - s.valueOf(); - } catch ( e ) { - result = "Passed!"; - exception = e.toString(); - } +try { + var s = new String("Not a Boolean"); + s.valueOf = VALUE_0F; + s.valueOf(); +} catch ( e ) { + result = "Passed!"; + exception = e.toString(); +} - testcases[tc++] = new TestCase( - SECTION, - "Assigning Boolean.prototype.valueOf to a String object "+ - "(threw " +exception +")", - "Passed!", - result ); +new TestCase( + SECTION, + "Assigning Boolean.prototype.valueOf to a String object "+ + "(threw " +exception +")", + "Passed!", + result ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/browser.js b/mozilla/js/tests/ecma_2/Exceptions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/Exceptions/date-001.js b/mozilla/js/tests/ecma_2/Exceptions/date-001.js index 60ef3a4af91..a959311661e 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/date-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/date-001.js @@ -1,57 +1,55 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: date-001.js - Corresponds To: 15.9.5.2-2.js - ECMA Section: 15.9.5.2 Date.prototype.toString - Description: - This function returns a string value. The contents of the string are - implementation dependent, but are intended to represent the Date in a - convenient, human-readable form in the current time zone. + File Name: date-001.js + Corresponds To: 15.9.5.2-2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. - The toString function is not generic; it generates a runtime error if its - this value is not a Date object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - This verifies that calling toString on an object that is not a string - generates a runtime error. + This verifies that calling toString on an object that is not a string + generates a runtime error. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "date-001"; - var VERSION = "JS1_4"; - var TITLE = "Date.prototype.toString"; +var SECTION = "date-001"; +var VERSION = "JS1_4"; +var TITLE = "Date.prototype.toString"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var OBJ = new MyObject( new Date(0) ); + result = OBJ.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var OBJ = new MyObject( new Date(0) ); - result = OBJ.toString(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "OBJECT = new MyObject( new Date(0)) ; result = OBJ.toString()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "OBJECT = new MyObject( new Date(0)) ; result = OBJ.toString()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyObject( value ) { - this.value = value; - this.valueOf = new Function( "return this.value" ); - this.toString = Date.prototype.toString; - return this; + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = Date.prototype.toString; + return this; } diff --git a/mozilla/js/tests/ecma_2/Exceptions/date-002.js b/mozilla/js/tests/ecma_2/Exceptions/date-002.js index 6fd5a648997..73ebbe82d19 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/date-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/date-002.js @@ -1,51 +1,49 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: date-002.js - Corresponds To: 15.9.5.23-3-n.js - ECMA Section: 15.9.5.23 - Description: Date.prototype.setTime + File Name: date-002.js + Corresponds To: 15.9.5.23-3-n.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime - 1. If the this value is not a Date object, generate a runtime error. - 2. Call ToNumber(time). - 3. Call TimeClip(Result(1)). - 4. Set the [[Value]] property of the this value to Result(2). - 5. Return the value of the [[Value]] property of the this value. + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "date-002"; - var VERSION = "JS1_4"; - var TITLE = "Date.prototype.setTime()"; +var SECTION = "date-002"; +var VERSION = "JS1_4"; +var TITLE = "Date.prototype.setTime()"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var MYDATE = new MyDate(); + result = MYDATE.setTime(0); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var MYDATE = new MyDate(); - result = MYDATE.setTime(0); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "MYDATE = new MyDate(); MYDATE.setTime(0)" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "MYDATE = new MyDate(); MYDATE.setTime(0)" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyDate(value) { - this.value = value; - this.setTime = Date.prototype.setTime; - return this; + this.value = value; + this.setTime = Date.prototype.setTime; + return this; } diff --git a/mozilla/js/tests/ecma_2/Exceptions/date-003.js b/mozilla/js/tests/ecma_2/Exceptions/date-003.js index b675fdd87aa..b7cbfafb32b 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/date-003.js +++ b/mozilla/js/tests/ecma_2/Exceptions/date-003.js @@ -1,53 +1,51 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: date-003.js - Corresponds To 15.9.5.3-1.js - ECMA Section: 15.9.5.3-1 Date.prototype.valueOf - Description: + File Name: date-003.js + Corresponds To 15.9.5.3-1.js + ECMA Section: 15.9.5.3-1 Date.prototype.valueOf + Description: - The valueOf function returns a number, which is this time value. + The valueOf function returns a number, which is this time value. - The valueOf function is not generic; it generates a runtime error if - its this value is not a Date object. Therefore it cannot be transferred - to other kinds of objects for use as a method. + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "date-003"; - var VERSION = "JS1_4"; - var TITLE = "Date.prototype.valueOf"; +var SECTION = "date-003"; +var VERSION = "JS1_4"; +var TITLE = "Date.prototype.valueOf"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var OBJ = new MyObject( new Date(0) ); + result = OBJ.valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var OBJ = new MyObject( new Date(0) ); - result = OBJ.valueOf(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "OBJ = new MyObject( new Date(0)); OBJ.valueOf()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "OBJ = new MyObject( new Date(0)); OBJ.valueOf()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyObject( value ) { - this.value = value; - this.valueOf = Date.prototype.valueOf; + this.value = value; + this.valueOf = Date.prototype.valueOf; // The following line causes an infinte loop // this.toString = new Function( "return this+\"\";"); - return this; + return this; } diff --git a/mozilla/js/tests/ecma_2/Exceptions/date-004.js b/mozilla/js/tests/ecma_2/Exceptions/date-004.js index fc2e4199be0..f9c4494cc9a 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/date-004.js +++ b/mozilla/js/tests/ecma_2/Exceptions/date-004.js @@ -1,47 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: date-004.js - Corresponds To: 15.9.5.4-2-n.js - ECMA Section: 15.9.5.4-1 Date.prototype.getTime - Description: + File Name: date-004.js + Corresponds To: 15.9.5.4-2-n.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: - 1. If the this value is not an object whose [[Class]] property is "Date", - generate a runtime error. - 2. Return this time value. - Author: christine@netscape.com - Date: 12 november 1997 + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "date-004"; - var VERSION = "JS1_4"; - var TITLE = "Date.prototype.getTime"; +var SECTION = "date-004"; +var VERSION = "JS1_4"; +var TITLE = "Date.prototype.getTime"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var MYDATE = new MyDate(); + result = MYDATE.getTime(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var MYDATE = new MyDate(); - result = MYDATE.getTime(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "MYDATE = new MyDate(); MYDATE.getTime()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "MYDATE = new MyDate(); MYDATE.getTime()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyDate( value ) { - this.value = value; - this.getTime = Date.prototype.getTime; + this.value = value; + this.getTime = Date.prototype.getTime; } diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-001.js b/mozilla/js/tests/ecma_2/Exceptions/exception-001.js index eeeaa86e80f..5278ad8d989 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-001 * ECMA Section: @@ -8,35 +9,32 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-001"; - var VERSION = "js1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: CallError"; +var SECTION = "exception-001"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: CallError"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +Call_1(); - Call_1(); +test(); - test(); +function Call_1() { + result = "failed: no exception thrown"; + exception = null; - function Call_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - Math(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - testcases[tc++] = new TestCase( - SECTION, - "Math() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } - } + try { + Math(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "Math() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-002.js b/mozilla/js/tests/ecma_2/Exceptions/exception-002.js index 680fcbf3d14..820dbe6cb6d 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-002 * ECMA Section: @@ -8,35 +9,32 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-002"; - var VERSION = "js1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: ConstructError"; +var SECTION = "exception-002"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: ConstructError"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +Construct_1(); - Construct_1(); +test(); - test(); +function Construct_1() { + result = "failed: no exception thrown"; + exception = null; - function Construct_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = new Math(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - testcases[tc++] = new TestCase( - SECTION, - "new Math() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } - } + try { + result = new Math(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "new Math() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-003.js b/mozilla/js/tests/ecma_2/Exceptions/exception-003.js index d073fbc14f6..d69bf32cc34 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-003.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-003 * ECMA Section: @@ -8,39 +9,36 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-003"; - var VERSION = "js1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: TargetError"; +var SECTION = "exception-003"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: TargetError"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +Target_1(); - Target_1(); +test(); - test(); +function Target_1() { + result = "failed: no exception thrown"; + exception = null; - function Target_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - string = new String("hi"); - string.toString = Boolean.prototype.toString; - string.toString(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - testcases[tc++] = new TestCase( - SECTION, - "string = new String(\"hi\");"+ - "string.toString = Boolean.prototype.toString" + - "string.toString() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } - } + try { + string = new String("hi"); + string.toString = Boolean.prototype.toString; + string.toString(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "string = new String(\"hi\");"+ + "string.toString = Boolean.prototype.toString" + + "string.toString() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-004.js b/mozilla/js/tests/ecma_2/Exceptions/exception-004.js index 1fde9595f43..10354252dcd 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-004.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-004.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-004 * ECMA Section: @@ -8,35 +9,32 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-004"; - var VERSION = "js1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; +var SECTION = "exception-004"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +ToObject_1(); - ToObject_1(); +test(); - test(); +function ToObject_1() { + result = "failed: no exception thrown"; + exception = null; - function ToObject_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = foo["bar"]; - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - testcases[tc++] = new TestCase( - SECTION, - "foo[\"bar\"] [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } - } + try { + result = foo["bar"]; + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "foo[\"bar\"] [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-005.js b/mozilla/js/tests/ecma_2/Exceptions/exception-005.js index 2fbb9846148..d9944b2074f 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-005.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-005.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-005 * ECMA Section: @@ -8,35 +9,32 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-005"; - var VERSION = "js1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; +var SECTION = "exception-005"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +ToObject_1(); - ToObject_1(); +test(); - test(); +function ToObject_1() { + result = "failed: no exception thrown"; + exception = null; - function ToObject_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = foo["bar"]; - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - testcases[tc++] = new TestCase( - SECTION, - "foo[\"bar\"] [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } - } + try { + result = foo["bar"]; + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "foo[\"bar\"] [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-006.js b/mozilla/js/tests/ecma_2/Exceptions/exception-006.js index 583e976ba65..a3ddaabec63 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-006.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-006.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-006 * ECMA Section: @@ -8,46 +9,43 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-006"; - var VERSION = "js1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; +var SECTION = "exception-006"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +ToPrimitive_1(); - ToPrimitive_1(); - - test(); +test(); - /** - * Getting the [[DefaultValue]] of any instances of MyObject - * should result in a runtime error in ToPrimitive. - */ +/** + * Getting the [[DefaultValue]] of any instances of MyObject + * should result in a runtime error in ToPrimitive. + */ - function MyObject() { - this.toString = void 0; - this.valueOf = void 0; - } +function MyObject() { + this.toString = void 0; + this.valueOf = void 0; +} - function ToPrimitive_1() { - result = "failed: no exception thrown"; - exception = null; +function ToPrimitive_1() { + result = "failed: no exception thrown"; + exception = null; - try { - result = new MyObject() + new MyObject(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - testcases[tc++] = new TestCase( - SECTION, - "new MyObject() + new MyObject() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } - } + try { + result = new MyObject() + new MyObject(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "new MyObject() + new MyObject() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-007.js b/mozilla/js/tests/ecma_2/Exceptions/exception-007.js index e26a40ecae5..b0476a23d83 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-007.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-007.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-007 * ECMA Section: @@ -8,47 +9,44 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-007"; - var VERSION = "js1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; - var BUGNUMBER="318250"; +var SECTION = "exception-007"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; +var BUGNUMBER="318250"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DefaultValue_1(); - DefaultValue_1(); - - test(); +test(); - /** - * Getting the [[DefaultValue]] of any instances of MyObject - * should result in a runtime error in ToPrimitive. - */ +/** + * Getting the [[DefaultValue]] of any instances of MyObject + * should result in a runtime error in ToPrimitive. + */ - function MyObject() { - this.toString = void 0; - this.valueOf = new Object(); - } +function MyObject() { + this.toString = void 0; + this.valueOf = new Object(); +} - function DefaultValue_1() { - result = "failed: no exception thrown"; - exception = null; +function DefaultValue_1() { + result = "failed: no exception thrown"; + exception = null; - try { - result = new MyObject() + new MyObject(); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - testcases[tc++] = new TestCase( - SECTION, - "new MyObject() + new MyObject() [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } - } + try { + result = new MyObject() + new MyObject(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "new MyObject() + new MyObject() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-008.js b/mozilla/js/tests/ecma_2/Exceptions/exception-008.js index 797f12566b2..5125738575b 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-008.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-008.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-008 * ECMA Section: @@ -8,34 +9,31 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-008"; - var VERSION = "js1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; +var SECTION = "exception-008"; +var VERSION = "js1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +Syntax_1(); - Syntax_1(); +test(); - test(); +function Syntax_1() { + result = "failed: no exception thrown"; + exception = null; - function Syntax_1() { - result = "failed: no exception thrown"; - exception = null; - - try { - result = eval("continue;"); - } catch ( e ) { - result = "passed: threw exception", - exception = e.toString(); - } finally { - testcases[tc++] = new TestCase( - SECTION, - "eval(\"continue\") [ exception is " + exception +" ]", - "passed: threw exception", - result ); - } - } + try { + result = eval("continue;"); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + new TestCase( + SECTION, + "eval(\"continue\") [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-009.js b/mozilla/js/tests/ecma_2/Exceptions/exception-009.js index b153532e55b..9591a05edaf 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-009.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-009.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: exception-009 * ECMA Section: @@ -10,41 +11,38 @@ * Author: christine@netscape.com * Date: 31 August 1998 */ - var SECTION = "exception-009"; - var VERSION = "JS1_4"; - var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; - var BUGNUMBER= "312964"; +var SECTION = "exception-009"; +var VERSION = "JS1_4"; +var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; +var BUGNUMBER= "312964"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +try { + expect = "passed: no exception thrown"; + result = expect; + Nested_1(); +} catch ( e ) { + result = "failed: threw " + e; +} finally { + new TestCase( + SECTION, + "nested try", + expect, + result ); +} + +test(); + +function Nested_1() { + try { try { - expect = "passed: no exception thrown"; - result = expect; - Nested_1(); - } catch ( e ) { - result = "failed: threw " + e; + } catch (a) { } finally { - testcases[tc++] = new TestCase( - SECTION, - "nested try", - expect, - result ); - } - - - test(); - - function Nested_1() { - try { - try { - } catch (a) { - } finally { - } - } catch (b) { - } finally { - } } + } catch (b) { + } finally { + } +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-010-n.js b/mozilla/js/tests/ecma_2/Exceptions/exception-010-n.js index fe7cdae8e4a..e3dde58346b 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-010-n.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-010-n.js @@ -38,15 +38,22 @@ * * ***** END LICENSE BLOCK ***** */ +var SECTION = "exception-010"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Don't Crash throwing null"; + +writeHeaderToLog( SECTION + " "+ TITLE); +writeLineToLog("Null throw test."); +writeLineToLog("BUGNUMBER: 21799"); + +DESCRIPTION = "throw null"; +EXPECTED = "error"; + +new TestCase( SECTION, "throw null", "error", eval("throw null" )); + test(); -function test() -{ - print ("Null throw test."); - print ("BUGNUMBER: 21799"); - - throw null; - - print ("FAILED!: Should have exited with uncaught exception."); +writeLineToLog("FAILED!: Should have exited with uncaught exception."); + -} diff --git a/mozilla/js/tests/ecma_2/Exceptions/exception-011-n.js b/mozilla/js/tests/ecma_2/Exceptions/exception-011-n.js index f1fd34635e7..7138427ba95 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/exception-011-n.js +++ b/mozilla/js/tests/ecma_2/Exceptions/exception-011-n.js @@ -38,14 +38,23 @@ * * ***** END LICENSE BLOCK ***** */ +var SECTION = "exception-011"; +var VERSION = "ECMA_2"; +startTest(); +var TITLE = "Don't Crash throwing undefined"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +writeLineToLog("Undefined throw test."); + +DESCRIPTION = "throw undefined"; +EXPECTED = "error"; + +new TestCase( SECTION, "throw undefined", "error", eval("throw (void 0)") ); + test(); -function test() -{ - print ("Undefined throw test."); - - throw (void 0); - - print ("FAILED!: Should have exited with uncaught exception."); +writeLineToLog("FAILED!: Should have exited with uncaught exception."); + + -} diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-001.js b/mozilla/js/tests/ecma_2/Exceptions/expression-001.js index b1baf6f15d7..81872ead52d 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-001.js @@ -1,47 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-001.js - Corresponds to: ecma/Expressions/11.12-2-n.js - ECMA Section: 11.12 - Description: + File Name: expression-001.js + Corresponds to: ecma/Expressions/11.12-2-n.js + ECMA Section: 11.12 + Description: - The grammar for a ConditionalExpression in ECMAScript is a little bit - different from that in C and Java, which each allow the second - subexpression to be an Expression but restrict the third expression to - be a ConditionalExpression. The motivation for this difference in - ECMAScript is to allow an assignment expression to be governed by either - arm of a conditional and to eliminate the confusing and fairly useless - case of a comma expression as the center expression. + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. - Author: christine@netscape.com - Date: 09 september 1998 + Author: christine@netscape.com + Date: 09 september 1998 */ - var SECTION = "expression-001"; - var VERSION = "JS1_4"; - var TITLE = "Conditional operator ( ? : )" - startTest(); - writeHeaderToLog( SECTION + " " + TITLE ); +var SECTION = "expression-001"; +var VERSION = "JS1_4"; +var TITLE = "Conditional operator ( ? : )" +startTest(); +writeHeaderToLog( SECTION + " " + TITLE ); - var tc = 0; - var testcases = new Array(); +// the following expression should be an error in JS. - // the following expression should be an error in JS. +var result = "Failed" +var exception = "No exception was thrown"; - var result = "Failed" - var exception = "No exception was thrown"; +try { + eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\""); +} catch ( e ) { + result = "Passed"; + exception = e.toString(); +} - try { - eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\""); - } catch ( e ) { - result = "Passed"; - exception = e.toString(); - } - - testcases[tc++] = new TestCase( - SECTION, - "comma expression in a conditional statement "+ - "(threw "+ exception +")", - "Passed", - result ); +new TestCase( + SECTION, + "comma expression in a conditional statement "+ + "(threw "+ exception +")", + "Passed", + result ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-002.js b/mozilla/js/tests/ecma_2/Exceptions/expression-002.js index 1a73ebec01d..53799878860 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-002.js @@ -1,57 +1,55 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expressions-002.js - Corresponds to: ecma/Expressions/11.2.1-3-n.js - ECMA Section: 11.2.1 Property Accessors - Description: + File Name: expressions-002.js + Corresponds to: ecma/Expressions/11.2.1-3-n.js + ECMA Section: 11.2.1 Property Accessors + Description: - Try to access properties of an object whose value is undefined. + Try to access properties of an object whose value is undefined. - Author: christine@netscape.com - Date: 09 september 1998 + Author: christine@netscape.com + Date: 09 september 1998 */ - var SECTION = "expressions-002.js"; - var VERSION = "JS1_4"; - var TITLE = "Property Accessors"; - writeHeaderToLog( SECTION + " "+TITLE ); +var SECTION = "expressions-002.js"; +var VERSION = "JS1_4"; +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); - startTest(); +startTest(); - var tc = 0; - var testcases = new Array(); +// go through all Native Function objects, methods, and properties and get their typeof. - // go through all Native Function objects, methods, and properties and get their typeof. +var PROPERTY = new Array(); +var p = 0; - var PROPERTY = new Array(); - var p = 0; +// try to access properties of primitive types - // try to access properties of primitive types +OBJECT = new Property( "undefined", void 0, "undefined", NaN ); - OBJECT = new Property( "undefined", void 0, "undefined", NaN ); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; - - try { - result = OBJECT.value.valueOf(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +try { + result = OBJECT.value.valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - testcases[tc++] = new TestCase( - SECTION, - "Get the value of an object whose value is undefined "+ - "(threw " + exception +")", - expect, - result ); +new TestCase( + SECTION, + "Get the value of an object whose value is undefined "+ + "(threw " + exception +")", + expect, + result ); - test(); +test(); function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.valueOf = value; -} \ No newline at end of file + this.object = object; + this.string = String(value); + this.number = Number(value); + this.valueOf = value; +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-003.js b/mozilla/js/tests/ecma_2/Exceptions/expression-003.js index 30b536912ac..0dc7d7f868e 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-003.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-003.js @@ -1,52 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expressions-003.js - Corresponds to: ecma/Expressions/11.2.1-3-n.js - ECMA Section: 11.2.1 Property Accessors - Description: + File Name: expressions-003.js + Corresponds to: ecma/Expressions/11.2.1-3-n.js + ECMA Section: 11.2.1 Property Accessors + Description: - Try to access properties of an object whose value is undefined. + Try to access properties of an object whose value is undefined. - Author: christine@netscape.com - Date: 09 september 1998 + Author: christine@netscape.com + Date: 09 september 1998 */ - var SECTION = "expressions-003.js"; - var VERSION = "JS1_4"; - var TITLE = "Property Accessors"; - writeHeaderToLog( SECTION + " "+TITLE ); +var SECTION = "expressions-003.js"; +var VERSION = "JS1_4"; +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); - startTest(); +startTest(); - var tc = 0; - var testcases = new Array(); +// try to access properties of primitive types - // try to access properties of primitive types +OBJECT = new Property( "undefined", void 0, "undefined", NaN ); - OBJECT = new Property( "undefined", void 0, "undefined", NaN ); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; - - try { - result = OBJECT.value.toString(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +try { + result = OBJECT.value.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - testcases[tc++] = new TestCase( - SECTION, - "Get the toString value of an object whose value is undefined "+ - "(threw " + exception +")", - expect, - result ); +new TestCase( + SECTION, + "Get the toString value of an object whose value is undefined "+ + "(threw " + exception +")", + expect, + result ); - test(); +test(); function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; -} \ No newline at end of file + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-004.js b/mozilla/js/tests/ecma_2/Exceptions/expression-004.js index 0ce3864b11c..5db826783cb 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-004.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-004.js @@ -1,46 +1,44 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-004.js - Corresponds To: 11.2.1-4-n.js - ECMA Section: 11.2.1 Property Accessors - Description: + File Name: expression-004.js + Corresponds To: 11.2.1-4-n.js + ECMA Section: 11.2.1 Property Accessors + Description: - Author: christine@netscape.com - Date: 09 september 1998 + Author: christine@netscape.com + Date: 09 september 1998 */ - var SECTION = "expression-004"; - var VERSION = "JS1_4"; - var TITLE = "Property Accessors"; - writeHeaderToLog( SECTION + " "+TITLE ); - startTest(); +var SECTION = "expression-004"; +var VERSION = "JS1_4"; +var TITLE = "Property Accessors"; +writeHeaderToLog( SECTION + " "+TITLE ); +startTest(); - var tc = 0; - var testcases = new Array(); +var OBJECT = new Property( "null", null, "null", 0 ); - var OBJECT = new Property( "null", null, "null", 0 ); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = OBJECT.value.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = OBJECT.value.toString(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "Get the toString value of an object whose value is null "+ + "(threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "Get the toString value of an object whose value is null "+ - "(threw " + exception +")", - expect, - result ); - - test(); +test(); function Property( object, value, string, number ) { - this.object = object; - this.string = String(value); - this.number = Number(value); - this.value = value; + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; } diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-005.js b/mozilla/js/tests/ecma_2/Exceptions/expression-005.js index df6914493bc..8d783eac622 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-005.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-005.js @@ -1,38 +1,36 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-005.js - Corresponds To: 11.2.2-10-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: expression-005.js + Corresponds To: 11.2.2-10-n.js + ECMA Section: 11.2.2. The new operator + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-005"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; +var SECTION = "expression-005"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var expect = "Passed"; +var exception = "No exception thrown"; - var result = "Failed"; - var expect = "Passed"; - var exception = "No exception thrown"; +try { + result = new Math(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = new Math(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "result= new Math() (threw " + exception + ")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "result= new Math() (threw " + exception + ")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-006.js b/mozilla/js/tests/ecma_2/Exceptions/expression-006.js index 1bf0798a160..6cdbaefc9be 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-006.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-006.js @@ -1,43 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-006.js - Corresponds to: 11.2.2-1-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: expression-006.js + Corresponds to: 11.2.2-1-n.js + ECMA Section: 11.2.2. The new operator + Description: - http://scopus/bugsplat/show_bug.cgi?id=327765 + http://scopus/bugsplat/show_bug.cgi?id=327765 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-006.js"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; - var BUGNUMBER="327765"; +var SECTION = "expression-006.js"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; +var BUGNUMBER="327765"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var OBJECT = new Object(); + result = new OBJECT(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var OBJECT = new Object(); - result = new OBJECT(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "OBJECT = new Object; result = new OBJECT()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "OBJECT = new Object; result = new OBJECT()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-007.js b/mozilla/js/tests/ecma_2/Exceptions/expression-007.js index 988109b652b..02d199417a3 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-007.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-007.js @@ -1,41 +1,39 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-007.js - Corresponds To: 11.2.2-2-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: expression-007.js + Corresponds To: 11.2.2-2-n.js + ECMA Section: 11.2.2. The new operator + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-007"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; +var SECTION = "expression-007"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + UNDEFINED = void 0; + result = new UNDEFINED(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - UNDEFINED = void 0; - result = new UNDEFINED(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "UNDEFINED = void 0; result = new UNDEFINED()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "UNDEFINED = void 0; result = new UNDEFINED()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-008.js b/mozilla/js/tests/ecma_2/Exceptions/expression-008.js index caa891254c7..cf1385b694e 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-008.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-008.js @@ -1,38 +1,36 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-008 - Corresponds To: 11.2.2-3-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-008 + Corresponds To: 11.2.2-3-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-008"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; +var SECTION = "expression-008"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var NULL = null; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var NULL = null; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = new NULL(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = new NULL(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "NULL = null; result = new NULL()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "NULL = null; result = new NULL()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-009.js b/mozilla/js/tests/ecma_2/Exceptions/expression-009.js index 2aa63b6a6d5..870dcb80857 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-009.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-009.js @@ -1,39 +1,37 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-009 - Corresponds to: ecma/Expressions/11.2.2-4-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-009 + Corresponds to: ecma/Expressions/11.2.2-4-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-009"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; +var SECTION = "expression-009"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var STRING = ""; - var STRING = ""; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = new STRING(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = new STRING(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "STRING = ''; result = new STRING()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "STRING = ''; result = new STRING()" + - " (threw " + exception +")", - expect, - result ); - - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-010.js b/mozilla/js/tests/ecma_2/Exceptions/expression-010.js index bb21aba2626..19da1a601b2 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-010.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-010.js @@ -1,40 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-010.js - Corresponds To: 11.2.2-5-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-010.js + Corresponds To: 11.2.2-5-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-010"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; +var SECTION = "expression-010"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var NUMBER = 0; - var NUMBER = 0; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = new NUMBER(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = new NUMBER(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "NUMBER=0, result = new NUMBER()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "NUMBER=0, result = new NUMBER()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-011.js b/mozilla/js/tests/ecma_2/Exceptions/expression-011.js index 71c601a3b46..bcbcf78077a 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-011.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-011.js @@ -1,40 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-011.js - Corresponds To: ecma/Expressions/11.2.2-6-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-011.js + Corresponds To: ecma/Expressions/11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-011"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; +var SECTION = "expression-011"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var BOOLEAN = true; - var BOOLEAN = true; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var OBJECT = new BOOLEAN(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var OBJECT = new BOOLEAN(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "BOOLEAN = true; result = new BOOLEAN()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "BOOLEAN = true; result = new BOOLEAN()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-012.js b/mozilla/js/tests/ecma_2/Exceptions/expression-012.js index 31eb0996bbd..63b67100615 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-012.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-012.js @@ -1,41 +1,39 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-012.js - Corresponds To: ecma/Expressions/11.2.2-6-n.js - ECMA Section: 11.2.2. The new operator - Description: - http://scopus/bugsplat/show_bug.cgi?id=327765 - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-012.js + Corresponds To: ecma/Expressions/11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + http://scopus/bugsplat/show_bug.cgi?id=327765 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-012"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; - var BUGNUMBER= "327765"; +var SECTION = "expression-012"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; +var BUGNUMBER= "327765"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var STRING = new String("hi"); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var STRING = new String("hi"); - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = new STRING(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = new STRING(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "STRING = new String(\"hi\"); result = new STRING()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "STRING = new String(\"hi\"); result = new STRING()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-013.js b/mozilla/js/tests/ecma_2/Exceptions/expression-013.js index cc75a7747c5..60fedb25272 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-013.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-013.js @@ -1,41 +1,39 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-013.js - Corresponds To: ecma/Expressions/11.2.2-8-n.js - ECMA Section: 11.2.2. The new operator - Description: - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-013.js + Corresponds To: ecma/Expressions/11.2.2-8-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-013"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; - var BUGNUMBER= "327765"; +var SECTION = "expression-013"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; +var BUGNUMBER= "327765"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var NUMBER = new Number(1); - var NUMBER = new Number(1); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = new NUMBER(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = new NUMBER(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "NUMBER = new Number(1); result = new NUMBER()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "NUMBER = new Number(1); result = new NUMBER()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-014.js b/mozilla/js/tests/ecma_2/Exceptions/expression-014.js index 4a09cd140a4..5475cde2978 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-014.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-014.js @@ -1,43 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-014.js - Corresponds To: ecma/Expressions/11.2.2-9-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: expression-014.js + Corresponds To: ecma/Expressions/11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-014.js"; - var VERSION = "ECMA_1"; - var TITLE = "The new operator"; - var BUGNUMBER= "327765"; +var SECTION = "expression-014.js"; +var VERSION = "ECMA_1"; +var TITLE = "The new operator"; +var BUGNUMBER= "327765"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - - var BOOLEAN = new Boolean(); +var BOOLEAN = new Boolean(); - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - try { - result = new BOOLEAN(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +try { + result = new BOOLEAN(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - testcases[tc++] = new TestCase( - SECTION, - "BOOLEAN = new Boolean(); result = new BOOLEAN()" + - " (threw " + exception +")", - expect, - result ); +new TestCase( + SECTION, + "BOOLEAN = new Boolean(); result = new BOOLEAN()" + + " (threw " + exception +")", + expect, + result ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-015.js b/mozilla/js/tests/ecma_2/Exceptions/expression-015.js index 09577fc1b0a..b04d6641177 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-015.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-015.js @@ -1,37 +1,35 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-015.js - Corresponds To: ecma/Expressions/11.2.3-2-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-015.js + Corresponds To: ecma/Expressions/11.2.3-2-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-015"; - var VERSION = "JS1_4"; - var TITLE = "Function Calls"; +var SECTION = "expression-015"; +var VERSION = "JS1_4"; +var TITLE = "Function Calls"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("result = 3.valueOf();"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("result = 3.valueOf();"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "3.valueOf()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "3.valueOf()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-016.js b/mozilla/js/tests/ecma_2/Exceptions/expression-016.js index 4a551106a7e..ccbc987657c 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-016.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-016.js @@ -1,37 +1,35 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-016.js - Corresponds To: ecma/Expressions/11.2.3-3-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-016.js + Corresponds To: ecma/Expressions/11.2.3-3-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-016"; - var VERSION = "JS1_4"; - var TITLE = "Function Calls"; +var SECTION = "expression-016"; +var VERSION = "JS1_4"; +var TITLE = "Function Calls"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = (void 0).valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = (void 0).valueOf(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "(void 0).valueOf()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "(void 0).valueOf()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-017.js b/mozilla/js/tests/ecma_2/Exceptions/expression-017.js index 949cf3f5734..8c73d872564 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-017.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-017.js @@ -1,37 +1,35 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-07.js - Corresponds To: ecma/Expressions/11.2.3-4-n.js - ECMA Section: 11.2.3. Function Calls - Description: - Author: christine@netscape.com - Date: 12 november 1997 + File Name: expression-07.js + Corresponds To: ecma/Expressions/11.2.3-4-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-017"; - var VERSION = "JS1_4"; - var TITLE = "Function Calls"; +var SECTION = "expression-017"; +var VERSION = "JS1_4"; +var TITLE = "Function Calls"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = nullvalueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - result = nullvalueOf(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "null.valueOf()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "null.valueOf()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/expression-019.js b/mozilla/js/tests/ecma_2/Exceptions/expression-019.js index 0ef02cb609e..ae8c7ca27b2 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/expression-019.js +++ b/mozilla/js/tests/ecma_2/Exceptions/expression-019.js @@ -1,41 +1,39 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: expression-019.js - Corresponds To: 11.2.2-7-n.js - ECMA Section: 11.2.2. The new operator - Description: + File Name: expression-019.js + Corresponds To: 11.2.2-7-n.js + ECMA Section: 11.2.2. The new operator + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "expression-019"; - var VERSION = "JS1_4"; - var TITLE = "The new operator"; - var BUGNUMBER= "327765"; +var SECTION = "expression-019"; +var VERSION = "JS1_4"; +var TITLE = "The new operator"; +var BUGNUMBER= "327765"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var STRING = new String("hi"); + result = new STRING(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var STRING = new String("hi"); - result = new STRING(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var STRING = new String(\"hi\"); result = new STRING();" + + " (threw " + exception + ")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var STRING = new String(\"hi\"); result = new STRING();" + - " (threw " + exception + ")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/function-001.js b/mozilla/js/tests/ecma_2/Exceptions/function-001.js index 3cbd19e6e16..f901d18d366 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/function-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/function-001.js @@ -27,9 +27,6 @@ startTest(); writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - var result = "fail"; var exception = "no exception thrown"; @@ -40,7 +37,7 @@ exception = e.toString(); } - testcases[tc++] = new TestCase( + new TestCase( SECTION, "eval(\"function f(){}function g(){}\") (threw "+exception, "pass", @@ -48,17 +45,3 @@ test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma_2/Exceptions/global-001.js b/mozilla/js/tests/ecma_2/Exceptions/global-001.js index 3b1bd98f0df..a512d6aed35 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/global-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/global-001.js @@ -1,43 +1,40 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: global-001 - Corresponds To: ecma/GlobalObject/15.1-1-n.js - ECMA Section: The global object - Description: + File Name: global-001 + Corresponds To: ecma/GlobalObject/15.1-1-n.js + ECMA Section: The global object + Description: - The global object does not have a [[Construct]] property; it is not - possible to use the global object as a constructor with the new operator. + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "global-001"; - var VERSION = "ECMA_1"; - var TITLE = "The Global Object"; +var SECTION = "global-001"; +var VERSION = "ECMA_1"; +var TITLE = "The Global Object"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; +try { + result = new this(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +new TestCase( + SECTION, + "result = new this()" + + " (threw " + exception +")", + expect, + result ); - try { - result = new this(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } - - testcases[tc++] = new TestCase( - SECTION, - "result = new this()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/global-002.js b/mozilla/js/tests/ecma_2/Exceptions/global-002.js index 2453c295b19..efc40b48cfe 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/global-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/global-002.js @@ -1,43 +1,40 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: global-002 - Corresponds To: ecma/GlobalObject/15.1-2-n.js - ECMA Section: The global object - Description: + File Name: global-002 + Corresponds To: ecma/GlobalObject/15.1-2-n.js + ECMA Section: The global object + Description: - The global object does not have a [[Construct]] property; it is not - possible to use the global object as a constructor with the new operator. + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "global-002"; - var VERSION = "JS1_4"; - var TITLE = "The Global Object"; +var SECTION = "global-002"; +var VERSION = "JS1_4"; +var TITLE = "The Global Object"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; +try { + result = this(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +new TestCase( + SECTION, + "result = this()" + + " (threw " + exception +")", + expect, + result ); - try { - result = this(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } - - testcases[tc++] = new TestCase( - SECTION, - "result = this()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-001.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-001.js index 528a57347f9..c21ae5fc0c6 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-001.js @@ -1,49 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-001.js - CorrespondsTo: ecma/LexicalConventions/7.2.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. + File Name: lexical-001.js + CorrespondsTo: ecma/LexicalConventions/7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "lexical-001"; - var VERSION = "JS1_4"; - var TITLE = "Line Terminators"; +var SECTION = "lexical-001"; +var VERSION = "JS1_4"; +var TITLE = "Line Terminators"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = eval("\r\n\expect"); +} catch ( e ) { + exception = e.toString(); +} - try { - result = eval("\r\n\expect"); - } catch ( e ) { - exception = e.toString(); - } +new TestCase( + SECTION, + "OBJECT = new Object; result = new OBJECT()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "OBJECT = new Object; result = new OBJECT()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-002.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-002.js index b1521c2a44d..7a03faa90af 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-002.js @@ -1,49 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-002.js - Corresponds To: ecma/LexicalConventions/7.2-3-n.js - ECMA Section: 7.2 Line Terminators - Description: - readability - - separate tokens - - may occur between any two tokens - - cannot occur within any token, not even a string - - affect the process of automatic semicolon insertion. + File Name: lexical-002.js + Corresponds To: ecma/LexicalConventions/7.2-3-n.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. - white space characters are: - unicode name formal name string representation - \u000A line feed \n - \u000D carriage return \r + white space characters are: + unicode name formal name string representation + \u000A line feed \n + \u000D carriage return \r - this test uses onerror to capture line numbers. because - we use on error, we can only have one test case per file. + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "lexical-002"; - var VERSION = "JS1_4"; - var TITLE = "Line Terminators"; +var SECTION = "lexical-002"; +var VERSION = "JS1_4"; +var TITLE = "Line Terminators"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + result = eval("\r\n\expect"); +} catch ( e ) { + exception = e.toString(); +} - try { - result = eval("\r\n\expect"); - } catch ( e ) { - exception = e.toString(); - } +new TestCase( + SECTION, + "result=eval(\"\r\nexpect\")" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "result=eval(\"\r\nexpect\")" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-003.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-003.js index a622d12bf81..b095dfbf658 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-003.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-003.js @@ -1,41 +1,38 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-003.js - Corresponds To: 7.3-13-n.js - ECMA Section: 7.3 Comments - Description: + File Name: lexical-003.js + Corresponds To: 7.3-13-n.js + ECMA Section: 7.3 Comments + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-003.js"; - var VERSION = "JS1_4"; - var TITLE = "Comments"; +var SECTION = "lexical-003.js"; +var VERSION = "JS1_4"; +var TITLE = "Comments"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; +try { + eval("/*\n/* nested comment */\n*/\n"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +new TestCase( + SECTION, + "/*/*nested comment*/ */" + + " (threw " + exception +")", + expect, + result ); - try { - eval("/*\n/* nested comment */\n*/\n"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } - - testcases[tc++] = new TestCase( - SECTION, - "/*/*nested comment*/ */" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-004.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-004.js index 64758385b2c..9a3d8a729aa 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-004.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-004.js @@ -1,49 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-004.js - Corresponds To: ecma/LexicalExpressions/7.4.1-1-n.js - ECMA Section: 7.4.1 + File Name: lexical-004.js + Corresponds To: ecma/LexicalExpressions/7.4.1-1-n.js + ECMA Section: 7.4.1 - Description: + Description: - Reserved words cannot be used as identifiers. + Reserved words cannot be used as identifiers. - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-004"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-004"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var null = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var null = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var null = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var null = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-005.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-005.js index a9cdd6b12e6..a74f189b724 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-005.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-005.js @@ -1,50 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-005.js - Corresponds To: 7.4.1-2.js - ECMA Section: 7.4.1 + File Name: lexical-005.js + Corresponds To: 7.4.1-2.js + ECMA Section: 7.4.1 - Description: + Description: - Reserved words cannot be used as identifiers. + Reserved words cannot be used as identifiers. - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-005"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-005"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; +try { + eval("true = false;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +new TestCase( + SECTION, + "true = false" + + " (threw " + exception +")", + expect, + result ); - try { - eval("true = false;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } - - testcases[tc++] = new TestCase( - SECTION, - "true = false" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-006.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-006.js index 89c45f3b475..96195e2f442 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-006.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-006.js @@ -1,55 +1,53 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-006.js - Corresponds To: 7.4.2-1.js - ECMA Section: 7.4.2 + File Name: lexical-006.js + Corresponds To: 7.4.2-1.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-006"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-006"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("break = new Object();"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("break = new Object();"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "break = new Object()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "break = new Object()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-007.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-007.js index d34afe4bee6..0e798d390a9 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-007.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-007.js @@ -1,48 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-005.js - Corresponds To: 7.4.1-3-n.js - ECMA Section: 7.4.1 + File Name: lexical-005.js + Corresponds To: 7.4.1-3-n.js + ECMA Section: 7.4.1 - Description: + Description: - Reserved words cannot be used as identifiers. + Reserved words cannot be used as identifiers. - ReservedWord :: - Keyword - FutureReservedWord - NullLiteral - BooleanLiteral + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-005"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-005"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("false = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("false = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "false = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "false = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-008.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-008.js index f819eaee1a6..871c0b0afd3 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-008.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-008.js @@ -1,50 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-008.js - Corresponds To: 7.4.3-1-n.js - ECMA Section: 7.4.3 + File Name: lexical-008.js + Corresponds To: 7.4.3-1-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-008.js"; - var VERSION = "JS1_4"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-008.js"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("case = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("case = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "case = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "case = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-009.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-009.js index 39fc71ab3c0..134500213ea 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-009.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-009.js @@ -1,49 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-009 - Corresponds To: 7.4.3-2-n.js - ECMA Section: 7.4.3 + File Name: lexical-009 + Corresponds To: 7.4.3-2-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-009"; - var VERSION = "ECMA_1"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-009"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - try { - eval("debugger = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +try { + eval("debugger = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - testcases[tc++] = new TestCase( - SECTION, - "debugger = true" + - " (threw " + exception +")", - expect, - result ); +new TestCase( + SECTION, + "debugger = true" + + " (threw " + exception +")", + expect, + result ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-010.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-010.js index 9e9f6648dbb..c2a7fa1882a 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-010.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-010.js @@ -1,48 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-010.js - Corresponds To: 7.4.3-3-n.js - ECMA Section: 7.4.3 + File Name: lexical-010.js + Corresponds To: 7.4.3-3-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-010"; - var VERSION = "ECMA_1"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-010"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("export = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("export = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "export = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "export = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-012.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-012.js index e4579fd95c6..acdffabb5d1 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-012.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-012.js @@ -1,50 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-012.js - Corresponds To: 7.4.3-5-n.js - ECMA Section: 7.4.3 + File Name: lexical-012.js + Corresponds To: 7.4.3-5-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-012"; - var VERSION = "JS1_4"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-012"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("catch = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("catch = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "catch = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "catch = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-013.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-013.js index 699d06a9f9c..ea0f4249726 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-013.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-013.js @@ -1,49 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-013.js - Corresponds To: 7.4.3-6-n.js - ECMA Section: 7.4.3 + File Name: lexical-013.js + Corresponds To: 7.4.3-6-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-013"; - var VERSION = "JS1_4"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-013"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - try { - eval("default = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +try { + eval("default = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - testcases[tc++] = new TestCase( - SECTION, - "default = true" + - " (threw " + exception +")", - expect, - result ); +new TestCase( + SECTION, + "default = true" + + " (threw " + exception +")", + expect, + result ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-015.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-015.js index 7cbcc049f6a..e2b3b6172f5 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-015.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-015.js @@ -1,50 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-015.js - Corresponds To: 7.4.3-8-n.js - ECMA Section: 7.4.3 + File Name: lexical-015.js + Corresponds To: 7.4.3-8-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-015"; - var VERSION = "JS1_4"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-015"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("switch = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("switch = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "switch = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "switch = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-017.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-017.js index 96849b76994..feca34768d4 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-017.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-017.js @@ -1,50 +1,49 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-017.js - Corresponds To: 7.4.3-10-n.js - ECMA Section: 7.4.3 + File Name: lexical-017.js + Corresponds To: 7.4.3-10-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-017"; - var VERSION = "JS1_4"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-017"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - try { - eval("do = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +try { + eval("do = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - testcases[tc++] = new TestCase( - SECTION, - "do = true" + - " (threw " + exception +")", - expect, - result ); +new TestCase( + SECTION, + "do = true" + + " (threw " + exception +")", + expect, + result ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-018.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-018.js index 5d46c5f289e..6a6881eba89 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-018.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-018.js @@ -1,50 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-018 - Corresponds To: 7.4.3-11-n.js - ECMA Section: 7.4.3 + File Name: lexical-018 + Corresponds To: 7.4.3-11-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-018"; - var VERSION = "JS1_4"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-018"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("finally = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("finally = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "finally = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "finally = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-019.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-019.js index 9f01fc0adf3..9fb10223a90 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-019.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-019.js @@ -1,50 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-019.js - Corresponds To: 7.4.3-12-n.js - ECMA Section: 7.4.3 + File Name: lexical-019.js + Corresponds To: 7.4.3-12-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-019"; - var VERSION = "JS1_4"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-019"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("throw = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("throw = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "throw = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "throw = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-020.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-020.js index 362a3d572e5..cd2e508d105 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-020.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-020.js @@ -1,50 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-020.js - Corresponds To 7.4.3-13-n.js - ECMA Section: 7.4.3 + File Name: lexical-020.js + Corresponds To 7.4.3-13-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-020"; - var VERSION = "JS1_4"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-020"; +var VERSION = "JS1_4"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("const = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("const = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "const = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "const = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-022.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-022.js index 54f256a60dd..67f7a6db2ef 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-022.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-022.js @@ -1,50 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-022 - Corresponds To 7.4.3-15-n.js - ECMA Section: 7.4.3 + File Name: lexical-022 + Corresponds To 7.4.3-15-n.js + ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-022.js"; - var VERSION = "ECMA_1"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-022.js"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("import = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("import = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "import = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "import = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-023.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-023.js index 0715a3d3923..ddb015704a0 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-023.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-023.js @@ -1,49 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-023.js - Corresponds To: 7.4.3-16-n.js - ECMA Section: 7.4.3 - Description: - The following words are used as keywords in proposed extensions and are - therefore reserved to allow for the possibility of future adoption of - those extensions. + File Name: lexical-023.js + Corresponds To: 7.4.3-16-n.js + ECMA Section: 7.4.3 + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. - FutureReservedWord :: one of - case debugger export super - catch default extends switch - class do finally throw - const enum import try + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-023.js"; - var VERSION = "ECMA_1"; - var TITLE = "Future Reserved Words"; +var SECTION = "lexical-023.js"; +var VERSION = "ECMA_1"; +var TITLE = "Future Reserved Words"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("try = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("try = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "try = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "try = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-024.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-024.js index d7317914e13..0fb9b5e728f 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-024.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-024.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-024 - Corresponds To: 7.4.2-1-n.js - ECMA Section: 7.4.2 + File Name: lexical-024 + Corresponds To: 7.4.2-1-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-024"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-024"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var break;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var break;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var break" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var break" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-025.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-025.js index 16a44d60e27..883e6f97a36 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-025.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-025.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-025.js - Corresponds To 7.4.2-2-n.js - ECMA Section: 7.4.2 + File Name: lexical-025.js + Corresponds To 7.4.2-2-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-025"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-025"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var for;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var for;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var for" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var for" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-026.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-026.js index 73aea73f0d5..9f7afe44ec4 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-026.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-026.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-026.js - Corresponds To: 7.4.2-3-n.js - ECMA Section: 7.4.2 + File Name: lexical-026.js + Corresponds To: 7.4.2-3-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-026"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-026"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var new;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var new;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var new" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var new" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-027.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-027.js index b8f8593055d..9666bc111cf 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-027.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-027.js @@ -1,58 +1,56 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-027.js - Corresponds To: 7.4.2-4-n.js - ECMA Section: 7.4.2 + File Name: lexical-027.js + Corresponds To: 7.4.2-4-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - var + var - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-027"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-027"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var var;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var var;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var var" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var var" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-028.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-028.js index a985527def1..8dc5104febd 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-028.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-028.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-028.js - Corresponds To: 7.4.2-5-n.js - ECMA Section: 7.4.2 + File Name: lexical-028.js + Corresponds To: 7.4.2-5-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-028"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-028"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var continue=true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var continue=true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var continue=true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var continue=true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-029.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-029.js index 0b38cbeb5e7..886e04308b4 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-029.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-029.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-029.js - Corresponds To: 7.4.2-6.js - ECMA Section: 7.4.2 + File Name: lexical-029.js + Corresponds To: 7.4.2-6.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-029"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-029"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var function = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var function = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var function = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var function = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-030.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-030.js index bc854724f2f..e6f1431a11a 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-030.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-030.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-030.js - Corresponds To: 7.4.2-7-n.js - ECMA Section: 7.4.2 + File Name: lexical-030.js + Corresponds To: 7.4.2-7-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-030"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-030"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var return = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var return = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var return = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var return = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-031.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-031.js index d2251ba854d..a77c0a795b8 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-031.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-031.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-031.js - Corresponds To: 7.4.2-8-n.js - ECMA Section: 7.4.2 + File Name: lexical-031.js + Corresponds To: 7.4.2-8-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-031"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-031"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var return;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var return;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var return" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var return" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-032.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-032.js index 5ac71cbddcf..c6d883ea67f 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-032.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-032.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-032.js - Corresponds To: 7.4.2-9-n.js - ECMA Section: 7.4.2 + File Name: lexical-032.js + Corresponds To: 7.4.2-9-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-032"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-032"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("delete = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("delete = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "delete = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "delete = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-033.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-033.js index 2a357fe0f5b..5e0af78c653 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-033.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-033.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-033.js - Corresponds To: 7.4.2-10.js - ECMA Section: 7.4.2 + File Name: lexical-033.js + Corresponds To: 7.4.2-10.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-033"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-033"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("if = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("if = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "if = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "if = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-034.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-034.js index d6c03a24364..e423a33e4c2 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-034.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-034.js @@ -1,55 +1,53 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: 7.4.2-11-n.js - ECMA Section: 7.4.2 + File Name: 7.4.2-11-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-034"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-034"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("this = true"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("this = true"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "this = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "this = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-035.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-035.js index f5fca592fbf..41ebc85e762 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-035.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-035.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-035.js - Correpsonds To: 7.4.2-12-n.js - ECMA Section: 7.4.2 + File Name: lexical-035.js + Correpsonds To: 7.4.2-12-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-035"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-035"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var while"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var while"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var while" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var while" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-036.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-036.js index 3512c9b721a..c2849480a59 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-036.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-036.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-036.js - Corresponds To: 7.4.2-13-n.js - ECMA Section: 7.4.2 + File Name: lexical-036.js + Corresponds To: 7.4.2-13-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-036"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-036"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("else = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("else = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "else = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "else = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-037.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-037.js index 641c9de4776..8cb9b531148 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-037.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-037.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-037.js - Corresponds To: 7.4.2-14-n.js - ECMA Section: 7.4.2 + File Name: lexical-037.js + Corresponds To: 7.4.2-14-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-028"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-028"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var in;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var in;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var in" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var in" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-038.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-038.js index f44b6b3cf67..b5c322eaef1 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-038.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-038.js @@ -1,56 +1,54 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-038.js - Corresponds To: 7.4.2-15-n.js - ECMA Section: 7.4.2 + File Name: lexical-038.js + Corresponds To: 7.4.2-15-n.js + ECMA Section: 7.4.2 - Description: - The following tokens are ECMAScript keywords and may not be used as - identifiers in ECMAScript programs. + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. - Syntax + Syntax - Keyword :: one of - break for new var - continue function return void - delete if this while - else in typeof with + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with - This test verifies that the keyword cannot be used as an identifier. - Functioinal tests of the keyword may be found in the section corresponding - to the function of the keyword. + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "lexical-038"; - var VERSION = "JS1_4"; - var TITLE = "Keywords"; +var SECTION = "lexical-038"; +var VERSION = "JS1_4"; +var TITLE = "Keywords"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("typeof = true;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("typeof = true;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "typeof = true" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "typeof = true" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-039.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-039.js index e40b21b9a1f..5fb3fe4d284 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-039.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-039.js @@ -1,43 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-039 - Corresponds To: 7.5-2-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: lexical-039 + Corresponds To: 7.5-2-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "lexical-039"; - var VERSION = "JS1_4"; - var TITLE = "Identifiers"; +var SECTION = "lexical-039"; +var VERSION = "JS1_4"; +var TITLE = "Identifiers"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var 0abc;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var 0abc;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var 0abc" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var 0abc" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-040.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-040.js index fb306c1d0ff..6fc4c39b3b4 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-040.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-040.js @@ -1,43 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-040.js - Corresponds To: 7.5-2.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: lexical-040.js + Corresponds To: 7.5-2.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "lexical-040"; - var VERSION = "JS1_4"; - var TITLE = "Identifiers"; +var SECTION = "lexical-040"; +var VERSION = "JS1_4"; +var TITLE = "Identifiers"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var 1abc;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var 1abc;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var 1abc" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var 1abc" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-041.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-041.js index da830f8e220..9fa35b346d9 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-041.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-041.js @@ -1,45 +1,43 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-041.js - Corresponds To: 7.5-8-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: lexical-041.js + Corresponds To: 7.5-8-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "lexical-041"; - var VERSION = "ECMA_1"; - var TITLE = "Identifiers"; +var SECTION = "lexical-041"; +var VERSION = "ECMA_1"; +var TITLE = "Identifiers"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var @abc;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var @abc;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var @abc" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var @abc" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-042.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-042.js index 88ee50951cf..5e032807e88 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-042.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-042.js @@ -1,46 +1,44 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-042.js - Corresponds To: 7.5-9-n.js - ECMA Section: 7.5 Identifiers - Description: Identifiers are of unlimited length - - can contain letters, a decimal digit, _, or $ - - the first character cannot be a decimal digit - - identifiers are case sensitive + File Name: lexical-042.js + Corresponds To: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "lexical-042"; - var VERSION = "JS1_4"; - var TITLE = "Identifiers"; +var SECTION = "lexical-042"; +var VERSION = "JS1_4"; +var TITLE = "Identifiers"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("var 123;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("var 123;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "var 123" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "var 123" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-047.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-047.js index b5e35489b8a..6437e4f0dde 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-047.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-047.js @@ -1,47 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-047.js - Corresponds To: 7.8.1-7-n.js - ECMA Section: 7.8.1 - Description: - Author: christine@netscape.com - Date: 15 september 1997 + File Name: lexical-047.js + Corresponds To: 7.8.1-7-n.js + ECMA Section: 7.8.1 + Description: + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "lexical-047"; - var VERSION = "JS1_4"; - var TITLE = "for loops"; +var SECTION = "lexical-047"; +var VERSION = "JS1_4"; +var TITLE = "for loops"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var counter = 0; + eval("for ( counter = 0\n" + + "counter <= 1\n" + + "counter++ )\n" + + "{\n" + + "result += \": got to inner loop\";\n" + + "}\n"); - try { - var counter = 0; - eval("for ( counter = 0\n" - + "counter <= 1\n" - + "counter++ )\n" - + "{\n" - + "result += \": got to inner loop\";\n" - + "}\n"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-048.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-048.js index 39a0600ad85..e0766ec62a5 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-048.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-048.js @@ -1,41 +1,39 @@ - /** - File Name: lexical-048.js - Corresponds To: 7.8.1-1.js - ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertion - Description: - Author: christine@netscape.com - Date: 15 september 1997 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/** + File Name: lexical-048.js + Corresponds To: 7.8.1-1.js + ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertion + Description: + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "lexical-048"; - var VERSION = "JS1_4"; - var TITLE = "The Rules of Automatic Semicolon Insertion"; +var SECTION = "lexical-048"; +var VERSION = "JS1_4"; +var TITLE = "The Rules of Automatic Semicolon Insertion"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var counter = 0; + eval( "for ( counter = 0;\ncounter <= 1\ncounter++ ) {\nresult += \": got inside for loop\")"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var counter = 0; - eval( "for ( counter = 0;\ncounter <= 1\ncounter++ ) {\nresult += \": got inside for loop\")"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-049.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-049.js index e03cfec0e40..e302a33996b 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-049.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-049.js @@ -1,46 +1,44 @@ - /** - File Name: lexical-049 - Corresponds To: 7.8.1-1.js - ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertioin - Description: - Author: christine@netscape.com - Date: 15 september 1997 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/** + File Name: lexical-049 + Corresponds To: 7.8.1-1.js + ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertioin + Description: + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "lexical-049"; - var VERSION = "JS1_4"; - var TITLE = "The Rules of Automatic Semicolon Insertion"; +var SECTION = "lexical-049"; +var VERSION = "JS1_4"; +var TITLE = "The Rules of Automatic Semicolon Insertion"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var counter = 0; + eval("for ( counter = 0\n" + + "counter <= 1;\n" + + "counter++ )\n" + + "{\n" + + "result += \": got inside for loop\";\n" + + "}\n"); - try { - var counter = 0; - eval("for ( counter = 0\n" - + "counter <= 1;\n" - + "counter++ )\n" - + "{\n" - + "result += \": got inside for loop\";\n" - + "}\n"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "line breaks within a for expression" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-050.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-050.js index bc871a7e2dd..bcec0e3d19d 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-050.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-050.js @@ -1,42 +1,40 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-050.js - Corresponds to: 7.8.2-1-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 + File Name: lexical-050.js + Corresponds to: 7.8.2-1-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "lexical-050"; - var VERSION = "JS1_4"; - var TITLE = "Examples of Automatic Semicolon Insertion"; +var SECTION = "lexical-050"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("{ 1 2 } 3"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("{ 1 2 } 3"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "{ 1 2 } 3" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "{ 1 2 } 3" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-051.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-051.js index 68e6b44258a..84c8f399208 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-051.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-051.js @@ -1,42 +1,40 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-051.js - Corresponds to: 7.8.2-3-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 + File Name: lexical-051.js + Corresponds to: 7.8.2-3-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "lexical-051"; - var VERSION = "JS1_4"; - var TITLE = "Examples of Automatic Semicolon Insertion"; +var SECTION = "lexical-051"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; - - try { - eval("for (a; b\n) result += \": got to inner loop\";") +try { + eval("for (a; b\n) result += \": got to inner loop\";") } catch ( e ) { - result = expect; - exception = e.toString(); + result = expect; + exception = e.toString(); } - testcases[tc++] = new TestCase( - SECTION, - "for (a; b\n)" + - " (threw " + exception +")", - expect, - result ); +new TestCase( + SECTION, + "for (a; b\n)" + + " (threw " + exception +")", + expect, + result ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-052.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-052.js index 49aa7c761df..0f3ce439d79 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-052.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-052.js @@ -1,44 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-052.js - Corresponds to: 7.8.2-4-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 + File Name: lexical-052.js + Corresponds to: 7.8.2-4-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "lexical-052"; - var VERSION = "JS1_4"; - var TITLE = "Examples of Automatic Semicolon Insertion"; +var SECTION = "lexical-052"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + MyFunction(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - MyFunction(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "calling return indirectly" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "calling return indirectly" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyFunction() { - var s = "return"; - eval(s); + var s = "return"; + eval(s); } diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-053.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-053.js index 6e3ae99bd67..3728e3c39c5 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-053.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-053.js @@ -1,42 +1,40 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-053.js - Corresponds to: 7.8.2-7-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 + File Name: lexical-053.js + Corresponds to: 7.8.2-7-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "lexical-053"; - var VERSION = "JS1_4"; - var TITLE = "Examples of Automatic Semicolon Insertion"; +var SECTION = "lexical-053"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + a = true + b = false - try { - a = true - b = false + eval('if (a > b)\nelse result += ": got to else statement"'); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - eval('if (a > b)\nelse result += ": got to else statement"'); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "calling return indirectly" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "calling return indirectly" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/lexical-054.js b/mozilla/js/tests/ecma_2/Exceptions/lexical-054.js index c4b9e9f654b..5739239a4f6 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/lexical-054.js +++ b/mozilla/js/tests/ecma_2/Exceptions/lexical-054.js @@ -1,43 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: lexical-054.js - Corresponds to: 7.8.2-7-n.js - ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion - Description: compare some specific examples of the automatic - insertion rules in the EMCA specification. - Author: christine@netscape.com - Date: 15 september 1997 + File Name: lexical-054.js + Corresponds to: 7.8.2-7-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "lexical-054"; - var VERSION = "JS1_4"; - var TITLE = "Examples of Automatic Semicolon Insertion"; +var SECTION = "lexical-054"; +var VERSION = "JS1_4"; +var TITLE = "Examples of Automatic Semicolon Insertion"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + a=0; + b=1; + c=2; + d=3; + eval("if (a > b)\nelse c = d"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - a=0; - b=1; - c=2; - d=3; - eval("if (a > b)\nelse c = d"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "if (a > b)\nelse c = d" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "if (a > b)\nelse c = d" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/number-001.js b/mozilla/js/tests/ecma_2/Exceptions/number-001.js index 1f456037d3d..746bc36e21d 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/number-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/number-001.js @@ -1,52 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: number-001 - Corresponds To: 15.7.4.2-2-n.js - ECMA Section: 15.7.4.2.2 Number.prototype.toString() - Description: - If the radix is the number 10 or not supplied, then this number value is - given as an argument to the ToString operator; the resulting string value - is returned. + File Name: number-001 + Corresponds To: 15.7.4.2-2-n.js + ECMA Section: 15.7.4.2.2 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. - If the radix is supplied and is an integer from 2 to 36, but not 10, the - result is a string, the choice of which is implementation dependent. + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. - The toString function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "number-001"; - var VERSION = "JS1_4"; - var TITLE = "Exceptions for Number.toString()"; +var SECTION = "number-001"; +var VERSION = "JS1_4"; +var TITLE = "Exceptions for Number.toString()"; - startTest(); - writeHeaderToLog( SECTION + " Number.prototype.toString()"); +startTest(); +writeHeaderToLog( SECTION + " Number.prototype.toString()"); - var testcases = new Array(); - var tc = 0; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; +try { + object= new Object(); + object.toString = Number.prototype.toString; + result = object.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +new TestCase( + SECTION, + "object = new Object(); object.toString = Number.prototype.toString; object.toString()" + + " (threw " + exception +")", + expect, + result ); - - try { - object= new Object(); - object.toString = Number.prototype.toString; - result = object.toString(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } - - testcases[tc++] = new TestCase( - SECTION, - "object = new Object(); object.toString = Number.prototype.toString; object.toString()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/number-002.js b/mozilla/js/tests/ecma_2/Exceptions/number-002.js index 5e84ebf20e3..c8502ca19b9 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/number-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/number-002.js @@ -1,45 +1,43 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: number-002.js - Corresponds To: ecma/Number/15.7.4.3-2-n.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. + File Name: number-002.js + Corresponds To: ecma/Number/15.7.4.3-2-n.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "number-002"; - var VERSION = "JS1_4"; - var TITLE = "Exceptions for Number.valueOf()"; +var SECTION = "number-002"; +var VERSION = "JS1_4"; +var TITLE = "Exceptions for Number.valueOf()"; - startTest(); - writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); +startTest(); +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - var testcases = new Array(); - var tc = 0; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + object= new Object(); + object.toString = Number.prototype.valueOf; + result = object.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - object= new Object(); - object.toString = Number.prototype.valueOf; - result = object.toString(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/number-003.js b/mozilla/js/tests/ecma_2/Exceptions/number-003.js index 947d3d23243..ab9ac7672bb 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/number-003.js +++ b/mozilla/js/tests/ecma_2/Exceptions/number-003.js @@ -1,47 +1,45 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: number-003.js - Corresponds To: 15.7.4.3-3.js - ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() - Description: - Returns this number value. + File Name: number-003.js + Corresponds To: 15.7.4.3-3.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. - The valueOf function is not generic; it generates a runtime error if its - this value is not a Number object. Therefore it cannot be transferred to - other kinds of objects for use as a method. + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. - Author: christine@netscape.com - Date: 16 september 1997 + Author: christine@netscape.com + Date: 16 september 1997 */ - var SECTION = "number-003"; - var VERSION = "JS1_4"; - var TITLE = "Exceptions for Number.valueOf()"; +var SECTION = "number-003"; +var VERSION = "JS1_4"; +var TITLE = "Exceptions for Number.valueOf()"; - var tc = 0; - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); - startTest(); - writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + VALUE_OF = Number.prototype.valueOf; + OBJECT = new String("Infinity"); + OBJECT.valueOf = VALUE_OF; + result = OBJECT.valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - VALUE_OF = Number.prototype.valueOf; - OBJECT = new String("Infinity"); - OBJECT.valueOf = VALUE_OF; - result = OBJECT.valueOf(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "Assigning Number.prototype.valueOf as the valueOf of a String object " + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "Assigning Number.prototype.valueOf as the valueOf of a String object " + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/shell.js b/mozilla/js/tests/ecma_2/Exceptions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-001.js b/mozilla/js/tests/ecma_2/Exceptions/statement-001.js index 928a04d747d..4b4a130bc60 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-001.js @@ -1,44 +1,42 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: statement-001.js - Corresponds To: 12.6.2-9-n.js - ECMA Section: 12.6.2 The for Statement + File Name: statement-001.js + Corresponds To: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement - 1. first expression is not present. - 2. second expression is not present - 3. third expression is not present + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present - Author: christine@netscape.com - Date: 15 september 1997 + Author: christine@netscape.com + Date: 15 september 1997 */ - var SECTION = "statement-001.js"; +var SECTION = "statement-001.js"; // var SECTION = "12.6.2-9-n"; - var VERSION = "ECMA_1"; - var TITLE = "The for statment"; +var VERSION = "ECMA_1"; +var TITLE = "The for statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - var tc = 0; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("for (i) {\n}"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("for (i) {\n}"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "for(i) {}" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "for(i) {}" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-002.js b/mozilla/js/tests/ecma_2/Exceptions/statement-002.js index 83c642c12d7..4b5c2c6ec56 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-002.js @@ -1,66 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: statement-002.js - Corresponds To: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: statement-002.js + Corresponds To: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "statement-002"; - var VERSION = "JS1_4"; - var TITLE = "The for..in statment"; +var SECTION = "statement-002"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; - var testcases = new Array(); - var tc = 0; +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval(" for ( var i, p in this) { result += this[p]; }"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval(" for ( var i, p in this) { result += this[p]; }"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "more than one member expression" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "more than one member expression" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-003.js b/mozilla/js/tests/ecma_2/Exceptions/statement-003.js index c7ffc7f9ba1..38916a780a8 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-003.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-003.js @@ -1,77 +1,75 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: statement-003 - Corresponds To: 12.6.3-7-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - The production IterationStatement : for ( LeftHandSideExpression in Expression ) - Statement is evaluated as follows: + File Name: statement-003 + Corresponds To: 12.6.3-7-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: - 1. Evaluate the Expression. - 2. Call GetValue(Result(1)). - 3. Call ToObject(Result(2)). - 4. Let C be "normal completion". - 5. Get the name of the next property of Result(3) that doesn't have the - DontEnum attribute. If there is no such property, go to step 14. - 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). - 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): - 1. If Type(V) is not Reference, generate a runtime error. - 2. Call GetBase(V). - 3. If Result(2) is null, go to step 6. - 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) - for the property name and W for the value. - 5. Return. - 6. Call the [[Put]] method for the global object, passing - GetPropertyName(V) for the property name and W for the value. - 7. Return. - 8. Evaluate Statement. - 9. If Result(8) is a value completion, change C to be "normal completion - after value V" where V is the value carried by Result(8). - 10. If Result(8) is a break completion, go to step 14. - 11. If Result(8) is a continue completion, go to step 5. - 12. If Result(8) is a return completion, return Result(8). - 13. Go to step 5. - 14. Return C. + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "statement-003"; - var VERSION = "JS1_4"; - var TITLE = "The for..in statment"; +var SECTION = "statement-003"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - var tc = 0; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var o = new MyObject(); + var result = 0; - try { - var o = new MyObject(); - var result = 0; + eval("for ( this in o) {\n" + + "result += this[p];\n" + + "}\n"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - eval("for ( this in o) {\n" - + "result += this[p];\n" - + "}\n"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyObject() { - this.value = 2; - this[0] = 4; - return this; + this.value = 2; + this[0] = 4; + return this; } diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-004.js b/mozilla/js/tests/ecma_2/Exceptions/statement-004.js index 9eee4e605e9..2b59c09961d 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-004.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-004.js @@ -1,49 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: statement-004.js - Corresponds To: 12.6.3-1.js - ECMA Section: 12.6.3 The for...in Statement - Description: - Author: christine@netscape.com - Date: 11 september 1997 + File Name: statement-004.js + Corresponds To: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "statement-004"; - var VERSION = "JS1_4"; - var TITLE = "The for..in statment"; +var SECTION = "statement-004"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - var tc = 0; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var o = new MyObject(); - try { - var o = new MyObject(); + eval("for ( \"a\" in o) {\n" + + "result += this[p];\n" + + "}"); - eval("for ( \"a\" in o) {\n" - + "result += this[p];\n" - + "}"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyObject() { - this.value = 2; - this[0] = 4; - return this; + this.value = 2; + this[0] = 4; + return this; } diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-005.js b/mozilla/js/tests/ecma_2/Exceptions/statement-005.js index 50933b03b7e..aa87e3633c9 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-005.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-005.js @@ -1,48 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: statement-005.js - Corresponds To: 12.6.3-8-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: - Author: christine@netscape.com - Date: 11 september 1997 + File Name: statement-005.js + Corresponds To: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "statement-005"; - var VERSION = "JS1_4"; - var TITLE = "The for..in statment"; +var SECTION = "statement-005"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - var tc = 0; +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var o = new MyObject(); + result = 0; - try { - var o = new MyObject(); - result = 0; + eval("for (1 in o) {\n" + + "result += this[p];" + + "}\n"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - eval("for (1 in o) {\n" - + "result += this[p];" - + "}\n"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "bad left-hand side expression" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyObject() { - this.value = 2; - this[0] = 4; - return this; + this.value = 2; + this[0] = 4; + return this; } diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-006.js b/mozilla/js/tests/ecma_2/Exceptions/statement-006.js index 1fe03259eac..6e86ac70bab 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-006.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-006.js @@ -1,48 +1,46 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: statement-006.js - Corresponds To: 12.6.3-9-n.js - ECMA Section: 12.6.3 The for...in Statement - Description: + File Name: statement-006.js + Corresponds To: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: - Author: christine@netscape.com - Date: 11 september 1997 + Author: christine@netscape.com + Date: 11 september 1997 */ - var SECTION = "statement-006"; - var VERSION = "JS1_4"; - var TITLE = "The for..in statment"; +var SECTION = "statement-006"; +var VERSION = "JS1_4"; +var TITLE = "The for..in statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var o = new MyObject(); + var result = 0; + for ( var o in foo) { + result += this[o]; + } +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var o = new MyObject(); - var result = 0; - for ( var o in foo) { - result += this[o]; - } - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "object is not defined" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "object is not defined" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); function MyObject() { - this.value = 2; - this[0] = 4; - return this; -} \ No newline at end of file + this.value = 2; + this[0] = 4; + return this; +} diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-007.js b/mozilla/js/tests/ecma_2/Exceptions/statement-007.js index 506578b4d90..7499b3029b7 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-007.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-007.js @@ -1,39 +1,37 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: statement-007.js - Corresponds To: 12.7-1-n.js - ECMA Section: 12.7 The continue statement - Description: + File Name: statement-007.js + Corresponds To: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "statement-007"; - var VERSION = "JS1_4"; - var TITLE = "The continue statment"; +var SECTION = "statement-007"; +var VERSION = "JS1_4"; +var TITLE = "The continue statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("continue;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("continue;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "continue outside of an iteration statement" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "continue outside of an iteration statement" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-008.js b/mozilla/js/tests/ecma_2/Exceptions/statement-008.js index e293964c129..c95888b60c3 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-008.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-008.js @@ -1,39 +1,37 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: statement-008.js - Corresponds To: 12.8-1-n.js - ECMA Section: 12.8 The break statement - Description: + File Name: statement-008.js + Corresponds To: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "statement-008"; - var VERSION = "JS1_4"; - var TITLE = "The break in statment"; +var SECTION = "statement-008"; +var VERSION = "JS1_4"; +var TITLE = "The break in statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("break;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("break;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "break outside of an iteration statement" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "break outside of an iteration statement" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/statement-009.js b/mozilla/js/tests/ecma_2/Exceptions/statement-009.js index 136d3f1f866..1723ddbcedd 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/statement-009.js +++ b/mozilla/js/tests/ecma_2/Exceptions/statement-009.js @@ -1,38 +1,36 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: 12.9-1-n.js - ECMA Section: 12.9 The return statement - Description: + File Name: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "12.9-1-n"; - var VERSION = "ECMA_1"; - var TITLE = "The return statment"; +var SECTION = "12.9-1-n"; +var VERSION = "ECMA_1"; +var TITLE = "The return statement"; - startTest(); - writeHeaderToLog( SECTION + " The return statement"); +startTest(); +writeHeaderToLog( SECTION + " The return statement"); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + eval("return;"); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - eval("return;"); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "return outside of a function" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "return outside of a function" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/string-001.js b/mozilla/js/tests/ecma_2/Exceptions/string-001.js index 9ba39afb1a3..a51c4d46f36 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/string-001.js +++ b/mozilla/js/tests/ecma_2/Exceptions/string-001.js @@ -1,50 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: string-001.js - Corresponds To: 15.5.4.2-2-n.js - ECMA Section: 15.5.4.2 String.prototype.toString() + File Name: string-001.js + Corresponds To: 15.5.4.2-2-n.js + ECMA Section: 15.5.4.2 String.prototype.toString() - Description: Returns this string value. Note that, for a String - object, the toString() method happens to return the same - thing as the valueOf() method. + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. - The toString function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "string-001"; - var VERSION = "JS1_4"; - var TITLE = "String.prototype.toString"; +var SECTION = "string-001"; +var VERSION = "JS1_4"; +var TITLE = "String.prototype.toString"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + OBJECT = new Object(); + OBJECT.toString = String.prototype.toString(); + result = OBJECT.toString(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - OBJECT = new Object(); - OBJECT.toString = String.prototype.toString(); - result = OBJECT.toString(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "OBJECT = new Object; "+ + " OBJECT.toString = String.prototype.toString; OBJECT.toString()" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "OBJECT = new Object; "+ - " OBJECT.toString = String.prototype.toString; OBJECT.toString()" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Exceptions/string-002.js b/mozilla/js/tests/ecma_2/Exceptions/string-002.js index 857271efe07..5b26f134547 100644 --- a/mozilla/js/tests/ecma_2/Exceptions/string-002.js +++ b/mozilla/js/tests/ecma_2/Exceptions/string-002.js @@ -1,49 +1,47 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: string-002.js - Corresponds To: 15.5.4.3-3-n.js - ECMA Section: 15.5.4.3 String.prototype.valueOf() + File Name: string-002.js + Corresponds To: 15.5.4.3-3-n.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() - Description: Returns this string value. + Description: Returns this string value. - The valueOf function is not generic; it generates a - runtime error if its this value is not a String object. - Therefore it connot be transferred to the other kinds of - objects for use as a method. + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. - Author: christine@netscape.com - Date: 1 october 1997 + Author: christine@netscape.com + Date: 1 october 1997 */ - var SECTION = "string-002"; - var VERSION = "JS1_4"; - var TITLE = "String.prototype.valueOf"; +var SECTION = "string-002"; +var VERSION = "JS1_4"; +var TITLE = "String.prototype.valueOf"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var result = "Failed"; +var exception = "No exception thrown"; +var expect = "Passed"; - var result = "Failed"; - var exception = "No exception thrown"; - var expect = "Passed"; +try { + var OBJECT =new Object(); + OBJECT.valueOf = String.prototype.valueOf; + result = OBJECT.valueOf(); +} catch ( e ) { + result = expect; + exception = e.toString(); +} - try { - var OBJECT =new Object(); - OBJECT.valueOf = String.prototype.valueOf; - result = OBJECT.valueOf(); - } catch ( e ) { - result = expect; - exception = e.toString(); - } +new TestCase( + SECTION, + "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+ + "result = OBJECT.valueOf();" + + " (threw " + exception +")", + expect, + result ); - testcases[tc++] = new TestCase( - SECTION, - "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+ - "result = OBJECT.valueOf();" + - " (threw " + exception +")", - expect, - result ); - - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Expressions/StrictEquality-001.js b/mozilla/js/tests/ecma_2/Expressions/StrictEquality-001.js index c3ac50735cf..1d7cfb1c038 100644 --- a/mozilla/js/tests/ecma_2/Expressions/StrictEquality-001.js +++ b/mozilla/js/tests/ecma_2/Expressions/StrictEquality-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: StrictEquality-001.js * ECMA Section: 11.9.6.js @@ -6,65 +7,62 @@ * Author: christine@netscape.com * Date: 4 september 1998 */ - var SECTION = "StrictEquality-001 - 11.9.6"; - var VERSION = "ECMA_2"; - var TITLE = "The strict equality operator ( === )"; +var SECTION = "StrictEquality-001 - 11.9.6"; +var VERSION = "ECMA_2"; +var TITLE = "The strict equality operator ( === )"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var tc = 0; - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - // 1. If Type(x) is different from Type(y) return false +// 1. If Type(x) is different from Type(y) return false - StrictEquality( true, new Boolean(true), false ); - StrictEquality( new Boolean(), false, false ); - StrictEquality( "", new String(), false ); - StrictEquality( new String("hi"), "hi", false ); +StrictEquality( true, new Boolean(true), false ); +StrictEquality( new Boolean(), false, false ); +StrictEquality( "", new String(), false ); +StrictEquality( new String("hi"), "hi", false ); - // 2. If Type(x) is not Number go to step 9. +// 2. If Type(x) is not Number go to step 9. - // 3. If x is NaN, return false - StrictEquality( NaN, NaN, false ); - StrictEquality( NaN, 0, false ); +// 3. If x is NaN, return false +StrictEquality( NaN, NaN, false ); +StrictEquality( NaN, 0, false ); - // 4. If y is NaN, return false. - StrictEquality( 0, NaN, false ); +// 4. If y is NaN, return false. +StrictEquality( 0, NaN, false ); - // 5. if x is the same number value as y, return true +// 5. if x is the same number value as y, return true - // 6. If x is +0 and y is -0, return true +// 6. If x is +0 and y is -0, return true - // 7. If x is -0 and y is +0, return true +// 7. If x is -0 and y is +0, return true - // 8. Return false. +// 8. Return false. - // 9. If Type(x) is String, then return true if x and y are exactly - // the same sequence of characters ( same length and same characters - // in corresponding positions.) Otherwise return false. +// 9. If Type(x) is String, then return true if x and y are exactly +// the same sequence of characters ( same length and same characters +// in corresponding positions.) Otherwise return false. - // 10. If Type(x) is Boolean, return true if x and y are both true or - // both false. otherwise return false. +// 10. If Type(x) is Boolean, return true if x and y are both true or +// both false. otherwise return false. - // Return true if x and y refer to the same object. Otherwise return - // false. +// Return true if x and y refer to the same object. Otherwise return +// false. - // Return false. +// Return false. - test(); +test(); function StrictEquality( x, y, expect ) { - result = ( x === y ); + result = ( x === y ); - testcases[tc++] = new TestCase( - SECTION, - x +" === " + y, - expect, - result ); + new TestCase( + SECTION, + x +" === " + y, + expect, + result ); } diff --git a/mozilla/js/tests/ecma_2/Expressions/browser.js b/mozilla/js/tests/ecma_2/Expressions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/Expressions/instanceof-001.js b/mozilla/js/tests/ecma_2/Expressions/instanceof-001.js index 2e7412ad8c4..6a81aa40b7f 100644 --- a/mozilla/js/tests/ecma_2/Expressions/instanceof-001.js +++ b/mozilla/js/tests/ecma_2/Expressions/instanceof-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: instanceof-001.js * ECMA Section: 11.8.6 @@ -8,110 +9,98 @@ * Author: christine@netscape.com * Date: 2 September 1998 */ - var SECTION = "instanceof-001"; - var VERSION = "ECMA_2"; - var TITLE = "instanceof" +var SECTION = "instanceof-001"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; - function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} - testcases[tc++] = new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); - } +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); - } - Gen3.name = 3; - Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); - function Gen2(value) { - this.value = value; - this.generation = 2; - } - Gen2.name = 2; - Gen2.prototype = new Gen3(); +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); - function Gen1(value) { - this.value = value; - this.generation = 1; - } - Gen1.name = 1; - Gen1.prototype = new Gen2(); - - function Gen0(value) { - this.value = value; - this.generation = 0; - } - Gen0.name = 0; - Gen0.prototype = new Gen1(); +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); - function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenA.prototype = new Gen0(); - GenA.name = "A"; +} +GenA.prototype = new Gen0(); +GenA.name = "A"; - function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenB.name = "B" - GenB.prototype = void 0; +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" +GenB.prototype = void 0; - // RelationalExpression is not an object. +// RelationalExpression is not an object. - InstanceOf( true, Boolean, false ); - InstanceOf( new Boolean(false), Boolean, true ); +InstanceOf( true, Boolean, false ); +InstanceOf( new Boolean(false), Boolean, true ); - // Identifier is not a function +// __proto__ of RelationalExpression is null. should return false +genA = new GenA(); +genA.__proto__ = null; -// InstanceOf( true, true, false ); -// InstanceOf( new Boolean(true), false, false ); +InstanceOf( genA, GenA, false ); - // Identifier is a function, prototype of Identifier is not an object +// RelationalExpression.__proto__ == (but not ===) Identifier.prototype -// InstanceOf( new GenB(), GenB, false ); +InstanceOf( new Gen2(), Gen0, false ); +InstanceOf( new Gen2(), Gen1, false ); +InstanceOf( new Gen2(), Gen2, true ); +InstanceOf( new Gen2(), Gen3, true ); - // __proto__ of RelationalExpression is null. should return false - genA = new GenA(); - genA.__proto__ = null; +// RelationalExpression.__proto__.__proto__ === Identifier.prototype +InstanceOf( new Gen0(), Gen0, true ); +InstanceOf( new Gen0(), Gen1, true ); +InstanceOf( new Gen0(), Gen2, true ); +InstanceOf( new Gen0(), Gen3, true ); - InstanceOf( genA, GenA, false ); +InstanceOf( new Gen0(), Object, true ); +InstanceOf( new Gen0(), Function, false ); - // RelationalExpression.__proto__ == (but not ===) Identifier.prototype +InstanceOf( Gen0, Function, true ); +InstanceOf( Gen0, Object, true ); - InstanceOf( new Gen2(), Gen0, false ); - InstanceOf( new Gen2(), Gen1, false ); - InstanceOf( new Gen2(), Gen2, true ); - InstanceOf( new Gen2(), Gen3, true ); - - // RelationalExpression.__proto__.__proto__ === Identifier.prototype - InstanceOf( new Gen0(), Gen0, true ); - InstanceOf( new Gen0(), Gen1, true ); - InstanceOf( new Gen0(), Gen2, true ); - InstanceOf( new Gen0(), Gen3, true ); - - InstanceOf( new Gen0(), Object, true ); - InstanceOf( new Gen0(), Function, false ); - - InstanceOf( Gen0, Function, true ); - InstanceOf( Gen0, Object, true ); - - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma_2/Expressions/instanceof-002.js b/mozilla/js/tests/ecma_2/Expressions/instanceof-002.js index 68697d06b04..a597d482c9b 100644 --- a/mozilla/js/tests/ecma_2/Expressions/instanceof-002.js +++ b/mozilla/js/tests/ecma_2/Expressions/instanceof-002.js @@ -1,124 +1,122 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: instanceof-002.js - Section: - Description: Determining Instance Relationships + File Name: instanceof-002.js + Section: + Description: Determining Instance Relationships - This test is the same as js1_3/inherit/proto-002, except that it uses - the builtin instanceof operator rather than a user-defined function - called InstanceOf. + This test is the same as js1_3/inherit/proto-002, except that it uses + the builtin instanceof operator rather than a user-defined function + called InstanceOf. - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ // onerror = err; - var SECTION = "instanceof-002"; - var VERSION = "ECMA_2"; - var TITLE = "Determining Instance Relationships"; +var SECTION = "instanceof-002"; +var VERSION = "ECMA_2"; +var TITLE = "Determining Instance Relationships"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var tc = 0; - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function InstanceOf( object, constructor ) { - while ( object != null ) { - if ( object == constructor.prototype ) { - return true; - } - object = object.__proto__; + while ( object != null ) { + if ( object == constructor.prototype ) { + return true; } - return false; + object = object.__proto__; + } + return false; } function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; + this.name = name || ""; + this.dept = dept || "general"; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee ( name, dept, projs ) { - this.base = Employee; - this.base( name, dept) + this.base = Employee; + this.base( name, dept) this.projects = projs || new Array(); } WorkerBee.prototype = new Employee(); function SalesPerson () { - this.dept = "sales"; - this.quota = 100; + this.dept = "sales"; + this.quota = 100; } SalesPerson.prototype = new WorkerBee(); function Engineer ( name, projs, machine ) { - this.base = WorkerBee; - this.base( name, "engineering", projs ) + this.base = WorkerBee; + this.base( name, "engineering", projs ) this.machine = machine || ""; } Engineer.prototype = new WorkerBee(); -var pat = new Engineer() +var pat = new Engineer(); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__ == Engineer.prototype", - true, - pat.__proto__ == Engineer.prototype ); +new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__.__proto__ == WorkerBee.prototype", - true, - pat.__proto__.__proto__ == WorkerBee.prototype ); +new TestCase( SECTION, + "pat.__proto__.__proto__ == WorkerBee.prototype", + true, + pat.__proto__.__proto__ == WorkerBee.prototype ); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__ == Employee.prototype", - true, - pat.__proto__.__proto__.__proto__ == Employee.prototype ); +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__ == Employee.prototype", + true, + pat.__proto__.__proto__.__proto__ == Employee.prototype ); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", - true, - pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", + true, + pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", - true, - pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", + true, + pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); - testcases[tc++] = new TestCase( SECTION, - "pat instanceof Engineer", - true, - pat instanceof Engineer ); +new TestCase( SECTION, + "pat instanceof Engineer", + true, + pat instanceof Engineer ); - testcases[tc++] = new TestCase( SECTION, - "pat instanceof WorkerBee )", - true, - pat instanceof WorkerBee ); +new TestCase( SECTION, + "pat instanceof WorkerBee )", + true, + pat instanceof WorkerBee ); - testcases[tc++] = new TestCase( SECTION, - "pat instanceof Employee )", - true, - pat instanceof Employee ); +new TestCase( SECTION, + "pat instanceof Employee )", + true, + pat instanceof Employee ); - testcases[tc++] = new TestCase( SECTION, - "pat instanceof Object )", - true, - pat instanceof Object ); +new TestCase( SECTION, + "pat instanceof Object )", + true, + pat instanceof Object ); - testcases[tc++] = new TestCase( SECTION, - "pat instanceof SalesPerson )", - false, - pat instanceof SalesPerson ); - test(); +new TestCase( SECTION, + "pat instanceof SalesPerson )", + false, + pat instanceof SalesPerson ); +test(); diff --git a/mozilla/js/tests/ecma_2/Expressions/instanceof-003-n.js b/mozilla/js/tests/ecma_2/Expressions/instanceof-003-n.js index f48108ee418..e7155c01293 100644 --- a/mozilla/js/tests/ecma_2/Expressions/instanceof-003-n.js +++ b/mozilla/js/tests/ecma_2/Expressions/instanceof-003-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: instanceof-001.js * ECMA Section: 11.8.6 @@ -8,86 +9,75 @@ * Author: christine@netscape.com * Date: 2 September 1998 */ - var SECTION = "instanceof-001"; - var VERSION = "ECMA_2"; - var TITLE = "instanceof" +var SECTION = "instanceof-003-n"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +function InstanceOf( object_1, object_2, expect ) { - function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; + result = object_1 instanceof object_2; - testcases[tc++] = new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); - } + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} - function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); - } - Gen3.name = 3; - Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - function Gen2(value) { - this.value = value; - this.generation = 2; - } - Gen2.name = 2; - Gen2.prototype = new Gen3(); +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); - function Gen1(value) { - this.value = value; - this.generation = 1; - } - Gen1.name = 1; - Gen1.prototype = new Gen2(); +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); - function Gen0(value) { - this.value = value; - this.generation = 0; - } - Gen0.name = 0; - Gen0.prototype = new Gen1(); +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); - function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenA.prototype = new Gen0(); - GenA.name = "A"; +} +GenA.prototype = new Gen0(); +GenA.name = "A"; - function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenB.name = "B" - GenB.prototype = void 0; +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" +GenB.prototype = void 0; - // RelationalExpression is not an object. +// Identifier is not a function +DESCRIPTION = "Identifier is not a function"; +EXPECTED = "error"; - InstanceOf( true, Boolean, false ); -// InstanceOf( new Boolean(false), Boolean, true ); +InstanceOf( true, true, "error" ); - // Identifier is not a function - - InstanceOf( true, true, false ); -// InstanceOf( new Boolean(true), false, false ); - - // Identifier is a function, prototype of Identifier is not an object - -// InstanceOf( new GenB(), GenB, false ); - - - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma_2/Expressions/instanceof-004-n.js b/mozilla/js/tests/ecma_2/Expressions/instanceof-004-n.js index 664a5536a6c..4e0a96e57cb 100644 --- a/mozilla/js/tests/ecma_2/Expressions/instanceof-004-n.js +++ b/mozilla/js/tests/ecma_2/Expressions/instanceof-004-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: instanceof-001.js * ECMA Section: 11.8.6 @@ -8,85 +9,75 @@ * Author: christine@netscape.com * Date: 2 September 1998 */ - var SECTION = "instanceof-001"; - var VERSION = "ECMA_2"; - var TITLE = "instanceof" +var SECTION = "instanceof-004-n"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; - function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} - testcases[tc++] = new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); - } +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); - } - Gen3.name = 3; - Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); - function Gen2(value) { - this.value = value; - this.generation = 2; - } - Gen2.name = 2; - Gen2.prototype = new Gen3(); +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); - function Gen1(value) { - this.value = value; - this.generation = 1; - } - Gen1.name = 1; - Gen1.prototype = new Gen2(); - - function Gen0(value) { - this.value = value; - this.generation = 0; - } - Gen0.name = 0; - Gen0.prototype = new Gen1(); +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); - function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenA.prototype = new Gen0(); - GenA.name = "A"; +} +GenA.prototype = new Gen0(); +GenA.name = "A"; - function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenB.name = "B" - GenB.prototype = void 0; +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" +GenB.prototype = void 0; - // RelationalExpression is not an object. +// Identifier is not a function - InstanceOf( true, Boolean, false ); - InstanceOf( new Boolean(false), Boolean, true ); +DESCRIPTION = "Identifier is not a function"; +EXPECTED = "error"; - // Identifier is not a function +InstanceOf( new Boolean(true), false, "error" ); - InstanceOf( new Boolean(true), false, false ); - - // Identifier is a function, prototype of Identifier is not an object - -// InstanceOf( new GenB(), GenB, false ); - - - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma_2/Expressions/instanceof-005-n.js b/mozilla/js/tests/ecma_2/Expressions/instanceof-005-n.js index c3a621d9b78..a93e1813d21 100644 --- a/mozilla/js/tests/ecma_2/Expressions/instanceof-005-n.js +++ b/mozilla/js/tests/ecma_2/Expressions/instanceof-005-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: instanceof-001.js * ECMA Section: 11.8.6 @@ -8,77 +9,76 @@ * Author: christine@netscape.com * Date: 2 September 1998 */ - var SECTION = "instanceof-001"; - var VERSION = "ECMA_2"; - var TITLE = "instanceof" +var SECTION = "instanceof-005-n"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; - function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} - testcases[tc++] = new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); - } +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); - } - Gen3.name = 3; - Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); - function Gen2(value) { - this.value = value; - this.generation = 2; - } - Gen2.name = 2; - Gen2.prototype = new Gen3(); +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); - function Gen1(value) { - this.value = value; - this.generation = 1; - } - Gen1.name = 1; - Gen1.prototype = new Gen2(); - - function Gen0(value) { - this.value = value; - this.generation = 0; - } - Gen0.name = 0; - Gen0.prototype = new Gen1(); +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); - function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenA.prototype = new Gen0(); - GenA.name = "A"; +} +GenA.prototype = new Gen0(); +GenA.name = "A"; - function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenB.name = "B" - GenB.prototype = void 0; +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" +GenB.prototype = void 0; - // Identifier is a function, prototype of Identifier is not an object +// Identifier is a function, prototype of Identifier is not an object - InstanceOf( new GenB(), GenB, false ); +DESCRIPTION = "Identifier is a function, prototype of Identifier is not an object"; +EXPECTED = "error"; +InstanceOf( new GenB(), GenB, "error" ); - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma_2/Expressions/instanceof-006.js b/mozilla/js/tests/ecma_2/Expressions/instanceof-006.js index f1be0b4be97..def13858039 100644 --- a/mozilla/js/tests/ecma_2/Expressions/instanceof-006.js +++ b/mozilla/js/tests/ecma_2/Expressions/instanceof-006.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: instanceof-001.js * ECMA Section: 11.8.6 @@ -8,76 +9,73 @@ * Author: christine@netscape.com * Date: 2 September 1998 */ - var SECTION = "instanceof-001"; - var VERSION = "ECMA_2"; - var TITLE = "instanceof" +var SECTION = "instanceof-001"; +var VERSION = "ECMA_2"; +var TITLE = "instanceof" - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; - function InstanceOf( object_1, object_2, expect ) { - result = object_1 instanceof object_2; + new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); +} - testcases[tc++] = new TestCase( - SECTION, - "(" + object_1 + ") instanceof " + object_2, - expect, - result ); - } +function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); +} +Gen3.name = 3; +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); - function Gen3(value) { - this.value = value; - this.generation = 3; - this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); - } - Gen3.name = 3; - Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); +function Gen2(value) { + this.value = value; + this.generation = 2; +} +Gen2.name = 2; +Gen2.prototype = new Gen3(); - function Gen2(value) { - this.value = value; - this.generation = 2; - } - Gen2.name = 2; - Gen2.prototype = new Gen3(); +function Gen1(value) { + this.value = value; + this.generation = 1; +} +Gen1.name = 1; +Gen1.prototype = new Gen2(); - function Gen1(value) { - this.value = value; - this.generation = 1; - } - Gen1.name = 1; - Gen1.prototype = new Gen2(); - - function Gen0(value) { - this.value = value; - this.generation = 0; - } - Gen0.name = 0; - Gen0.prototype = new Gen1(); +function Gen0(value) { + this.value = value; + this.generation = 0; +} +Gen0.name = 0; +Gen0.prototype = new Gen1(); - function GenA(value) { - this.value = value; - this.generation = "A"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenA.prototype = new Gen0(); - GenA.name = "A"; +} +GenA.prototype = new Gen0(); +GenA.name = "A"; - function GenB(value) { - this.value = value; - this.generation = "B"; - this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); - } - GenB.name = "B" - GenB.prototype = void 0; +function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); +} +GenB.name = "B" +GenB.prototype = void 0; - // RelationalExpression is not an object. +// RelationalExpression is not an object. // InstanceOf( true, Boolean, false ); - InstanceOf( new Boolean(false), Boolean, true ); +InstanceOf( new Boolean(false), Boolean, true ); - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/ecma_2/Expressions/shell.js b/mozilla/js/tests/ecma_2/Expressions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/FunctionObjects/apply-001-n.js b/mozilla/js/tests/ecma_2/FunctionObjects/apply-001-n.js index 2d6af031434..fd914d6fce9 100644 --- a/mozilla/js/tests/ecma_2/FunctionObjects/apply-001-n.js +++ b/mozilla/js/tests/ecma_2/FunctionObjects/apply-001-n.js @@ -38,18 +38,26 @@ * * ***** END LICENSE BLOCK ***** */ -print ("STATUS: f.apply crash test."); +writeLineToLog("STATUS: f.apply crash test."); -print ("BUGNUMBER: 21836"); +writeLineToLog("BUGNUMBER: 21836"); function f () { } -test (); +var SECTION = "apply-001-n"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "f.apply(2,2) doesn't crash"; + +writeHeaderToLog( SECTION + " "+ TITLE); + +DESCRIPTION = "f.apply(2,2) doesn't crash"; +EXPECTED = "error"; + +new TestCase( SECTION, "f.apply(2,2) doesn't crash", "error", eval("f.apply(2,2)") ); + +test(); -function test () -{ - f.apply(2,2); -} diff --git a/mozilla/js/tests/ecma_2/FunctionObjects/browser.js b/mozilla/js/tests/ecma_2/FunctionObjects/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/FunctionObjects/call-1.js b/mozilla/js/tests/ecma_2/FunctionObjects/call-1.js index 9ea9074752f..63c99b0c071 100644 --- a/mozilla/js/tests/ecma_2/FunctionObjects/call-1.js +++ b/mozilla/js/tests/ecma_2/FunctionObjects/call-1.js @@ -1,40 +1,37 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: call-1.js - Section: Function.prototype.call - Description: + File Name: call-1.js + Section: Function.prototype.call + Description: - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "call-1"; - var VERSION = "ECMA_2"; - var TITLE = "Function.prototype.call"; +var SECTION = "call-1"; +var VERSION = "ECMA_2"; +var TITLE = "Function.prototype.call"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +new TestCase( SECTION, + "ToString.call( this, this )", + GLOBAL, + ToString.call( this, this ) ); +new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype )", + "false", + ToString.call( Boolean, Boolean.prototype ) ); - testcases[tc++] = new TestCase( SECTION, - "ToString.call( this, this )", - GLOBAL, - ToString.call( this, this ) ); +new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype.valueOf() )", + "false", + ToString.call( Boolean, Boolean.prototype.valueOf() ) ); - testcases[tc++] = new TestCase( SECTION, - "ToString.call( Boolean, Boolean.prototype )", - "false", - ToString.call( Boolean, Boolean.prototype ) ); - - testcases[tc++] = new TestCase( SECTION, - "ToString.call( Boolean, Boolean.prototype.valueOf() )", - "false", - ToString.call( Boolean, Boolean.prototype.valueOf() ) ); - - test(); +test(); function ToString( obj ) { - return obj +""; -} \ No newline at end of file + return obj +""; +} diff --git a/mozilla/js/tests/ecma_2/FunctionObjects/shell.js b/mozilla/js/tests/ecma_2/FunctionObjects/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/LexicalConventions/browser.js b/mozilla/js/tests/ecma_2/LexicalConventions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/LexicalConventions/regexp-literals-001.js b/mozilla/js/tests/ecma_2/LexicalConventions/regexp-literals-001.js index 6af945bc7c3..1c908f39155 100644 --- a/mozilla/js/tests/ecma_2/LexicalConventions/regexp-literals-001.js +++ b/mozilla/js/tests/ecma_2/LexicalConventions/regexp-literals-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: LexicalConventions/regexp-literals-001.js * ECMA Section: 7.8.5 @@ -7,32 +8,32 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "LexicalConventions/regexp-literals-001.js"; - var VERSION = "ECMA_2"; - var TITLE = "Regular Expression Literals"; +var SECTION = "LexicalConventions/regexp-literals-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "Regular Expression Literals"; - startTest(); +startTest(); - // Regular Expression Literals may not be empty; // should be regarded - // as a comment, not a RegExp literal. +// Regular Expression Literals may not be empty; // should be regarded +// as a comment, not a RegExp literal. - s = //; +s = //; - "passed"; +"passed"; - AddTestCase( - "// should be a comment, not a regular expression literal", - "passed", - String(s)); +AddTestCase( + "// should be a comment, not a regular expression literal", + "passed", + String(s)); - AddTestCase( - "// typeof object should be type of object declared on following line", - "passed", - (typeof s) == "string" ? "passed" : "failed" ); +AddTestCase( + "// typeof object should be type of object declared on following line", + "passed", + (typeof s) == "string" ? "passed" : "failed" ); - AddTestCase( - "// should not return an object of the type RegExp", - "passed", - (typeof s == "object") ? "failed" : "passed" ); +AddTestCase( + "// should not return an object of the type RegExp", + "passed", + (typeof s == "object") ? "failed" : "passed" ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/LexicalConventions/regexp-literals-002.js b/mozilla/js/tests/ecma_2/LexicalConventions/regexp-literals-002.js index c67184b166e..123741b7f04 100644 --- a/mozilla/js/tests/ecma_2/LexicalConventions/regexp-literals-002.js +++ b/mozilla/js/tests/ecma_2/LexicalConventions/regexp-literals-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: LexicalConventions/regexp-literals-002.js * ECMA Section: 7.8.5 @@ -6,17 +7,17 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "LexicalConventions/regexp-literals-002.js"; - var VERSION = "ECMA_2"; - var TITLE = "Regular Expression Literals"; +var SECTION = "LexicalConventions/regexp-literals-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "Regular Expression Literals"; - startTest(); +startTest(); - // A regular expression literal represents an object of type RegExp. +// A regular expression literal represents an object of type RegExp. - AddTestCase( - "// A regular expression literal represents an object of type RegExp.", - "true", - (/x*/ instanceof RegExp).toString() ); +AddTestCase( + "// A regular expression literal represents an object of type RegExp.", + "true", + (/x*/ instanceof RegExp).toString() ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/LexicalConventions/shell.js b/mozilla/js/tests/ecma_2/LexicalConventions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/README b/mozilla/js/tests/ecma_2/README new file mode 100755 index 00000000000..6da6cdd5149 --- /dev/null +++ b/mozilla/js/tests/ecma_2/README @@ -0,0 +1 @@ +ECMA 262 Edition 2 diff --git a/mozilla/js/tests/ecma_2/RegExp/browser.js b/mozilla/js/tests/ecma_2/RegExp/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/RegExp/constructor-001.js b/mozilla/js/tests/ecma_2/RegExp/constructor-001.js index be904e57623..62f9a0686af 100644 --- a/mozilla/js/tests/ecma_2/RegExp/constructor-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/constructor-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/constructor-001.js * ECMA Section: 15.7.3.3 @@ -6,61 +7,61 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/constructor-001"; - var VERSION = "ECMA_2"; - var TITLE = "new RegExp()"; +var SECTION = "RegExp/constructor-001"; +var VERSION = "ECMA_2"; +var TITLE = "new RegExp()"; - startTest(); +startTest(); - /* - * for each test case, verify: - * - verify that [[Class]] property is RegExp - * - prototype property should be set to RegExp.prototype - * - source is set to the empty string - * - global property is set to false - * - ignoreCase property is set to false - * - multiline property is set to false - * - lastIndex property is set to 0 - */ +/* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ - RegExp.prototype.getClassProperty = Object.prototype.toString; - var re = new RegExp(); +RegExp.prototype.getClassProperty = Object.prototype.toString; +var re = new RegExp(); - AddTestCase( - "new RegExp().__proto__", - RegExp.prototype, - re.__proto__ - ); +AddTestCase( + "new RegExp().__proto__", + RegExp.prototype, + re.__proto__ + ); - AddTestCase( - "RegExp.prototype.getClassProperty = Object.prototype.toString; " + - "(new RegExp()).getClassProperty()", - "[object RegExp]", - re.getClassProperty() ); +AddTestCase( + "RegExp.prototype.getClassProperty = Object.prototype.toString; " + + "(new RegExp()).getClassProperty()", + "[object RegExp]", + re.getClassProperty() ); - AddTestCase( - "(new RegExp()).source", - "", - re.source ); +AddTestCase( + "(new RegExp()).source", + "", + re.source ); - AddTestCase( - "(new RegExp()).global", - false, - re.global ); +AddTestCase( + "(new RegExp()).global", + false, + re.global ); - AddTestCase( - "(new RegExp()).ignoreCase", - false, - re.ignoreCase ); +AddTestCase( + "(new RegExp()).ignoreCase", + false, + re.ignoreCase ); - AddTestCase( - "(new RegExp()).multiline", - false, - re.multiline ); +AddTestCase( + "(new RegExp()).multiline", + false, + re.multiline ); - AddTestCase( - "(new RegExp()).lastIndex", - 0, - re.lastIndex ); +AddTestCase( + "(new RegExp()).lastIndex", + 0, + re.lastIndex ); - test() +test() diff --git a/mozilla/js/tests/ecma_2/RegExp/exec-001.js b/mozilla/js/tests/ecma_2/RegExp/exec-001.js index 69edc1103e4..10e139469f2 100644 --- a/mozilla/js/tests/ecma_2/RegExp/exec-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/exec-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/exec-001.js * ECMA Section: 15.7.5.3 @@ -6,29 +7,29 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/exec-001"; - var VERSION = "ECMA_2"; - var TITLE = "RegExp.prototype.exec(string)"; +var SECTION = "RegExp/exec-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp.prototype.exec(string)"; - startTest(); +startTest(); - /* - * for each test case, verify: - * - type of object returned - * - length of the returned array - * - value of lastIndex - * - value of index - * - value of input - * - value of the array indices - */ +/* + * for each test case, verify: + * - type of object returned + * - length of the returned array + * - value of lastIndex + * - value of index + * - value of input + * - value of the array indices + */ - // test cases without subpatterns - // test cases with subpatterns - // global property is true - // global property is false - // test cases in which the exec returns null +// test cases without subpatterns +// test cases with subpatterns +// global property is true +// global property is false +// test cases in which the exec returns null - testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" }; +// testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" }; - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/RegExp/exec-002.js b/mozilla/js/tests/ecma_2/RegExp/exec-002.js index c811b616551..14dfeb3a1d8 100644 --- a/mozilla/js/tests/ecma_2/RegExp/exec-002.js +++ b/mozilla/js/tests/ecma_2/RegExp/exec-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/exec-002.js * ECMA Section: 15.7.5.3 @@ -8,175 +9,175 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/exec-002"; - var VERSION = "ECMA_2"; - var TITLE = "RegExp.prototype.exec(string)"; +var SECTION = "RegExp/exec-002"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp.prototype.exec(string)"; - startTest(); +startTest(); - /* - * for each test case, verify: - * - type of object returned - * - length of the returned array - * - value of lastIndex - * - value of index - * - value of input - * - value of the array indices - */ +/* + * for each test case, verify: + * - type of object returned + * - length of the returned array + * - value of lastIndex + * - value of index + * - value of input + * - value of the array indices + */ - AddRegExpCases( - /(a|d|q|)x/i, - "bcaDxqy", - 3, - ["Dx", "D"] ); +AddRegExpCases( + /(a|d|q|)x/i, + "bcaDxqy", + 3, + ["Dx", "D"] ); - AddRegExpCases( - /(a|(e|q))(x|y)/, - "bcaddxqy", - 6, - ["qy","q","q","y"] ); +AddRegExpCases( + /(a|(e|q))(x|y)/, + "bcaddxqy", + 6, + ["qy","q","q","y"] ); - AddRegExpCases( - /a+b+d/, - "aabbeeaabbs", - 0, - null ); +AddRegExpCases( + /a+b+d/, + "aabbeeaabbs", + 0, + null ); - AddRegExpCases( - /a*b/, - "aaadaabaaa", - 4, - ["aab"] ); +AddRegExpCases( + /a*b/, + "aaadaabaaa", + 4, + ["aab"] ); - AddRegExpCases( - /a*b/, - "dddb", - 3, - ["b"] ); +AddRegExpCases( + /a*b/, + "dddb", + 3, + ["b"] ); - AddRegExpCases( - /a*b/, - "xxx", - 0, - null ); +AddRegExpCases( + /a*b/, + "xxx", + 0, + null ); - AddRegExpCases( - /x\d\dy/, - "abcx45ysss235", - 3, - ["x45y"] ); +AddRegExpCases( + /x\d\dy/, + "abcx45ysss235", + 3, + ["x45y"] ); - AddRegExpCases( - /[^abc]def[abc]+/, - "abxdefbb", - 2, - ["xdefbb"] ); +AddRegExpCases( + /[^abc]def[abc]+/, + "abxdefbb", + 2, + ["xdefbb"] ); - AddRegExpCases( - /(a*)baa/, - "ccdaaabaxaabaa", - 9, - ["aabaa", "aa"] ); +AddRegExpCases( + /(a*)baa/, + "ccdaaabaxaabaa", + 9, + ["aabaa", "aa"] ); - AddRegExpCases( - /(a*)baa/, - "aabaa", - 0, - ["aabaa", "aa"] ); +AddRegExpCases( + /(a*)baa/, + "aabaa", + 0, + ["aabaa", "aa"] ); - AddRegExpCases( - /q(a|b)*q/, - "xxqababqyy", - 2, - ["qababq", "b"] ); +AddRegExpCases( + /q(a|b)*q/, + "xxqababqyy", + 2, + ["qababq", "b"] ); - AddRegExpCases( - /(a(.|[^d])c)*/, - "adcaxc", - 0, - ["adcaxc", "axc", "x"] ); +AddRegExpCases( + /(a(.|[^d])c)*/, + "adcaxc", + 0, + ["adcaxc", "axc", "x"] ); - AddRegExpCases( - /(a*)b\1/, - "abaaaxaabaayy", - 0, - ["aba", "a"] ); +AddRegExpCases( + /(a*)b\1/, + "abaaaxaabaayy", + 0, + ["aba", "a"] ); - AddRegExpCases( - /(a*)b\1/, - "abaaaxaabaayy", - 0, - ["aba", "a"] ); +AddRegExpCases( + /(a*)b\1/, + "abaaaxaabaayy", + 0, + ["aba", "a"] ); - AddRegExpCases( - /(a*)b\1/, - "cccdaaabaxaabaayy", - 6, - ["aba", "a"] ); +AddRegExpCases( + /(a*)b\1/, + "cccdaaabaxaabaayy", + 6, + ["aba", "a"] ); - AddRegExpCases( - /(a*)b\1/, - "cccdaaabqxaabaayy", - 7, - ["b", ""] ); +AddRegExpCases( + /(a*)b\1/, + "cccdaaabqxaabaayy", + 7, + ["b", ""] ); - AddRegExpCases( - /"(.|[^"\\\\])*"/, +AddRegExpCases( + /"(.|[^"\\\\])*"/, 'xx\"makudonarudo\"yy', 2, ["\"makudonarudo\"", "o"] ); AddRegExpCases( /"(.|[^"\\\\])*"/, - "xx\"ma\"yy", - 2, - ["\"ma\"", "a"] ); + "xx\"ma\"yy", + 2, + ["\"ma\"", "a"] ); - test(); +test(); function AddRegExpCases( - regexp, pattern, index, matches_array ) { +regexp, pattern, index, matches_array ) { - // prevent a runtime error +// prevent a runtime error - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); +if ( regexp.exec(pattern) == null || matches_array == null ) { +AddTestCase( +regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); - return; - } - AddTestCase( - regexp + ".exec(" + pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); +return; +} +AddTestCase( +regexp + ".exec(" + pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); - AddTestCase( - regexp + ".exec(" + pattern +").index", - index, - regexp.exec(pattern).index ); +AddTestCase( +regexp + ".exec(" + pattern +").index", + index, + regexp.exec(pattern).index ); - AddTestCase( - regexp + ".exec(" + pattern +").input", - pattern, - regexp.exec(pattern).input ); +AddTestCase( +regexp + ".exec(" + pattern +").input", + pattern, + regexp.exec(pattern).input ); - AddTestCase( - regexp + ".exec(" + pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); +AddTestCase( +regexp + ".exec(" + pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); /* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - regexp + ".exec(" + pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + regexp + ".exec(" + pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } */ } diff --git a/mozilla/js/tests/ecma_2/RegExp/function-001.js b/mozilla/js/tests/ecma_2/RegExp/function-001.js index 67c4f21d493..ceae37fb66c 100644 --- a/mozilla/js/tests/ecma_2/RegExp/function-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/function-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/function-001.js * ECMA Section: 15.7.2.1 @@ -6,61 +7,61 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/function-001"; - var VERSION = "ECMA_2"; - var TITLE = "RegExp( pattern, flags )"; +var SECTION = "RegExp/function-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp( pattern, flags )"; - startTest(); +startTest(); - /* - * for each test case, verify: - * - verify that [[Class]] property is RegExp - * - prototype property should be set to RegExp.prototype - * - source is set to the empty string - * - global property is set to false - * - ignoreCase property is set to false - * - multiline property is set to false - * - lastIndex property is set to 0 - */ +/* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ - RegExp.prototype.getClassProperty = Object.prototype.toString; - var re = new RegExp(); +RegExp.prototype.getClassProperty = Object.prototype.toString; +var re = new RegExp(); - AddTestCase( - "new RegExp().__proto__", - RegExp.prototype, - re.__proto__ - ); +AddTestCase( + "new RegExp().__proto__", + RegExp.prototype, + re.__proto__ + ); - AddTestCase( - "RegExp.prototype.getClassProperty = Object.prototype.toString; " + - "(new RegExp()).getClassProperty()", - "[object RegExp]", - re.getClassProperty() ); +AddTestCase( + "RegExp.prototype.getClassProperty = Object.prototype.toString; " + + "(new RegExp()).getClassProperty()", + "[object RegExp]", + re.getClassProperty() ); - AddTestCase( - "(new RegExp()).source", - "", - re.source ); +AddTestCase( + "(new RegExp()).source", + "", + re.source ); - AddTestCase( - "(new RegExp()).global", - false, - re.global ); +AddTestCase( + "(new RegExp()).global", + false, + re.global ); - AddTestCase( - "(new RegExp()).ignoreCase", - false, - re.ignoreCase ); +AddTestCase( + "(new RegExp()).ignoreCase", + false, + re.ignoreCase ); - AddTestCase( - "(new RegExp()).multiline", - false, - re.multiline ); +AddTestCase( + "(new RegExp()).multiline", + false, + re.multiline ); - AddTestCase( - "(new RegExp()).lastIndex", - 0, - re.lastIndex ); +AddTestCase( + "(new RegExp()).lastIndex", + 0, + re.lastIndex ); - test() +test() diff --git a/mozilla/js/tests/ecma_2/RegExp/hex-001.js b/mozilla/js/tests/ecma_2/RegExp/hex-001.js index 122d59cd3df..6105c4e5d6a 100644 --- a/mozilla/js/tests/ecma_2/RegExp/hex-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/hex-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/hex-001.js * ECMA Section: 15.7.3.1 @@ -6,58 +7,58 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/hex-001"; - var VERSION = "ECMA_2"; - var TITLE = "RegExp patterns that contain HexicdecimalEscapeSequences"; +var SECTION = "RegExp/hex-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp patterns that contain HexicdecimalEscapeSequences"; - startTest(); +startTest(); - // These examples come from 15.7.1, HexidecimalEscapeSequence +// These examples come from 15.7.1, HexidecimalEscapeSequence - AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); - AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); - AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] ); +AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); +AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); +AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] ); - AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); - AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); - AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]); - AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] ); +AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); +AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); +AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]); +AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] ); - test(); +test(); function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - str_regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } + // prevent a runtime error + if ( regexp.exec(pattern) == null || matches_array == null ) { AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - length, - regexp.exec(pattern).length ); + str_regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + return; + } + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/RegExp/multiline-001.js b/mozilla/js/tests/ecma_2/RegExp/multiline-001.js index 51a601cf105..4d337423809 100644 --- a/mozilla/js/tests/ecma_2/RegExp/multiline-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/multiline-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/multiline-001.js * ECMA Section: @@ -6,57 +7,57 @@ * Date: 19 February 1999 */ - var SECTION = "RegExp/multiline-001"; - var VERSION = "ECMA_2"; - var TITLE = "RegExp: multiline flag"; - var BUGNUMBER="343901"; +var SECTION = "RegExp/multiline-001"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp: multiline flag"; +var BUGNUMBER="343901"; - startTest(); +startTest(); - var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" + - "northern flicker\npileated\n"; +var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" + +"northern flicker\npileated\n"; - AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] ); +AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] ); - AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] ); +AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] ); - test(); +test(); function AddRegExpCases - ( regexp, pattern, index, matches_array ) { +( regexp, pattern, index, matches_array ) { - // prevent a runtime error - - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } + // prevent a runtime error + if ( regexp.exec(pattern) == null || matches_array == null ) { AddTestCase( - regexp.toString() + ".exec(" + pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); + regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + return; + } + + AddTestCase( + regexp.toString() + ".exec(" + pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + regexp.toString() + ".exec(" + pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + regexp + ".exec(" + pattern +").input", + pattern, + regexp.exec(pattern).input ); + + + for ( var matches = 0; matches < matches_array.length; matches++ ) { AddTestCase( - regexp.toString() + ".exec(" + pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - regexp + ".exec(" + pattern +").input", - pattern, - regexp.exec(pattern).input ); - - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - regexp + ".exec(" + pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } + regexp + ".exec(" + pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/RegExp/octal-001.js b/mozilla/js/tests/ecma_2/RegExp/octal-001.js index d9d0571639d..d6b4a0afa39 100644 --- a/mozilla/js/tests/ecma_2/RegExp/octal-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/octal-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/octal-001.js * ECMA Section: 15.7.1 @@ -6,67 +7,67 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/octal-001.js"; - var VERSION = "ECMA_2"; - var TITLE = "RegExp patterns that contain OctalEscapeSequences"; - var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196"; +var SECTION = "RegExp/octal-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp patterns that contain OctalEscapeSequences"; +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196"; - startTest(); +startTest(); // backreference - AddRegExpCases( - /(.)\1/, - "/(.)\\1/", - "HI!!", - "HI!", - 2, - ["!!", "!"] ); +AddRegExpCases( + /(.)\1/, + "/(.)\\1/", + "HI!!", + "HI!", + 2, + ["!!", "!"] ); - test(); +test(); function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - // prevent a runtime error + // prevent a runtime error - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } + if ( regexp.exec(pattern) == null || matches_array == null ) { AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); /* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } */ } diff --git a/mozilla/js/tests/ecma_2/RegExp/octal-002.js b/mozilla/js/tests/ecma_2/RegExp/octal-002.js index 69c810066e7..8339b61afc5 100644 --- a/mozilla/js/tests/ecma_2/RegExp/octal-002.js +++ b/mozilla/js/tests/ecma_2/RegExp/octal-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/octal-002.js * ECMA Section: 15.7.1 @@ -6,82 +7,82 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/octal-002.js"; - var VERSION = "ECMA_2"; - var TITLE = "RegExp patterns that contain OctalEscapeSequences"; - var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; +var SECTION = "RegExp/octal-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp patterns that contain OctalEscapeSequences"; +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; - startTest(); +startTest(); // backreference - AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)\8/, - "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", - "aabbccaaabbbccc", - "aabbccaaabbbccc", - 0, - ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); +AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)\8/, + "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", + "aabbccaaabbbccc", + "aabbccaaabbbccc", + 0, + ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); - AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, - "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", - "aabbccaabbcc", - "aabbccaabbcc", - 0, - ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); +AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, + "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", + "aabbccaabbcc", + "aabbccaabbcc", + 0, + ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); - AddRegExpCases( - /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, - "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", - "aabbccaababcc", - "aabbccaababcc", - 0, - ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); +AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, + "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", + "aabbccaababcc", + "aabbccaababcc", + 0, + ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); - test(); +test(); function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - // prevent a runtime error + // prevent a runtime error - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } + if ( regexp.exec(pattern) == null || matches_array == null ) { AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); - AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - regexp.exec(pattern).toString() ); + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); /* - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } */ } diff --git a/mozilla/js/tests/ecma_2/RegExp/octal-003.js b/mozilla/js/tests/ecma_2/RegExp/octal-003.js index ac6de01e88d..cc512f36af1 100644 --- a/mozilla/js/tests/ecma_2/RegExp/octal-003.js +++ b/mozilla/js/tests/ecma_2/RegExp/octal-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/octal-003.js * ECMA Section: 15.7.1 @@ -23,59 +24,59 @@ * See the testcase ecma_3/RegExp/octal-002.js for an elaboration. * */ - var SECTION = "RegExp/octal-003.js"; - var VERSION = "ECMA_2"; - var TITLE = "RegExp patterns that contain OctalEscapeSequences"; - var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346132"; +var SECTION = "RegExp/octal-003.js"; +var VERSION = "ECMA_2"; +var TITLE = "RegExp patterns that contain OctalEscapeSequences"; +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346132"; - startTest(); +startTest(); - AddRegExpCases( /.\011/, "/\\011/", "a" + String.fromCharCode(0) + "11", "a\\011", 0, null ); +AddRegExpCases( /.\011/, "/\\011/", "a" + String.fromCharCode(0) + "11", "a\\011", 0, null ); - test(); +test(); function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { - // prevent a runtime error + // prevent a runtime error - if ( regexp.exec(pattern) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + str_pattern +")", - matches_array, - regexp.exec(pattern) ); - - return; - } + if ( regexp.exec(pattern) == null || matches_array == null ) { AddTestCase( - str_regexp + ".exec(" + str_pattern +").length", - matches_array.length, - regexp.exec(pattern).length ); + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + escape(pattern), + escape(regexp.exec(pattern).input) ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + escape(regexp.exec(pattern).toString()) ); + + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { AddTestCase( - str_regexp + ".exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").input", - escape(pattern), - escape(regexp.exec(pattern).input) ); - - AddTestCase( - str_regexp + ".exec(" + str_pattern +").toString()", - matches_array.toString(), - escape(regexp.exec(pattern).toString()) ); - - var limit = matches_array.length > regexp.exec(pattern).length - ? matches_array.length - : regexp.exec(pattern).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - str_regexp + ".exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - escape(regexp.exec(pattern)[matches]) ); - } + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + escape(regexp.exec(pattern)[matches]) ); + } } diff --git a/mozilla/js/tests/ecma_2/RegExp/properties-001.js b/mozilla/js/tests/ecma_2/RegExp/properties-001.js index 57638b6ed3e..b01325f609e 100644 --- a/mozilla/js/tests/ecma_2/RegExp/properties-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/properties-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/properties-001.js * ECMA Section: 15.7.6.js @@ -6,80 +7,80 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/properties-001.js"; - var VERSION = "ECMA_2"; - var TITLE = "Properties of RegExp Instances"; - var BUGNUMBER ="http://scopus/bugsplat/show_bug.cgi?id=346000"; +var SECTION = "RegExp/properties-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "Properties of RegExp Instances"; +var BUGNUMBER ="http://scopus/bugsplat/show_bug.cgi?id=346000"; - startTest(); +startTest(); - AddRegExpCases( new RegExp, "", false, false, false, 0 ); - AddRegExpCases( /.*/, ".*", false, false, false, 0 ); - AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); - AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); - AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); - AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); - AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); - AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); +AddRegExpCases( new RegExp, "", false, false, false, 0 ); +AddRegExpCases( /.*/, ".*", false, false, false, 0 ); +AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); +AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); +AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); +AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); +AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); +AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); - AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); - AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); - AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); +AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); +AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); +AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); - test(); +test(); function AddRegExpCases( re, s, g, i, m, l ) { - AddTestCase( re + ".test == RegExp.prototype.test", - true, - re.test == RegExp.prototype.test ); + AddTestCase( re + ".test == RegExp.prototype.test", + true, + re.test == RegExp.prototype.test ); - AddTestCase( re + ".toString == RegExp.prototype.toString", - true, - re.toString == RegExp.prototype.toString ); + AddTestCase( re + ".toString == RegExp.prototype.toString", + true, + re.toString == RegExp.prototype.toString ); - AddTestCase( re + ".contructor == RegExp.prototype.constructor", - true, - re.constructor == RegExp.prototype.constructor ); + AddTestCase( re + ".contructor == RegExp.prototype.constructor", + true, + re.constructor == RegExp.prototype.constructor ); - AddTestCase( re + ".compile == RegExp.prototype.compile", - true, - re.compile == RegExp.prototype.compile ); + AddTestCase( re + ".compile == RegExp.prototype.compile", + true, + re.compile == RegExp.prototype.compile ); - AddTestCase( re + ".exec == RegExp.prototype.exec", - true, - re.exec == RegExp.prototype.exec ); + AddTestCase( re + ".exec == RegExp.prototype.exec", + true, + re.exec == RegExp.prototype.exec ); - // properties + // properties - AddTestCase( re + ".source", - s, - re.source ); + AddTestCase( re + ".source", + s, + re.source ); /* * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed * the behavior of toString() and toSource() on empty regexps. * So branch if |s| is the empty string - */ -var S = s? s : '(?:)'; + var S = s? s : '(?:)'; - AddTestCase( re + ".toString()", - "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), - re.toString() ); + AddTestCase( re + ".toString()", + "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), + re.toString() ); - AddTestCase( re + ".global", - g, - re.global ); + AddTestCase( re + ".global", + g, + re.global ); - AddTestCase( re + ".ignoreCase", - i, - re.ignoreCase ); + AddTestCase( re + ".ignoreCase", + i, + re.ignoreCase ); - AddTestCase( re + ".multiline", - m, - re.multiline); + AddTestCase( re + ".multiline", + m, + re.multiline); - AddTestCase( re + ".lastIndex", - l, - re.lastIndex ); + AddTestCase( re + ".lastIndex", + l, + re.lastIndex ); } diff --git a/mozilla/js/tests/ecma_2/RegExp/properties-002.js b/mozilla/js/tests/ecma_2/RegExp/properties-002.js index 2496d5fe3e2..78f52fa7941 100644 --- a/mozilla/js/tests/ecma_2/RegExp/properties-002.js +++ b/mozilla/js/tests/ecma_2/RegExp/properties-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/properties-002.js * ECMA Section: 15.7.6.js @@ -6,7 +7,7 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - //----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- var SECTION = "RegExp/properties-002.js"; var VERSION = "ECMA_2"; var TITLE = "Properties of RegExp Instances"; @@ -77,49 +78,49 @@ test(); function AddRegExpCases( re, s, g, i, m, l ){ - AddTestCase( re + ".test == RegExp.prototype.test", - true, - re.test == RegExp.prototype.test ); + AddTestCase( re + ".test == RegExp.prototype.test", + true, + re.test == RegExp.prototype.test ); - AddTestCase( re + ".toString == RegExp.prototype.toString", - true, - re.toString == RegExp.prototype.toString ); + AddTestCase( re + ".toString == RegExp.prototype.toString", + true, + re.toString == RegExp.prototype.toString ); - AddTestCase( re + ".contructor == RegExp.prototype.constructor", - true, - re.constructor == RegExp.prototype.constructor ); + AddTestCase( re + ".contructor == RegExp.prototype.constructor", + true, + re.constructor == RegExp.prototype.constructor ); - AddTestCase( re + ".compile == RegExp.prototype.compile", - true, - re.compile == RegExp.prototype.compile ); + AddTestCase( re + ".compile == RegExp.prototype.compile", + true, + re.compile == RegExp.prototype.compile ); - AddTestCase( re + ".exec == RegExp.prototype.exec", - true, - re.exec == RegExp.prototype.exec ); + AddTestCase( re + ".exec == RegExp.prototype.exec", + true, + re.exec == RegExp.prototype.exec ); - // properties + // properties - AddTestCase( re + ".source", - s, - re.source ); + AddTestCase( re + ".source", + s, + re.source ); - AddTestCase( re + ".toString()", - "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), - re.toString() ); + AddTestCase( re + ".toString()", + "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), + re.toString() ); - AddTestCase( re + ".global", - g, - re.global ); + AddTestCase( re + ".global", + g, + re.global ); - AddTestCase( re + ".ignoreCase", - i, - re.ignoreCase ); + AddTestCase( re + ".ignoreCase", + i, + re.ignoreCase ); - AddTestCase( re + ".multiline", - m, - re.multiline); + AddTestCase( re + ".multiline", + m, + re.multiline); - AddTestCase( re + ".lastIndex", - l, - re.lastIndex ); + AddTestCase( re + ".lastIndex", + l, + re.lastIndex ); } diff --git a/mozilla/js/tests/ecma_2/RegExp/regexp-enumerate-001.js b/mozilla/js/tests/ecma_2/RegExp/regexp-enumerate-001.js index 9752fa1cdef..1106f8b63b3 100644 --- a/mozilla/js/tests/ecma_2/RegExp/regexp-enumerate-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/regexp-enumerate-001.js @@ -1,98 +1,83 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** - File Name: regexp-enumerate-001.js - ECMA V2 Section: - Description: Regression Test. + File Name: regexp-enumerate-001.js + ECMA V2 Section: + Description: Regression Test. - If instance Native Object have properties that are enumerable, - JavaScript enumerated through the properties twice. This only - happened if objects had been instantiated, but their properties - had not been enumerated. ie, the object inherited properties - from its prototype that are enumerated. + If instance Native Object have properties that are enumerable, + JavaScript enumerated through the properties twice. This only + happened if objects had been instantiated, but their properties + had not been enumerated. ie, the object inherited properties + from its prototype that are enumerated. - In the core JavaScript, this is only a problem with RegExp - objects, since the inherited properties of most core JavaScript - objects are not enumerated. + In the core JavaScript, this is only a problem with RegExp + objects, since the inherited properties of most core JavaScript + objects are not enumerated. - Author: christine@netscape.com, pschwartau@netscape.com - Date: 12 November 1997 - Modified: 14 July 2002 - Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291 - ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5 - RegExp properties should be DontEnum -* -*/ + Author: christine@netscape.com, pschwartau@netscape.com + Date: 12 November 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291 + ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5 + RegExp properties should be DontEnum + * + */ // onerror = err; - var SECTION = "regexp-enumerate-001"; - var VERSION = "ECMA_2"; - var TITLE = "Regression Test for Enumerating Properties"; +var SECTION = "regexp-enumerate-001"; +var VERSION = "ECMA_2"; +var TITLE = "Regression Test for Enumerating Properties"; - var BUGNUMBER="339403"; +var BUGNUMBER="339403"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - - /* - * This test expects RegExp instances to have four enumerated properties: - * source, global, ignoreCase, and lastIndex - * - * 99.01.25: now they also have a multiLine instance property. - * - */ +/* + * This test expects RegExp instances to have four enumerated properties: + * source, global, ignoreCase, and lastIndex + * + * 99.01.25: now they also have a multiLine instance property. + * + */ - var r = new RegExp(); +var r = new RegExp(); - var e = new Array(); +var e = new Array(); - var t = new TestRegExp(); +var t = new TestRegExp(); - for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) }; +for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) }; - testcases[testcases.length] = new TestCase( SECTION, - "r = new RegExp(); e = new Array(); "+ - "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length", - 0, - e.length ); +new TestCase( SECTION, + "r = new RegExp(); e = new Array(); "+ + "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length", + 0, + e.length ); - test(); +test(); function TestRegExp() { - this.addProperty = addProperty; + this.addProperty = addProperty; } function addProperty(name, value) { - var pass = false; + var pass = false; - if ( eval("this."+name) != void 0 ) { - pass = true; - } else { - eval( "this."+ name+" = "+ false ); - } + if ( eval("this."+name) != void 0 ) { + pass = true; + } else { + eval( "this."+ name+" = "+ false ); + } - testcases[testcases.length] = new TestCase( SECTION, - "Property: " + name +" already enumerated?", - false, - pass ); + new TestCase( SECTION, + "Property: " + name +" already enumerated?", + false, + pass ); - if ( testcases[ testcases.length-1].passed == false ) { - testcases[testcases.length-1].reason = "property already enumerated"; + if ( testcases[ testcases.length-1].passed == false ) { + testcases[testcases.length-1].reason = "property already enumerated"; - } + } } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma_2/RegExp/regress-001.js b/mozilla/js/tests/ecma_2/RegExp/regress-001.js index afd45fe0339..059d650f2ee 100644 --- a/mozilla/js/tests/ecma_2/RegExp/regress-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/regress-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/regress-001.js * ECMA Section: N/A @@ -8,32 +9,32 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/hex-001.js"; - var VERSION = "ECMA_2"; - var TITLE = "JS regexp anchoring on empty match bug"; - var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=2157"; +var SECTION = "RegExp/hex-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "JS regexp anchoring on empty match bug"; +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=2157"; - startTest(); +startTest(); - AddRegExpCases( /a||b/(''), - "//a||b/('')", - 1, - [''] ); +AddRegExpCases( /a||b/(''), + "//a||b/('')", + 1, + [''] ); - test(); +test(); function AddRegExpCases( regexp, str_regexp, length, matches_array ) { + AddTestCase( + "( " + str_regexp + " ).length", + regexp.length, + regexp.length ); + + + for ( var matches = 0; matches < matches_array.length; matches++ ) { AddTestCase( - "( " + str_regexp + " ).length", - regexp.length, - regexp.length ); - - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + str_regexp + " )[" + matches +"]", - matches_array[matches], - regexp[matches] ); - } + "( " + str_regexp + " )[" + matches +"]", + matches_array[matches], + regexp[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/RegExp/shell.js b/mozilla/js/tests/ecma_2/RegExp/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/RegExp/unicode-001.js b/mozilla/js/tests/ecma_2/RegExp/unicode-001.js index 17d05824568..bc2fd5773e3 100644 --- a/mozilla/js/tests/ecma_2/RegExp/unicode-001.js +++ b/mozilla/js/tests/ecma_2/RegExp/unicode-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: RegExp/unicode-001.js * ECMA Section: 15.7.3.1 @@ -6,48 +7,48 @@ * Author: christine@netscape.com * Date: 19 February 1999 */ - var SECTION = "RegExp/unicode-001.js"; - var VERSION = "ECMA_2"; - var TITLE = "new RegExp( pattern, flags )"; +var SECTION = "RegExp/unicode-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "new RegExp( pattern, flags )"; - startTest(); +startTest(); - // These examples come from 15.7.1, UnicodeEscapeSequence +// These examples come from 15.7.1, UnicodeEscapeSequence - AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] ); - AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); - AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); - AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] ); +AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] ); +AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); +AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); +AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] ); - AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] ); - AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] ); - AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]); - AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] ); +AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] ); +AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] ); +AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]); +AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] ); - test(); +test(); function AddRegExpCases( - regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + AddTestCase( + str_regexp + " .exec(" + str_pattern +").length", + length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { AddTestCase( - str_regexp + " .exec(" + str_pattern +").length", - length, - regexp.exec(pattern).length ); - - AddTestCase( - str_regexp + " .exec(" + str_pattern +").index", - index, - regexp.exec(pattern).index ); - - AddTestCase( - str_regexp + " .exec(" + str_pattern +").input", - pattern, - regexp.exec(pattern).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - str_regexp + " .exec(" + str_pattern +")[" + matches +"]", - matches_array[matches], - regexp.exec(pattern)[matches] ); - } + str_regexp + " .exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/Statements/browser.js b/mozilla/js/tests/ecma_2/Statements/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/Statements/dowhile-001.js b/mozilla/js/tests/ecma_2/Statements/dowhile-001.js index ffd53009b2c..c4d5ce11d63 100644 --- a/mozilla/js/tests/ecma_2/Statements/dowhile-001.js +++ b/mozilla/js/tests/ecma_2/Statements/dowhile-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: dowhile-001 * ECMA Section: @@ -8,34 +9,31 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "dowhile-002"; - var VERSION = "ECMA_2"; - var TITLE = "do...while with a labeled continue statement"; +var SECTION = "dowhile-002"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +LabeledContinue( 0, 1 ); +LabeledContinue( 1, 1 ); +LabeledContinue( -1, 1 ); +LabeledContinue( 5, 5 ); - LabeledContinue( 0, 1 ); - LabeledContinue( 1, 1 ); - LabeledContinue( -1, 1 ); - LabeledContinue( 5, 5 ); - - test(); +test(); function LabeledContinue( limit, expect ) { - i = 0; - woohoo: - do { - i++; - continue woohoo; - } while ( i < limit ); + i = 0; +woohoo: + do { + i++; + continue woohoo; + } while ( i < limit ); - testcases[tc++] = new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); + new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); } diff --git a/mozilla/js/tests/ecma_2/Statements/dowhile-002.js b/mozilla/js/tests/ecma_2/Statements/dowhile-002.js index e921b49f005..1d6c84928fc 100644 --- a/mozilla/js/tests/ecma_2/Statements/dowhile-002.js +++ b/mozilla/js/tests/ecma_2/Statements/dowhile-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: dowhile-002 * ECMA Section: @@ -10,59 +11,56 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "dowhile-002"; - var VERSION = "ECMA_2"; - var TITLE = "do...while with a labeled continue statement"; +var SECTION = "dowhile-002"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +LabeledContinue( 0, 1 ); +LabeledContinue( 1, 1 ); +LabeledContinue( -1, 1 ); +LabeledContinue( 5, 5 ); - LabeledContinue( 0, 1 ); - LabeledContinue( 1, 1 ); - LabeledContinue( -1, 1 ); - LabeledContinue( 5, 5 ); +test(); - test(); - -// The labeled statment contains statements after the labeled break. +// The labeled statement contains statements after the labeled break. // Verify that the statements after the break are not executed. function LabeledContinue( limit, expect ) { - i = 0; - result1 = "pass"; - result2 = "pass"; + i = 0; + result1 = "pass"; + result2 = "pass"; - woohoo: { - do { - i++; - if ( ! (i < limit) ) { - break woohoo; - result1 = "fail: evaluated statement after a labeled break"; - } - } while ( true ); +woohoo: { + do { + i++; + if ( ! (i < limit) ) { + break woohoo; + result1 = "fail: evaluated statement after a labeled break"; + } + } while ( true ); - result2 = "failed: broke out of loop, but not out of labeled block"; - } + result2 = "failed: broke out of loop, but not out of labeled block"; + } - testcases[tc++] = new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); + new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); - testcases[tc++] = new TestCase( - SECTION, - "breaking out of a do... while loop", - "pass", - result1 ); + new TestCase( + SECTION, + "breaking out of a do... while loop", + "pass", + result1 ); - testcases[tc++] = new TestCase( - SECTION, - "breaking out of a labeled do...while loop", - "pass", - result2 ); + new TestCase( + SECTION, + "breaking out of a labeled do...while loop", + "pass", + result2 ); } diff --git a/mozilla/js/tests/ecma_2/Statements/dowhile-003.js b/mozilla/js/tests/ecma_2/Statements/dowhile-003.js index a1ca517d911..fee66f2a477 100644 --- a/mozilla/js/tests/ecma_2/Statements/dowhile-003.js +++ b/mozilla/js/tests/ecma_2/Statements/dowhile-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: dowhile-003 * ECMA Section: @@ -9,52 +10,49 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "dowhile-003"; - var VERSION = "ECMA_2"; - var TITLE = "do...while with a labeled continue statement"; +var SECTION = "dowhile-003"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DoWhile( new DoWhileObject( 1, 1, 0 )); +DoWhile( new DoWhileObject( 1000, 1000, 0 )); +DoWhile( new DoWhileObject( 1001, 1001, 0 )); +DoWhile( new DoWhileObject( 1002, 1001, 1 )); +DoWhile( new DoWhileObject( -1, 1001, -1002 )); - DoWhile( new DoWhileObject( 1, 1, 0 )); - DoWhile( new DoWhileObject( 1000, 1000, 0 )); - DoWhile( new DoWhileObject( 1001, 1001, 0 )); - DoWhile( new DoWhileObject( 1002, 1001, 1 )); - DoWhile( new DoWhileObject( -1, 1001, -1002 )); - - test(); +test(); function DoWhileObject( value, iterations, endvalue ) { - this.value = value; - this.iterations = iterations; - this.endvalue = endvalue; + this.value = value; + this.iterations = iterations; + this.endvalue = endvalue; } function DoWhile( object ) { - var i = 0; + var i = 0; - do { - object.value = --object.value; - i++; - if ( i > 1000 ) - break; - } while( object.value ); + do { + object.value = --object.value; + i++; + if ( i > 1000 ) + break; + } while( object.value ); - testcases[tc++] = new TestCase( - SECTION, - "loop iterations", - object.iterations, - i + new TestCase( + SECTION, + "loop iterations", + object.iterations, + i ); - testcases[tc++] = new TestCase( - SECTION, - "object.value", - object.endvalue, - Number( object.value ) + new TestCase( + SECTION, + "object.value", + object.endvalue, + Number( object.value ) ); -} \ No newline at end of file +} diff --git a/mozilla/js/tests/ecma_2/Statements/dowhile-004.js b/mozilla/js/tests/ecma_2/Statements/dowhile-004.js index 3c96fc48ccb..e75a380a654 100644 --- a/mozilla/js/tests/ecma_2/Statements/dowhile-004.js +++ b/mozilla/js/tests/ecma_2/Statements/dowhile-004.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: dowhile-004 * ECMA Section: @@ -9,56 +10,53 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "dowhile-004"; - var VERSION = "ECMA_2"; - var TITLE = "do...while with a labeled continue statement"; +var SECTION = "dowhile-004"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DoWhile( 0, 1 ); +DoWhile( 1, 1 ); +DoWhile( -1, 1 ); +DoWhile( 5, 5 ); - DoWhile( 0, 1 ); - DoWhile( 1, 1 ); - DoWhile( -1, 1 ); - DoWhile( 5, 5 ); - - test(); +test(); function DoWhile( limit, expect ) { - i = 0; - result1 = "pass"; - result2 = "failed: broke out of labeled statement unexpectedly"; + i = 0; + result1 = "pass"; + result2 = "failed: broke out of labeled statement unexpectedly"; - foo: { - do { - i++; - if ( ! (i < limit) ) { - break; - result1 = "fail: evaluated statement after a labeled break"; - } - } while ( true ); +foo: { + do { + i++; + if ( ! (i < limit) ) { + break; + result1 = "fail: evaluated statement after a labeled break"; + } + } while ( true ); - result2 = "pass"; - } + result2 = "pass"; + } - testcases[tc++] = new TestCase( - SECTION, - "do while ( " + i +" < " + limit +" )", - expect, - i ); + new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); - testcases[tc++] = new TestCase( - SECTION, - "breaking out of a do... while loop", - "pass", - result1 ); + new TestCase( + SECTION, + "breaking out of a do... while loop", + "pass", + result1 ); - testcases[tc++] = new TestCase( - SECTION, - "breaking out of a labeled do...while loop", - "pass", - result2 ); + new TestCase( + SECTION, + "breaking out of a labeled do...while loop", + "pass", + result2 ); } diff --git a/mozilla/js/tests/ecma_2/Statements/dowhile-005.js b/mozilla/js/tests/ecma_2/Statements/dowhile-005.js index ce56cb9942a..a08da1aba61 100644 --- a/mozilla/js/tests/ecma_2/Statements/dowhile-005.js +++ b/mozilla/js/tests/ecma_2/Statements/dowhile-005.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: dowhile-005 * ECMA Section: @@ -12,59 +13,56 @@ * Author: christine@netscape.com * Date: 26 August 1998 */ - var SECTION = "dowhile-005"; - var VERSION = "ECMA_2"; - var TITLE = "do...while with a labeled continue statement"; - var BUGNUMBER = "316293"; +var SECTION = "dowhile-005"; +var VERSION = "ECMA_2"; +var TITLE = "do...while with a labeled continue statement"; +var BUGNUMBER = "316293"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - - NestedLabel(); +NestedLabel(); - test(); +test(); - function NestedLabel() { - i = 0; - result1 = "pass"; - result2 = "fail: did not hit code after inner loop"; - result3 = "pass"; +function NestedLabel() { + i = 0; + result1 = "pass"; + result2 = "fail: did not hit code after inner loop"; + result3 = "pass"; - outer: { - do { - inner: { +outer: { + do { + inner: { // print( i ); - break inner; - result1 = "fail: did break out of inner label"; - } - result2 = "pass"; - break outer; - print (i); - } while ( i++ < 100 ); + break inner; + result1 = "fail: did break out of inner label"; + } + result2 = "pass"; + break outer; + writeLineToLog(i); + } while ( i++ < 100 ); - } + } - result3 = "fail: did not break out of outer label"; + result3 = "fail: did not break out of outer label"; - testcases[tc++] = new TestCase( - SECTION, - "number of loop iterations", - 0, - i ); + new TestCase( + SECTION, + "number of loop iterations", + 0, + i ); - testcases[tc++] = new TestCase( - SECTION, - "break out of inner loop", - "pass", - result1 ); + new TestCase( + SECTION, + "break out of inner loop", + "pass", + result1 ); - testcases[tc++] = new TestCase( - SECTION, - "break out of outer loop", - "pass", - result2 ); - } \ No newline at end of file + new TestCase( + SECTION, + "break out of outer loop", + "pass", + result2 ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/dowhile-006.js b/mozilla/js/tests/ecma_2/Statements/dowhile-006.js index 67dce64f3a6..2c2709c04f7 100644 --- a/mozilla/js/tests/ecma_2/Statements/dowhile-006.js +++ b/mozilla/js/tests/ecma_2/Statements/dowhile-006.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: dowhile-006 * ECMA Section: @@ -8,79 +9,76 @@ * Author: christine@netscape.com * Date: 26 August 1998 */ - var SECTION = "dowhile-006"; - var VERSION = "ECMA_2"; - var TITLE = "do...while"; +var SECTION = "dowhile-006"; +var VERSION = "ECMA_2"; +var TITLE = "do...while"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DoWhile( new DoWhileObject( false, false, 10 ) ); +DoWhile( new DoWhileObject( true, false, 2 ) ); +DoWhile( new DoWhileObject( false, true, 3 ) ); +DoWhile( new DoWhileObject( true, true, 4 ) ); - DoWhile( new DoWhileObject( false, false, 10 ) ); - DoWhile( new DoWhileObject( true, false, 2 ) ); - DoWhile( new DoWhileObject( false, true, 3 ) ); - DoWhile( new DoWhileObject( true, true, 4 ) ); - - test(); +test(); function looping( object ) { - object.iterations--; + object.iterations--; - if ( object.iterations <= 0 ) { - return false; - } else { - return true; - } + if ( object.iterations <= 0 ) { + return false; + } else { + return true; + } } function DoWhileObject( breakOut, breakIn, iterations, loops ) { - this.iterations = iterations; - this.loops = loops; - this.breakOut = breakOut; - this.breakIn = breakIn; - this.looping = looping; + this.iterations = iterations; + this.loops = loops; + this.breakOut = breakOut; + this.breakIn = breakIn; + this.looping = looping; } function DoWhile( object ) { - var result1 = false; - var result2 = false; + var result1 = false; + var result2 = false; - outie: { - innie: { - do { - if ( object.breakOut ) - break outie; +outie: { +innie: { + do { + if ( object.breakOut ) + break outie; - if ( object.breakIn ) - break innie; + if ( object.breakIn ) + break innie; - } while ( looping(object) ); + } while ( looping(object) ); - // statements should be executed if: - // do...while exits normally - // do...while exits abruptly with no label + // statements should be executed if: + // do...while exits normally + // do...while exits abruptly with no label - result1 = true; + result1 = true; - } - - // statements should be executed if: - // do...while breaks out with label "innie" - // do...while exits normally - // do...while does not break out with "outie" - - result2 = true; - } - - testcases[tc++] = new TestCase( - SECTION, - "hit code after loop in inner loop", - ( object.breakIn || object.breakOut ) ? false : true , - result1 ); - - testcases[tc++] = new TestCase( - SECTION, - "hit code after loop in outer loop", - ( object.breakOut ) ? false : true, - result2 ); +} + +// statements should be executed if: +// do...while breaks out with label "innie" +// do...while exits normally +// do...while does not break out with "outie" + +result2 = true; + } + + new TestCase( + SECTION, + "hit code after loop in inner loop", + ( object.breakIn || object.breakOut ) ? false : true , + result1 ); + + new TestCase( + SECTION, + "hit code after loop in outer loop", + ( object.breakOut ) ? false : true, + result2 ); } diff --git a/mozilla/js/tests/ecma_2/Statements/dowhile-007.js b/mozilla/js/tests/ecma_2/Statements/dowhile-007.js index 849e70e1247..b56a632112a 100644 --- a/mozilla/js/tests/ecma_2/Statements/dowhile-007.js +++ b/mozilla/js/tests/ecma_2/Statements/dowhile-007.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: dowhile-007 * ECMA Section: @@ -8,87 +9,84 @@ * Author: christine@netscape.com * Date: 26 August 1998 */ - var SECTION = "dowhile-007"; - var VERSION = "ECMA_2"; - var TITLE = "do...while"; +var SECTION = "dowhile-007"; +var VERSION = "ECMA_2"; +var TITLE = "do...while"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DoWhile( new DoWhileObject( false, false, false, false )); +DoWhile( new DoWhileObject( true, false, false, false )); +DoWhile( new DoWhileObject( true, true, false, false )); +DoWhile( new DoWhileObject( true, true, true, false )); +DoWhile( new DoWhileObject( true, true, true, true )); +DoWhile( new DoWhileObject( false, false, false, true )); +DoWhile( new DoWhileObject( false, false, true, true )); +DoWhile( new DoWhileObject( false, true, true, true )); +DoWhile( new DoWhileObject( false, false, true, false )); - DoWhile( new DoWhileObject( false, false, false, false )); - DoWhile( new DoWhileObject( true, false, false, false )); - DoWhile( new DoWhileObject( true, true, false, false )); - DoWhile( new DoWhileObject( true, true, true, false )); - DoWhile( new DoWhileObject( true, true, true, true )); - DoWhile( new DoWhileObject( false, false, false, true )); - DoWhile( new DoWhileObject( false, false, true, true )); - DoWhile( new DoWhileObject( false, true, true, true )); - DoWhile( new DoWhileObject( false, false, true, false )); - - test(); +test(); function DoWhileObject( out1, out2, out3, in1 ) { - this.breakOutOne = out1; - this.breakOutTwo = out2; - this.breakOutThree = out3; - this.breakIn = in1; + this.breakOutOne = out1; + this.breakOutTwo = out2; + this.breakOutThree = out3; + this.breakIn = in1; } function DoWhile( object ) { - result1 = false; - result2 = false; - result3 = false; - result4 = false; + result1 = false; + result2 = false; + result3 = false; + result4 = false; - outie: - do { - if ( object.breakOutOne ) { - break outie; - } - result1 = true; +outie: + do { + if ( object.breakOutOne ) { + break outie; + } + result1 = true; - innie: - do { - if ( object.breakOutTwo ) { - break outie; - } - result2 = true; + innie: + do { + if ( object.breakOutTwo ) { + break outie; + } + result2 = true; - if ( object.breakIn ) { - break innie; - } - result3 = true; + if ( object.breakIn ) { + break innie; + } + result3 = true; - } while ( false ); - if ( object.breakOutThree ) { - break outie; - } - result4 = true; - } while ( false ); + } while ( false ); + if ( object.breakOutThree ) { + break outie; + } + result4 = true; + } while ( false ); - testcases[tc++] = new TestCase( - SECTION, - "break one: ", - (object.breakOutOne) ? false : true, - result1 ); + new TestCase( + SECTION, + "break one: ", + (object.breakOutOne) ? false : true, + result1 ); - testcases[tc++] = new TestCase( - SECTION, - "break two: ", - (object.breakOutOne||object.breakOutTwo) ? false : true, - result2 ); + new TestCase( + SECTION, + "break two: ", + (object.breakOutOne||object.breakOutTwo) ? false : true, + result2 ); - testcases[tc++] = new TestCase( - SECTION, - "break three: ", - (object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true, - result3 ); + new TestCase( + SECTION, + "break three: ", + (object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true, + result3 ); - testcases[tc++] = new TestCase( - SECTION, - "break four: ", - (object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true, - result4 ); + new TestCase( + SECTION, + "break four: ", + (object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true, + result4 ); } diff --git a/mozilla/js/tests/ecma_2/Statements/forin-001.js b/mozilla/js/tests/ecma_2/Statements/forin-001.js index 63119af6e38..3745888e67b 100644 --- a/mozilla/js/tests/ecma_2/Statements/forin-001.js +++ b/mozilla/js/tests/ecma_2/Statements/forin-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: forin-001.js * ECMA Section: @@ -18,9 +19,6 @@ startTest(); writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - ForIn_1( { length:4, company:"netscape", year:2000, 0:"zero" } ); ForIn_2( { length:4, company:"netscape", year:2000, 0:"zero" } ); ForIn_3( { length:4, company:"netscape", year:2000, 0:"zero" } ); @@ -47,7 +45,7 @@ } for ( var i = 0; i < PropertyArray.length; i++ ) { - testcases[tc++] = new TestCase( + new TestCase( SECTION, "object[" + PropertyArray[i] +"]", object[PropertyArray[i]], @@ -55,7 +53,7 @@ ); } - testcases[tc++] = new TestCase( + new TestCase( SECTION, "object.length", PropertyArray.length, @@ -77,7 +75,7 @@ } for ( i = 0; i < PropertyArray.length; i++ ) { - testcases[tc++] = new TestCase( + new TestCase( SECTION, "object[" + PropertyArray[i] +"]", object[PropertyArray[i]], @@ -85,7 +83,7 @@ ); } - testcases[tc++] = new TestCase( + new TestCase( SECTION, "object.length", PropertyArray.length, @@ -108,19 +106,19 @@ checkBreak = "fail"; } - testcases[tc++] = new TestCase( + new TestCase( SECTION, "check break out of for...in", "pass", checkBreak ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "properties.length", 1, properties.length ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "object["+properties[0]+"]", values[0], @@ -149,25 +147,25 @@ result3++; } - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify labeled statement is only executed once", true, result1 == 1 ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify statements in for loop are evaluated", true, result2 == i ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify break out of labeled for...in loop", true, result4 == 0 ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify break out of labeled block", true, @@ -195,25 +193,25 @@ result3++; } - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify labeled statement is only executed once", true, result1 == 1 ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify statements in for loop are evaluated", true, result2 == i ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify break out of labeled for...in loop", true, result4 == 0 ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify break out of labeled block", true, @@ -238,19 +236,19 @@ result4++; } - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify statements in for loop are evaluated", true, result2 == i ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify break out of labeled for...in loop", true, result4 == 0 ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "verify break out of labeled block", true, @@ -273,19 +271,19 @@ checkBreak = "fail"; } - testcases[tc++] = new TestCase( + new TestCase( SECTION, "check break out of for...in", "pass", checkBreak ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "properties.length", 1, properties.length ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "object["+properties[0]+"]", values[0], diff --git a/mozilla/js/tests/ecma_2/Statements/forin-002.js b/mozilla/js/tests/ecma_2/Statements/forin-002.js index 1f527a9ae1d..4c678a2d5fa 100644 --- a/mozilla/js/tests/ecma_2/Statements/forin-002.js +++ b/mozilla/js/tests/ecma_2/Statements/forin-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: forin-002.js * ECMA Section: @@ -9,65 +10,62 @@ * Author: christine@netscape.com * Date: 28 August 1998 */ - var SECTION = "forin-002"; - var VERSION = "ECMA_2"; - var TITLE = "The for...in statement"; +var SECTION = "forin-002"; +var VERSION = "ECMA_2"; +var TITLE = "The for...in statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +function MyObject( value ) { + this.value = value; + this.valueOf = new Function ( "return this.value" ); + this.toString = new Function ( "return this.value + \"\"" ); + this.toNumber = new Function ( "return this.value + 0" ); + this.toBoolean = new Function ( "return Boolean( this.value )" ); +} - function MyObject( value ) { - this.value = value; - this.valueOf = new Function ( "return this.value" ); - this.toString = new Function ( "return this.value + \"\"" ); - this.toNumber = new Function ( "return this.value + 0" ); - this.toBoolean = new Function ( "return Boolean( this.value )" ); +ForIn_1(this); +ForIn_2(this); + +ForIn_1(new MyObject(true)); +ForIn_2(new MyObject(new Boolean(true))); + +ForIn_2(3); + +test(); + +/** + * For ... In in a With Block + * + */ +function ForIn_1( object) { + with ( object ) { + for ( property in object ) { + new TestCase( + SECTION, + "with loop in a for...in loop. ("+object+")["+property +"] == "+ + "eval ( " + property +" )", + true, + object[property] == eval(property) ); } + } +} - ForIn_1(this); - ForIn_2(this); - - ForIn_1(new MyObject(true)); - ForIn_2(new MyObject(new Boolean(true))); - - ForIn_2(3); - - test(); - - /** - * For ... In in a With Block - * - */ - function ForIn_1( object) { - with ( object ) { - for ( property in object ) { - testcases[tc++] = new TestCase( - SECTION, - "with loop in a for...in loop. ("+object+")["+property +"] == "+ - "eval ( " + property +" )", - true, - object[property] == eval(property) ); - } - } - } - - /** - * With block in a For...In loop - * - */ - function ForIn_2(object) { - for ( property in object ) { - with ( object ) { - testcases[tc++] = new TestCase( - SECTION, - "with loop in a for...in loop. ("+object+")["+property +"] == "+ - "eval ( " + property +" )", - true, - object[property] == eval(property) ); - } - } +/** + * With block in a For...In loop + * + */ +function ForIn_2(object) { + for ( property in object ) { + with ( object ) { + new TestCase( + SECTION, + "with loop in a for...in loop. ("+object+")["+property +"] == "+ + "eval ( " + property +" )", + true, + object[property] == eval(property) ); } + } +} diff --git a/mozilla/js/tests/ecma_2/Statements/if-001.js b/mozilla/js/tests/ecma_2/Statements/if-001.js index 0da212d39fa..c5a9f43875f 100644 --- a/mozilla/js/tests/ecma_2/Statements/if-001.js +++ b/mozilla/js/tests/ecma_2/Statements/if-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: if-001.js * ECMA Section: @@ -9,31 +10,28 @@ * Author: christine@netscape.com * Date: 28 August 1998 */ - var SECTION = "for-001"; - var VERSION = "ECMA_2"; - var TITLE = "The if statement"; - var BUGNUMBER="148822"; +var SECTION = "for-001"; +var VERSION = "ECMA_2"; +var TITLE = "The if statement"; +var BUGNUMBER="148822"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var a = 0; +var b = 0; +var result = "passed"; - var a = 0; - var b = 0; - var result = "passed"; +if ( a = b ) { + result = "failed: a = b should return 0"; +} - if ( a = b ) { - result = "failed: a = b should return 0"; - } - - testcases[tc++] = new TestCase( - SECTION, - "if ( a = b ), where a and b are both equal to 0", - "passed", - result ); +new TestCase( + SECTION, + "if ( a = b ), where a and b are both equal to 0", + "passed", + result ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Statements/label-001.js b/mozilla/js/tests/ecma_2/Statements/label-001.js index 83b51ce665f..14d7d93be45 100644 --- a/mozilla/js/tests/ecma_2/Statements/label-001.js +++ b/mozilla/js/tests/ecma_2/Statements/label-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: label-001.js * ECMA Section: @@ -9,31 +10,28 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "label-003"; - var VERSION = "ECMA_2"; - var TITLE = "Labeled statements"; +var SECTION = "label-003"; +var VERSION = "ECMA_2"; +var TITLE = "Labeled statements"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +LabelTest(0, 0); +LabelTest(1, 1) + LabelTest(-1, 1000); +LabelTest(false, 0); +LabelTest(true, 1); - LabelTest(0, 0); - LabelTest(1, 1) - LabelTest(-1, 1000); - LabelTest(false, 0); - LabelTest(true, 1); +test(); - test(); +function LabelTest( limit, expect) { +woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; - function LabelTest( limit, expect) { - woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; - - testcases[tc++] = new TestCase( - SECTION, - "break out of a labeled for loop: "+ limit, - expect, - result ); - } +new TestCase( + SECTION, + "break out of a labeled for loop: "+ limit, + expect, + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/label-002.js b/mozilla/js/tests/ecma_2/Statements/label-002.js index 64b01a8c152..82e2fdf57a9 100644 --- a/mozilla/js/tests/ecma_2/Statements/label-002.js +++ b/mozilla/js/tests/ecma_2/Statements/label-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: label-002.js * ECMA Section: @@ -9,45 +10,42 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "label-002"; - var VERSION = "ECMA_2"; - var TITLE = "Labeled statements"; +var SECTION = "label-002"; +var VERSION = "ECMA_2"; +var TITLE = "Labeled statements"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +LabelTest( { p1:"hi,", p2:" norris" }, "hi, norris", " norrishi," ); +LabelTest( { 0:"zero", 1:"one" }, "zeroone", "onezero" ); - LabelTest( { p1:"hi,", p2:" norris" }, "hi, norris", " norrishi," ); - LabelTest( { 0:"zero", 1:"one" }, "zeroone", "onezero" ); +LabelTest2( { p1:"hi,", p2:" norris" }, "hi,", " norris" ); +LabelTest2( { 0:"zero", 1:"one" }, "zero", "one" ); - LabelTest2( { p1:"hi,", p2:" norris" }, "hi,", " norris" ); - LabelTest2( { 0:"zero", 1:"one" }, "zero", "one" ); +test(); - test(); +function LabelTest( object, expect1, expect2 ) { + result = ""; - function LabelTest( object, expect1, expect2 ) { - result = ""; +yoohoo: { for ( property in object ) { result += object[property]; }; break yoohoo }; - yoohoo: { for ( property in object ) { result += object[property]; }; break yoohoo }; + new TestCase( + SECTION, + "yoohoo: for ( property in object ) { result += object[property]; } break yoohoo }", + true, + result == expect1 || result == expect2 ); +} - testcases[tc++] = new TestCase( - SECTION, - "yoohoo: for ( property in object ) { result += object[property]; } break yoohoo }", - true, - result == expect1 || result == expect2 ); - } +function LabelTest2( object, expect1, expect2 ) { + result = ""; - function LabelTest2( object, expect1, expect2 ) { - result = ""; +yoohoo: { for ( property in object ) { result += object[property]; break yoohoo } }; ; - yoohoo: { for ( property in object ) { result += object[property]; break yoohoo } }; ; - - testcases[tc++] = new TestCase( - SECTION, - "yoohoo: for ( property in object ) { result += object[property]; break yoohoo }}", - true, - result == expect1 || result == expect2 ); - } +new TestCase( + SECTION, + "yoohoo: for ( property in object ) { result += object[property]; break yoohoo }}", + true, + result == expect1 || result == expect2 ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/shell.js b/mozilla/js/tests/ecma_2/Statements/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/Statements/switch-001.js b/mozilla/js/tests/ecma_2/Statements/switch-001.js index 6336518a78a..3f97cd5bf36 100644 --- a/mozilla/js/tests/ecma_2/Statements/switch-001.js +++ b/mozilla/js/tests/ecma_2/Statements/switch-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: switch-001.js * ECMA Section: @@ -9,56 +10,51 @@ * Date: 11 August 1998 * */ - var SECTION = "switch-001"; - var VERSION = "ECMA_2"; - var TITLE = "The switch statement"; +var SECTION = "switch-001"; +var VERSION = "ECMA_2"; +var TITLE = "The switch statement"; - var BUGNUMBER="315767"; +var BUGNUMBER="315767"; +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); +SwitchTest( 0, 126 ); +SwitchTest( 1, 124 ); +SwitchTest( 2, 120 ); +SwitchTest( 3, 112 ); +SwitchTest( 4, 64 ); +SwitchTest( 5, 96 ); +SwitchTest( true, 96 ); +SwitchTest( false, 96 ); +SwitchTest( null, 96 ); +SwitchTest( void 0, 96 ); +SwitchTest( "0", 96 ); - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +test(); - var tc = 0; - var testcases = new Array(); +function SwitchTest( input, expect ) { + var result = 0; - SwitchTest( 0, 126 ); - SwitchTest( 1, 124 ); - SwitchTest( 2, 120 ); - SwitchTest( 3, 112 ); - SwitchTest( 4, 64 ); - SwitchTest( 5, 96 ); - SwitchTest( true, 96 ); - SwitchTest( false, 96 ); - SwitchTest( null, 96 ); - SwitchTest( void 0, 96 ); - SwitchTest( "0", 96 ); + switch ( input ) { + case 0: + result += 2; + case 1: + result += 4; + case 2: + result += 8; + case 3: + result += 16; + default: + result += 32; + case 4: + result +=64; + } - test(); - - function SwitchTest( input, expect ) { - var result = 0; - - switch ( input ) { - case 0: - result += 2; - case 1: - result += 4; - case 2: - result += 8; - case 3: - result += 16; - default: - result += 32; - case 4: - result +=64; - } - - testcases[tc++] = new TestCase( - SECTION, - "switch with no breaks, case expressions are numbers. input is "+ - input, - expect, - result ); - } + new TestCase( + SECTION, + "switch with no breaks, case expressions are numbers. input is "+ + input, + expect, + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/switch-002.js b/mozilla/js/tests/ecma_2/Statements/switch-002.js index 20746a804a8..76b51c877cf 100644 --- a/mozilla/js/tests/ecma_2/Statements/switch-002.js +++ b/mozilla/js/tests/ecma_2/Statements/switch-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: switch-002.js * ECMA Section: @@ -9,52 +10,49 @@ * Date: 11 August 1998 * */ - var SECTION = "switch-002"; - var VERSION = "ECMA_2"; - var TITLE = "The switch statement"; +var SECTION = "switch-002"; +var VERSION = "ECMA_2"; +var TITLE = "The switch statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +SwitchTest( 0, 6 ); +SwitchTest( 1, 4 ); +SwitchTest( 2, 56 ); +SwitchTest( 3, 48 ); +SwitchTest( 4, 64 ); +SwitchTest( true, 32 ); +SwitchTest( false, 32 ); +SwitchTest( null, 32 ); +SwitchTest( void 0, 32 ); +SwitchTest( "0", 32 ); - SwitchTest( 0, 6 ); - SwitchTest( 1, 4 ); - SwitchTest( 2, 56 ); - SwitchTest( 3, 48 ); - SwitchTest( 4, 64 ); - SwitchTest( true, 32 ); - SwitchTest( false, 32 ); - SwitchTest( null, 32 ); - SwitchTest( void 0, 32 ); - SwitchTest( "0", 32 ); +test(); - test(); +function SwitchTest( input, expect ) { + var result = 0; - function SwitchTest( input, expect ) { - var result = 0; + switch ( input ) { + case 0: + result += 2; + case 1: + result += 4; + break; + case 2: + result += 8; + case 3: + result += 16; + default: + result += 32; + break; + case 4: + result += 64; + } - switch ( input ) { - case 0: - result += 2; - case 1: - result += 4; - break; - case 2: - result += 8; - case 3: - result += 16; - default: - result += 32; - break; - case 4: - result += 64; - } - - testcases[tc++] = new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); - } + new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/switch-003.js b/mozilla/js/tests/ecma_2/Statements/switch-003.js index 6a1389c81ad..da77ecc3bdd 100644 --- a/mozilla/js/tests/ecma_2/Statements/switch-003.js +++ b/mozilla/js/tests/ecma_2/Statements/switch-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: switch-003.js * ECMA Section: @@ -9,46 +10,43 @@ * Date: 11 August 1998 * */ - var SECTION = "switch-003"; - var VERSION = "ECMA_2"; - var TITLE = "The switch statement"; +var SECTION = "switch-003"; +var VERSION = "ECMA_2"; +var TITLE = "The switch statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - - SwitchTest( "a", "abc" ); - SwitchTest( "b", "bc" ); - SwitchTest( "c", "c" ); - SwitchTest( "d", "*abc" ); - SwitchTest( "v", "*abc" ); - SwitchTest( "w", "w*abc" ); - SwitchTest( "x", "xw*abc" ); - SwitchTest( "y", "yxw*abc" ); - SwitchTest( "z", "zyxw*abc" ); +SwitchTest( "a", "abc" ); +SwitchTest( "b", "bc" ); +SwitchTest( "c", "c" ); +SwitchTest( "d", "*abc" ); +SwitchTest( "v", "*abc" ); +SwitchTest( "w", "w*abc" ); +SwitchTest( "x", "xw*abc" ); +SwitchTest( "y", "yxw*abc" ); +SwitchTest( "z", "zyxw*abc" ); // SwitchTest( new java.lang.String("z"), "*abc" ); - test(); +test(); - function SwitchTest( input, expect ) { - var result = ""; +function SwitchTest( input, expect ) { + var result = ""; - switch ( input ) { - case "z": result += "z"; - case "y": result += "y"; - case "x": result += "x"; - case "w": result += "w"; - default: result += "*"; - case "a": result += "a"; - case "b": result += "b"; - case "c": result += "c"; - } + switch ( input ) { + case "z": result += "z"; + case "y": result += "y"; + case "x": result += "x"; + case "w": result += "w"; + default: result += "*"; + case "a": result += "a"; + case "b": result += "b"; + case "c": result += "c"; + } - testcases[tc++] = new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); - } \ No newline at end of file + new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/switch-004.js b/mozilla/js/tests/ecma_2/Statements/switch-004.js index 23da926d330..cb061638b2e 100644 --- a/mozilla/js/tests/ecma_2/Statements/switch-004.js +++ b/mozilla/js/tests/ecma_2/Statements/switch-004.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: switch-003.js * ECMA Section: @@ -14,78 +15,75 @@ * Date: 11 August 1998 * */ - var SECTION = "switch-003"; - var VERSION = "ECMA_2"; - var TITLE = "The switch statement"; - var BUGNUMBER= "315988"; +var SECTION = "switch-003"; +var VERSION = "ECMA_2"; +var TITLE = "The switch statement"; +var BUGNUMBER= "315988"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +ONE = new Number(1); +ZERO = new Number(0); +var A = new String("A"); +var B = new String("B"); +TRUE = new Boolean( true ); +FALSE = new Boolean( false ); +UNDEFINED = void 0; +NULL = null; - ONE = new Number(1); - ZERO = new Number(0); - var A = new String("A"); - var B = new String("B"); - TRUE = new Boolean( true ); - FALSE = new Boolean( false ); - UNDEFINED = void 0; - NULL = null; +SwitchTest( ZERO, "ZERO" ); +SwitchTest( NULL, "NULL" ); +SwitchTest( UNDEFINED, "UNDEFINED" ); +SwitchTest( FALSE, "FALSE" ); +SwitchTest( false, "false" ); +SwitchTest( 0, "0" ); - SwitchTest( ZERO, "ZERO" ); - SwitchTest( NULL, "NULL" ); - SwitchTest( UNDEFINED, "UNDEFINED" ); - SwitchTest( FALSE, "FALSE" ); - SwitchTest( false, "false" ); - SwitchTest( 0, "0" ); +SwitchTest ( TRUE, "TRUE" ); +SwitchTest( 1, "1" ); +SwitchTest( ONE, "ONE" ); +SwitchTest( true, "true" ); - SwitchTest ( TRUE, "TRUE" ); - SwitchTest( 1, "1" ); - SwitchTest( ONE, "ONE" ); - SwitchTest( true, "true" ); +SwitchTest( "a", "a" ); +SwitchTest( A, "A" ); +SwitchTest( "b", "b" ); +SwitchTest( B, "B" ); - SwitchTest( "a", "a" ); - SwitchTest( A, "A" ); - SwitchTest( "b", "b" ); - SwitchTest( B, "B" ); +SwitchTest( new Boolean( true ), "default" ); +SwitchTest( new Boolean(false ), "default" ); +SwitchTest( new String( "A" ), "default" ); +SwitchTest( new Number( 0 ), "default" ); - SwitchTest( new Boolean( true ), "default" ); - SwitchTest( new Boolean(false ), "default" ); - SwitchTest( new String( "A" ), "default" ); - SwitchTest( new Number( 0 ), "default" ); +test(); - test(); +function SwitchTest( input, expect ) { + var result = ""; - function SwitchTest( input, expect ) { - var result = ""; + switch ( input ) { + default: result += "default"; break; + case "a": result += "a"; break; + case "b": result += "b"; break; + case A: result += "A"; break; + case B: result += "B"; break; + case new Boolean(true): result += "new TRUE"; break; + case new Boolean(false): result += "new FALSE"; break; + case NULL: result += "NULL"; break; + case UNDEFINED: result += "UNDEFINED"; break; + case true: result += "true"; break; + case false: result += "false"; break; + case TRUE: result += "TRUE"; break; + case FALSE: result += "FALSE"; break; + case 0: result += "0"; break; + case 1: result += "1"; break; + case new Number(0) : result += "new ZERO"; break; + case new Number(1) : result += "new ONE"; break; + case ONE: result += "ONE"; break; + case ZERO: result += "ZERO"; break; + } - switch ( input ) { - default: result += "default"; break; - case "a": result += "a"; break; - case "b": result += "b"; break; - case A: result += "A"; break; - case B: result += "B"; break; - case new Boolean(true): result += "new TRUE"; break; - case new Boolean(false): result += "new FALSE"; break; - case NULL: result += "NULL"; break; - case UNDEFINED: result += "UNDEFINED"; break; - case true: result += "true"; break; - case false: result += "false"; break; - case TRUE: result += "TRUE"; break; - case FALSE: result += "FALSE"; break; - case 0: result += "0"; break; - case 1: result += "1"; break; - case new Number(0) : result += "new ZERO"; break; - case new Number(1) : result += "new ONE"; break; - case ONE: result += "ONE"; break; - case ZERO: result += "ZERO"; break; - } - - testcases[tc++] = new TestCase( - SECTION, - "switch with no breaks: input is " + input, - expect, - result ); - } + new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-001.js b/mozilla/js/tests/ecma_2/Statements/try-001.js index bcd0eac2c82..d8401bf6506 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-001.js +++ b/mozilla/js/tests/ecma_2/Statements/try-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-001.js * ECMA Section: @@ -12,71 +13,68 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = ""; - var VERSION = "ECMA_2"; - var TITLE = "The try statement"; +var SECTION = ""; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +var INVALID_JAVA_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; - var INVALID_JAVA_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; +TryNewJavaInteger( "3.14159", INVALID_JAVA_INTEGER_VALUE ); +TryNewJavaInteger( NaN, INVALID_JAVA_INTEGER_VALUE ); +TryNewJavaInteger( 0, 0 ); +TryNewJavaInteger( -1, -1 ); +TryNewJavaInteger( 1, 1 ); +TryNewJavaInteger( Infinity, Infinity ); - TryNewJavaInteger( "3.14159", INVALID_JAVA_INTEGER_VALUE ); - TryNewJavaInteger( NaN, INVALID_JAVA_INTEGER_VALUE ); - TryNewJavaInteger( 0, 0 ); - TryNewJavaInteger( -1, -1 ); - TryNewJavaInteger( 1, 1 ); - TryNewJavaInteger( Infinity, Infinity ); +test(); - test(); +/** + * Check to see if the input is valid for java.lang.Integer. If it is + * not valid, throw INVALID_JAVA_INTEGER_VALUE. If input is valid, + * return Number( v ) + * + */ - /** - * Check to see if the input is valid for java.lang.Integer. If it is - * not valid, throw INVALID_JAVA_INTEGER_VALUE. If input is valid, - * return Number( v ) - * - */ +function newJavaInteger( v ) { + value = Number( v ); + if ( Math.floor(value) != value || isNaN(value) ) { + throw ( INVALID_JAVA_INTEGER_VALUE ); + } else { + return value; + } +} - function newJavaInteger( v ) { - value = Number( v ); - if ( Math.floor(value) != value || isNaN(value) ) { - throw ( INVALID_JAVA_INTEGER_VALUE ); - } else { - return value; - } - } +/** + * Call newJavaInteger( value ) from within a try block. Catch any + * exception, and store it in result. Verify that we got the right + * return value from newJavaInteger in cases in which we do not expect + * exceptions, and that we got the exception in cases where an exception + * was expected. + */ +function TryNewJavaInteger( value, expect ) { + var finalTest = false; - /** - * Call newJavaInteger( value ) from within a try block. Catch any - * exception, and store it in result. Verify that we got the right - * return value from newJavaInteger in cases in which we do not expect - * exceptions, and that we got the exception in cases where an exception - * was expected. - */ - function TryNewJavaInteger( value, expect ) { - var finalTest = false; + try { + result = newJavaInteger( value ); + } catch ( e ) { + result = String( e ); + } finally { + finalTest = true; + } + new TestCase( + SECTION, + "newJavaValue( " + value +" )", + expect, + result); - try { - result = newJavaInteger( value ); - } catch ( e ) { - result = String( e ); - } finally { - finalTest = true; - } - testcases[tc++] = new TestCase( - SECTION, - "newJavaValue( " + value +" )", - expect, - result); + new TestCase( + SECTION, + "newJavaValue( " + value +" ) hit finally block", + true, + finalTest); - testcases[tc++] = new TestCase( - SECTION, - "newJavaValue( " + value +" ) hit finally block", - true, - finalTest); - - } +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-003.js b/mozilla/js/tests/ecma_2/Statements/try-003.js index de1e2139e3a..a696a3755a3 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-003.js +++ b/mozilla/js/tests/ecma_2/Statements/try-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-003.js * ECMA Section: @@ -8,72 +9,69 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-003"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement"; - var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585"; +var SECTION = "try-003"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; +var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +// Tests start here. - // Tests start here. +TrySomething( "x = \"hi\"", false ); +TrySomething( "throw \"boo\"", true ); +TrySomething( "throw 3", true ); - TrySomething( "x = \"hi\"", false ); - TrySomething( "throw \"boo\"", true ); - TrySomething( "throw 3", true ); +test(); - test(); - - /** - * This function contains a try block with no catch block, - * but it does have a finally block. Try to evaluate expressions - * that do and do not throw exceptions. - */ - - function TrySomething( expression, throwing ) { - innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; - if (throwing) { - outerCatch = "FAILED: NO EXCEPTION CAUGHT"; - } else { - outerCatch = "PASS"; - } - outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; - - try { - try { - eval( expression ); - } finally { - innerFinally = "PASS"; - } - } catch ( e ) { - if (throwing) { - outerCatch = "PASS"; - } else { - outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; - } - } finally { - outerFinally = "PASS"; - } - - - testcases[tc++] = new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - innerFinally ); - testcases[tc++] = new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - outerCatch ); - testcases[tc++] = new TestCase( - SECTION, - "eval( " + expression +" )", - "PASS", - outerFinally ); +/** + * This function contains a try block with no catch block, + * but it does have a finally block. Try to evaluate expressions + * that do and do not throw exceptions. + */ +function TrySomething( expression, throwing ) { + innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; + if (throwing) { + outerCatch = "FAILED: NO EXCEPTION CAUGHT"; + } else { + outerCatch = "PASS"; + } + outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; + try { + try { + eval( expression ); + } finally { + innerFinally = "PASS"; } + } catch ( e ) { + if (throwing) { + outerCatch = "PASS"; + } else { + outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; + } + } finally { + outerFinally = "PASS"; + } + + + new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + innerFinally ); + new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + outerCatch ); + new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + outerFinally ); + + +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-004.js b/mozilla/js/tests/ecma_2/Statements/try-004.js index b36dc4415c9..0298c789372 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-004.js +++ b/mozilla/js/tests/ecma_2/Statements/try-004.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-004.js * ECMA Section: @@ -8,44 +9,41 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-004"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement"; +var SECTION = "try-004"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +TryToCatch( "Math.PI", Math.PI ); +TryToCatch( "Thrower(5)", "Caught 5" ); +TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); - TryToCatch( "Math.PI", Math.PI ); - TryToCatch( "Thrower(5)", "Caught 5" ); - TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); +test(); - test(); +function Thrower( v ) { + throw "Caught " + v; +} - function Thrower( v ) { - throw "Caught " + v; - } +/** + * Evaluate a string. Catch any exceptions thrown. If no exception is + * expected, verify the result of the evaluation. If an exception is + * expected, verify that we got the right exception. + */ - /** - * Evaluate a string. Catch any exceptions thrown. If no exception is - * expected, verify the result of the evaluation. If an exception is - * expected, verify that we got the right exception. - */ +function TryToCatch( value, expect ) { + try { + result = eval( value ); + } catch ( e ) { + result = e; + } - function TryToCatch( value, expect ) { - try { - result = eval( value ); - } catch ( e ) { - result = e; - } - - testcases[tc++] = new TestCase( - SECTION, - "eval( " + value +" )", - expect, - result ); - } + new TestCase( + SECTION, + "eval( " + value +" )", + expect, + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-005.js b/mozilla/js/tests/ecma_2/Statements/try-005.js index 94b5beb2fe6..7c5733935c5 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-005.js +++ b/mozilla/js/tests/ecma_2/Statements/try-005.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-005.js * ECMA Section: @@ -10,45 +11,42 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-005"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement"; +var SECTION = "try-005"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +TryToCatch( "Math.PI", Math.PI ); +TryToCatch( "Thrower(5)", "Caught 5" ); +TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); - TryToCatch( "Math.PI", Math.PI ); - TryToCatch( "Thrower(5)", "Caught 5" ); - TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); +test(); - test(); +function Thrower( v ) { + throw "Caught " + v; +} +function Eval( v ) { + return eval( v ); +} - function Thrower( v ) { - throw "Caught " + v; - } - function Eval( v ) { - return eval( v ); - } +/** + * Evaluate a string. Catch any exceptions thrown. If no exception is + * expected, verify the result of the evaluation. If an exception is + * expected, verify that we got the right exception. + */ - /** - * Evaluate a string. Catch any exceptions thrown. If no exception is - * expected, verify the result of the evaluation. If an exception is - * expected, verify that we got the right exception. - */ +function TryToCatch( value, expect ) { + try { + result = Eval( value ); + } catch ( e ) { + result = e; + } - function TryToCatch( value, expect ) { - try { - result = Eval( value ); - } catch ( e ) { - result = e; - } - - testcases[tc++] = new TestCase( - SECTION, - "eval( " + value +" )", - expect, - result ); - } + new TestCase( + SECTION, + "eval( " + value +" )", + expect, + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-006.js b/mozilla/js/tests/ecma_2/Statements/try-006.js index 924f24d5dcc..f373f1d1b6c 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-006.js +++ b/mozilla/js/tests/ecma_2/Statements/try-006.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-006.js * ECMA Section: @@ -9,76 +10,73 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-006"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement"; +var SECTION = "try-006"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +/** + * This is the "check" function for test objects that will + * throw an exception. + */ +function throwException() { + throw EXCEPTION_STRING +": " + this.valueOf(); +} +var EXCEPTION_STRING = "Exception thrown:"; - /** - * This is the "check" function for test objects that will - * throw an exception. - */ - function throwException() { - throw EXCEPTION_STRING +": " + this.valueOf(); +/** + * This is the "check" function for test objects that do not + * throw an exception + */ +function noException() { + return this.valueOf(); +} + +/** + * Add test cases here + */ +TryWith( new TryObject( "hello", throwException, true )); +TryWith( new TryObject( "hola", noException, false )); + +/** + * Run the test. + */ + +test(); + +/** + * This is the object that will be the "this" in a with block. + */ +function TryObject( value, fun, exception ) { + this.value = value; + this.exception = exception; + + this.valueOf = new Function ( "return this.value" ); + this.check = fun; +} + +/** + * This function has the try block that has a with block within it. + * Test cases are added in this function. Within the with block, the + * object's "check" function is called. If the test object's exception + * property is true, we expect the result to be the exception value. + * If exception is false, then we expect the result to be the value of + * the object. + */ +function TryWith( object ) { + try { + with ( object ) { + result = check(); } - var EXCEPTION_STRING = "Exception thrown:"; + } catch ( e ) { + result = e; + } - /** - * This is the "check" function for test objects that do not - * throw an exception - */ - function noException() { - return this.valueOf(); - } - - /** - * Add test cases here - */ - TryWith( new TryObject( "hello", throwException, true )); - TryWith( new TryObject( "hola", noException, false )); - - /** - * Run the test. - */ - - test(); - - /** - * This is the object that will be the "this" in a with block. - */ - function TryObject( value, fun, exception ) { - this.value = value; - this.exception = exception; - - this.valueOf = new Function ( "return this.value" ); - this.check = fun; - } - - /** - * This function has the try block that has a with block within it. - * Test cases are added in this function. Within the with block, the - * object's "check" function is called. If the test object's exception - * property is true, we expect the result to be the exception value. - * If exception is false, then we expect the result to be the value of - * the object. - */ - function TryWith( object ) { - try { - with ( object ) { - result = check(); - } - } catch ( e ) { - result = e; - } - - testcases[tc++] = new TestCase( - SECTION, - "TryWith( " + object.value +" )", - (object.exception ? EXCEPTION_STRING +": " + object.valueOf() : object.valueOf()), - result ); - } + new TestCase( + SECTION, + "TryWith( " + object.value +" )", + (object.exception ? EXCEPTION_STRING +": " + object.valueOf() : object.valueOf()), + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-007.js b/mozilla/js/tests/ecma_2/Statements/try-007.js index 14a960abc21..7a8024a874d 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-007.js +++ b/mozilla/js/tests/ecma_2/Statements/try-007.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-007.js * ECMA Section: @@ -9,44 +10,41 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-007"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement: for-in"; +var SECTION = "try-007"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement: for-in"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +/** + * This is the "check" function for test objects that will + * throw an exception. + */ +function throwException() { + throw EXCEPTION_STRING +": " + this.valueOf(); +} +var EXCEPTION_STRING = "Exception thrown:"; - /** - * This is the "check" function for test objects that will - * throw an exception. - */ - function throwException() { - throw EXCEPTION_STRING +": " + this.valueOf(); - } - var EXCEPTION_STRING = "Exception thrown:"; +/** + * This is the "check" function for test objects that do not + * throw an exception + */ +function noException() { + return this.valueOf(); +} - /** - * This is the "check" function for test objects that do not - * throw an exception - */ - function noException() { - return this.valueOf(); - } +/** + * Add test cases here + */ +TryForIn( new TryObject( "hello", throwException, true )); +TryForIn( new TryObject( "hola", noException, false )); - /** - * Add test cases here - */ - TryForIn( new TryObject( "hello", throwException, true )); - TryForIn( new TryObject( "hola", noException, false )); +/** + * Run the test. + */ - /** - * Run the test. - */ - - test(); +test(); /** * This is the object that will be the "this" in a with block. @@ -55,11 +53,11 @@ * */ function TryObject( value, fun, exception ) { - this.value = value; - this.exception = exception; + this.value = value; + this.exception = exception; - this.check = fun; - this.valueOf = function () { return this.value; } + this.check = fun; + this.valueOf = function () { return this.value; } } /** @@ -69,21 +67,21 @@ function TryObject( value, fun, exception ) { * exceptions are properly caught. */ - function TryForIn( object ) { - try { - for ( p in object ) { - if ( typeof object[p] == "function" ) { - result = object[p](); - } - } - } catch ( e ) { - result = e; +function TryForIn( object ) { + try { + for ( p in object ) { + if ( typeof object[p] == "function" ) { + result = object[p](); + } } + } catch ( e ) { + result = e; + } - testcases[tc++] = new TestCase( - SECTION, - "TryForIn( " + object+ " )", - (object.exception ? EXCEPTION_STRING +": " + object.value : object.value), - result ); + new TestCase( + SECTION, + "TryForIn( " + object+ " )", + (object.exception ? EXCEPTION_STRING +": " + object.value : object.value), + result ); - } +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-008.js b/mozilla/js/tests/ecma_2/Statements/try-008.js index 78092b69d71..d7006ad6e81 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-008.js +++ b/mozilla/js/tests/ecma_2/Statements/try-008.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-008.js * ECMA Section: @@ -9,48 +10,45 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-008"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement: try in a constructor"; +var SECTION = "try-008"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement: try in a constructor"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +function Integer( value, exception ) { + try { + this.value = checkValue( value ); + } catch ( e ) { + this.value = e.toString(); + } - function Integer( value, exception ) { - try { - this.value = checkValue( value ); - } catch ( e ) { - this.value = e.toString(); - } + new TestCase( + SECTION, + "Integer( " + value +" )", + (exception ? INVALID_INTEGER_VALUE +": " + value : this.value), + this.value ); +} - testcases[tc++] = new TestCase( - SECTION, - "Integer( " + value +" )", - (exception ? INVALID_INTEGER_VALUE +": " + value : this.value), - this.value ); - } +var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; - var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; +function checkValue( value ) { + if ( Math.floor(value) != value || isNaN(value) ) { + throw ( INVALID_INTEGER_VALUE +": " + value ); + } else { + return value; + } +} - function checkValue( value ) { - if ( Math.floor(value) != value || isNaN(value) ) { - throw ( INVALID_INTEGER_VALUE +": " + value ); - } else { - return value; - } - } +// add test cases - // add test cases - - new Integer( 3, false ); - new Integer( NaN, true ); - new Integer( 0, false ); - new Integer( Infinity, false ); - new Integer( -2.12, true ); - new Integer( Math.LN2, true ); +new Integer( 3, false ); +new Integer( NaN, true ); +new Integer( 0, false ); +new Integer( Infinity, false ); +new Integer( -2.12, true ); +new Integer( Math.LN2, true ); - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/Statements/try-009.js b/mozilla/js/tests/ecma_2/Statements/try-009.js index 778e64784fa..c89925d5025 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-009.js +++ b/mozilla/js/tests/ecma_2/Statements/try-009.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-009.js * ECMA Section: @@ -10,54 +11,51 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-009"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement: try in a while block"; +var SECTION = "try-009"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement: try in a while block"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - - var EXCEPTION_STRING = "Exception thrown: "; - var NO_EXCEPTION_STRING = "No exception thrown: "; +var EXCEPTION_STRING = "Exception thrown: "; +var NO_EXCEPTION_STRING = "No exception thrown: "; - TryInWhile( new TryObject( "hello", ThrowException, true ) ); - TryInWhile( new TryObject( "aloha", NoException, false )); +TryInWhile( new TryObject( "hello", ThrowException, true ) ); +TryInWhile( new TryObject( "aloha", NoException, false )); - test(); +test(); - function TryObject( value, throwFunction, result ) { - this.value = value; - this.thrower = throwFunction; - this.result = result; +function TryObject( value, throwFunction, result ) { + this.value = value; + this.thrower = throwFunction; + this.result = result; +} +function ThrowException() { + throw EXCEPTION_STRING + this.value; +} +function NoException() { + return NO_EXCEPTION_STRING + this.value; +} +function TryInWhile( object ) { + result = null; + while ( true ) { + try { + object.thrower(); + result = NO_EXCEPTION_STRING + object.value; + break; + } catch ( e ) { + result = e; + break; } - function ThrowException() { - throw EXCEPTION_STRING + this.value; - } - function NoException() { - return NO_EXCEPTION_STRING + this.value; - } - function TryInWhile( object ) { - result = null; - while ( true ) { - try { - object.thrower(); - result = NO_EXCEPTION_STRING + object.value; - break; - } catch ( e ) { - result = e; - break; - } - } + } - testcases[tc++] = new TestCase( - SECTION, - "( "+ object +".thrower() )", - (object.result - ? EXCEPTION_STRING + object.value : - NO_EXCEPTION_STRING + object.value), - result ); - } + new TestCase( + SECTION, + "( "+ object +".thrower() )", + (object.result + ? EXCEPTION_STRING + object.value : + NO_EXCEPTION_STRING + object.value), + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-010.js b/mozilla/js/tests/ecma_2/Statements/try-010.js index eeb7f88c6b6..3337a0a9283 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-010.js +++ b/mozilla/js/tests/ecma_2/Statements/try-010.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-010.js * ECMA Section: @@ -10,61 +11,58 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-010"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement: try in a tryblock"; +var SECTION = "try-010"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement: try in a tryblock"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - - var EXCEPTION_STRING = "Exception thrown: "; - var NO_EXCEPTION_STRING = "No exception thrown: "; +var EXCEPTION_STRING = "Exception thrown: "; +var NO_EXCEPTION_STRING = "No exception thrown: "; - NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) ); - NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 )); - NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 )); - NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 )); +NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) ); +NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 )); +NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 )); +NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 )); - test(); +test(); - function TryObject( description, tryOne, tryTwo, result ) { - this.description = description; - this.tryOne = tryOne; - this.tryTwo = tryTwo; - this.result = result; +function TryObject( description, tryOne, tryTwo, result ) { + this.description = description; + this.tryOne = tryOne; + this.tryTwo = tryTwo; + this.result = result; +} +function ThrowException() { + throw EXCEPTION_STRING + this.value; +} +function NoException() { + return NO_EXCEPTION_STRING + this.value; +} +function NestedTry( object ) { + result = 0; + try { + object.tryOne(); + result += 1; + try { + object.tryTwo(); + result += 2; + } catch ( e ) { + result +=4; + } finally { + result += 8; } - function ThrowException() { - throw EXCEPTION_STRING + this.value; - } - function NoException() { - return NO_EXCEPTION_STRING + this.value; - } - function NestedTry( object ) { - result = 0; - try { - object.tryOne(); - result += 1; - try { - object.tryTwo(); - result += 2; - } catch ( e ) { - result +=4; - } finally { - result += 8; - } - } catch ( e ) { - result += 16; - } finally { - result += 32; - } + } catch ( e ) { + result += 16; + } finally { + result += 32; + } - testcases[tc++] = new TestCase( - SECTION, - object.description, - object.result, - result ); - } + new TestCase( + SECTION, + object.description, + object.result, + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/try-012.js b/mozilla/js/tests/ecma_2/Statements/try-012.js index f8c8e0014f8..00406e3cccc 100644 --- a/mozilla/js/tests/ecma_2/Statements/try-012.js +++ b/mozilla/js/tests/ecma_2/Statements/try-012.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: try-012.js * ECMA Section: @@ -9,84 +10,81 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "try-012"; - var VERSION = "ECMA_2"; - var TITLE = "The try statement"; - var BUGNUMBER="336872"; +var SECTION = "try-012"; +var VERSION = "ECMA_2"; +var TITLE = "The try statement"; +var BUGNUMBER="336872"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +// Tests start here. - // Tests start here. +TrySomething( "x = \"hi\"", true ); +TrySomething( "throw \"boo\"", true ); +TrySomething( "throw 3", true ); - TrySomething( "x = \"hi\"", true ); - TrySomething( "throw \"boo\"", true ); - TrySomething( "throw 3", true ); +test(); - test(); +/** + * This function contains a try block with no catch block, + * but it does have a finally block. Try to evaluate expressions + * that do and do not throw exceptions. + * + * The productioni TryStatement Block Finally is evaluated as follows: + * 1. Evaluate Block + * 2. Evaluate Finally + * 3. If Result(2).type is normal return result 1 (in the test case, result 1 has + * the completion type throw) + * 4. return result 2 (does not get hit in this case) + * + */ - /** - * This function contains a try block with no catch block, - * but it does have a finally block. Try to evaluate expressions - * that do and do not throw exceptions. - * - * The productioni TryStatement Block Finally is evaluated as follows: - * 1. Evaluate Block - * 2. Evaluate Finally - * 3. If Result(2).type is normal return result 1 (in the test case, result 1 has - * the completion type throw) - * 4. return result 2 (does not get hit in this case) - * - */ - - function TrySomething( expression, throwing ) { - innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; - if (throwing) { - outerCatch = "FAILED: NO EXCEPTION CAUGHT"; - } else { - outerCatch = "PASS"; - } - outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; +function TrySomething( expression, throwing ) { + innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; + if (throwing) { + outerCatch = "FAILED: NO EXCEPTION CAUGHT"; + } else { + outerCatch = "PASS"; + } + outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; - // If the inner finally does not throw an exception, the result - // of the try block should be returned. (Type of inner return - // value should be throw if finally executes correctly + // If the inner finally does not throw an exception, the result + // of the try block should be returned. (Type of inner return + // value should be throw if finally executes correctly - try { - try { - throw 0; - } finally { - innerFinally = "PASS"; - eval( expression ); - } - } catch ( e ) { - if (throwing) { - outerCatch = "PASS"; - } else { - outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; - } - } finally { - outerFinally = "PASS"; - } - - - testcases[tc++] = new TestCase( - SECTION, - "eval( " + expression +" ): evaluated inner finally block", - "PASS", - innerFinally ); - testcases[tc++] = new TestCase( - SECTION, - "eval( " + expression +" ): evaluated outer catch block ", - "PASS", - outerCatch ); - testcases[tc++] = new TestCase( - SECTION, - "eval( " + expression +" ): evaluated outer finally block", - "PASS", - outerFinally ); + try { + try { + throw 0; + } finally { + innerFinally = "PASS"; + eval( expression ); } + } catch ( e ) { + if (throwing) { + outerCatch = "PASS"; + } else { + outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; + } + } finally { + outerFinally = "PASS"; + } + + + new TestCase( + SECTION, + "eval( " + expression +" ): evaluated inner finally block", + "PASS", + innerFinally ); + new TestCase( + SECTION, + "eval( " + expression +" ): evaluated outer catch block ", + "PASS", + outerCatch ); + new TestCase( + SECTION, + "eval( " + expression +" ): evaluated outer finally block", + "PASS", + outerFinally ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/while-001.js b/mozilla/js/tests/ecma_2/Statements/while-001.js index f9c0d64cbaa..ed2e2b62974 100644 --- a/mozilla/js/tests/ecma_2/Statements/while-001.js +++ b/mozilla/js/tests/ecma_2/Statements/while-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: while-001 * ECMA Section: @@ -9,31 +10,28 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "while-001"; - var VERSION = "ECMA_2"; - var TITLE = "while statement"; +var SECTION = "while-001"; +var VERSION = "ECMA_2"; +var TITLE = "while statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DoWhile(); +test(); - DoWhile(); - test(); +function DoWhile() { + result = "pass"; - function DoWhile() { - result = "pass"; + while (false) { + result = "fail"; + break; + } - while (false) { - result = "fail"; - break; - } + new TestCase( + SECTION, + "while statement: don't evaluate statement is expression is false", + "pass", + result ); - testcases[tc++] = new TestCase( - SECTION, - "while statement: don't evaluate statement is expression is false", - "pass", - result ); - - } \ No newline at end of file +} diff --git a/mozilla/js/tests/ecma_2/Statements/while-002.js b/mozilla/js/tests/ecma_2/Statements/while-002.js index 3fda04bc493..afd60c1d636 100644 --- a/mozilla/js/tests/ecma_2/Statements/while-002.js +++ b/mozilla/js/tests/ecma_2/Statements/while-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: while-002 * ECMA Section: @@ -9,75 +10,72 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "while-002"; - var VERSION = "ECMA_2"; - var TITLE = "while statement"; +var SECTION = "while-002"; +var VERSION = "ECMA_2"; +var TITLE = "while statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DoWhile( new DoWhileObject( + "while expression is null", + null, + "result = \"fail: should not have evaluated statements in while block;break" + ) ); - DoWhile( new DoWhileObject( - "while expression is null", - null, - "result = \"fail: should not have evaluated statements in while block;break" - ) ); +DoWhile( new DoWhileObject( + "while expression is undefined", + void 0, + "result = \"fail: should not have evaluated statements in while block; break" + )); - DoWhile( new DoWhileObject( - "while expression is undefined", - void 0, - "result = \"fail: should not have evaluated statements in while block; break" - )); +DoWhile( new DoWhileObject( + "while expression is 0", + 0, + "result = \"fail: should not have evaluated statements in while block; break;" + )); - DoWhile( new DoWhileObject( - "while expression is 0", - 0, - "result = \"fail: should not have evaluated statements in while block; break;" - )); +DoWhile( new DoWhileObject( + "while expression is eval(\"\")", + eval(""), + "result = \"fail: should not have evaluated statements in while block; break" + )); - DoWhile( new DoWhileObject( - "while expression is eval(\"\")", - eval(""), - "result = \"fail: should not have evaluated statements in while block; break" - )); +DoWhile( new DoWhileObject( + "while expression is NaN", + NaN, + "result = \"fail: should not have evaluated statements in while block; break" + )); - DoWhile( new DoWhileObject( - "while expression is NaN", - NaN, - "result = \"fail: should not have evaluated statements in while block; break" - )); +test(); - test(); +function DoWhileObject( d, e, s ) { + this.description = d; + this.whileExpression = e; + this.statements = s; +} - function DoWhileObject( d, e, s ) { - this.description = d; - this.whileExpression = e; - this.statements = s; - } +function DoWhile( object ) { + result = "pass"; - function DoWhile( object ) { - result = "pass"; + while ( expression = object.whileExpression ) { + eval( object.statements ); + } - while ( expression = object.whileExpression ) { - eval( object.statements ); - } + // verify that the while expression was evaluated - // verify that the while expression was evaluated + new TestCase( + SECTION, + "verify that while expression was evaluated (should be "+ + object.whileExpression +")", + "pass", + (object.whileExpression == expression || + ( isNaN(object.whileExpression) && isNaN(expression) ) + ) ? "pass" : "fail" ); - testcases[tc++] = new TestCase( - SECTION, - "verify that while expression was evaluated (should be "+ - object.whileExpression +")", - "pass", - (object.whileExpression == expression || - ( isNaN(object.whileExpression) && isNaN(expression) ) - ) ? "pass" : "fail" ); - - testcases[tc++] = new TestCase( - SECTION, - object.description, - "pass", - result ); - } \ No newline at end of file + new TestCase( + SECTION, + object.description, + "pass", + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/while-003.js b/mozilla/js/tests/ecma_2/Statements/while-003.js index 0164f054e6c..0cc3b8afa65 100644 --- a/mozilla/js/tests/ecma_2/Statements/while-003.js +++ b/mozilla/js/tests/ecma_2/Statements/while-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: while-003 * ECMA Section: @@ -8,77 +9,74 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "while-003"; - var VERSION = "ECMA_2"; - var TITLE = "while statement"; +var SECTION = "while-003"; +var VERSION = "ECMA_2"; +var TITLE = "while statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DoWhile( new DoWhileObject( + "while expression is true", + true, + "result = \"pass\";" )); - DoWhile( new DoWhileObject( - "while expression is true", - true, - "result = \"pass\";" )); +DoWhile( new DoWhileObject( + "while expression is 1", + 1, + "result = \"pass\";" )); - DoWhile( new DoWhileObject( - "while expression is 1", - 1, - "result = \"pass\";" )); +DoWhile( new DoWhileObject( + "while expression is new Boolean(false)", + new Boolean(false), + "result = \"pass\";" )); - DoWhile( new DoWhileObject( - "while expression is new Boolean(false)", - new Boolean(false), - "result = \"pass\";" )); +DoWhile( new DoWhileObject( + "while expression is new Object()", + new Object(), + "result = \"pass\";" )); - DoWhile( new DoWhileObject( - "while expression is new Object()", - new Object(), - "result = \"pass\";" )); - - DoWhile( new DoWhileObject( - "while expression is \"hi\"", - "hi", - "result = \"pass\";" )); +DoWhile( new DoWhileObject( + "while expression is \"hi\"", + "hi", + "result = \"pass\";" )); /* - DoWhile( new DoWhileObject( - "while expression has a continue in it", - "true", - "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";" - )); + DoWhile( new DoWhileObject( + "while expression has a continue in it", + "true", + "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";" + )); */ - test(); +test(); - function DoWhileObject( d, e, s ) { - this.description = d; - this.whileExpression = e; - this.statements = s; - } +function DoWhileObject( d, e, s ) { + this.description = d; + this.whileExpression = e; + this.statements = s; +} - function DoWhile( object ) { - result = "fail: statements in while block were not evaluated"; +function DoWhile( object ) { + result = "fail: statements in while block were not evaluated"; - while ( expression = object.whileExpression ) { - eval( object.statements ); - break; - } + while ( expression = object.whileExpression ) { + eval( object.statements ); + break; + } - // verify that the while expression was evaluated + // verify that the while expression was evaluated - testcases[tc++] = new TestCase( - SECTION, - "verify that while expression was evaluated (should be "+ - object.whileExpression +")", - "pass", - (object.whileExpression == expression || - ( isNaN(object.whileExpression) && isNaN(expression) ) - ) ? "pass" : "fail" ); + new TestCase( + SECTION, + "verify that while expression was evaluated (should be "+ + object.whileExpression +")", + "pass", + (object.whileExpression == expression || + ( isNaN(object.whileExpression) && isNaN(expression) ) + ) ? "pass" : "fail" ); - testcases[tc++] = new TestCase( - SECTION, - object.description, - "pass", - result ); - } \ No newline at end of file + new TestCase( + SECTION, + object.description, + "pass", + result ); +} diff --git a/mozilla/js/tests/ecma_2/Statements/while-004.js b/mozilla/js/tests/ecma_2/Statements/while-004.js index 48faeb0cda9..61dcaf629c6 100644 --- a/mozilla/js/tests/ecma_2/Statements/while-004.js +++ b/mozilla/js/tests/ecma_2/Statements/while-004.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: while-004 * ECMA Section: @@ -6,209 +7,206 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "while-004"; - var VERSION = "ECMA_2"; - var TITLE = "while statement"; - var BUGNUMBER="316725"; +var SECTION = "while-004"; +var VERSION = "ECMA_2"; +var TITLE = "while statement"; +var BUGNUMBER="316725"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); +DoWhile_1(); +DoWhile_2(); +DoWhile_3(); +DoWhile_4(); +DoWhile_5(); - DoWhile_1(); - DoWhile_2(); - DoWhile_3(); - DoWhile_4(); - DoWhile_5(); +test(); - test(); +/** + * Break out of a while by calling return. + * + * Tests: 12.6.2 step 6. + */ +function dowhile() { + result = "pass"; - /** - * Break out of a while by calling return. - * - * Tests: 12.6.2 step 6. - */ - function dowhile() { - result = "pass"; + while (true) { + return result; + result = "fail: hit code after return statement"; + break; + } +} - while (true) { - return result; - result = "fail: hit code after return statement"; - break; - } +function DoWhile_1() { + description = "return statement in a while block"; + + result = dowhile(); + + new TestCase( + SECTION, + "DoWhile_1" + description, + "pass", + result ); +} + +/** + * While with a labeled continue statement. Verify that statements + * after the continue statement are not evaluated. + * + * Tests: 12.6.2 step 8. + * + */ +function DoWhile_2() { + var description = "while with a labeled continue statement"; + var result1 = "pass"; + var result2 = "fail: did not execute code after loop, but inside label"; + var i = 0; + var j = 0; + +theloop: + while( i++ < 10 ) { + j++; + continue theloop; + result1 = "failed: hit code after continue statement"; + } + result2 = "pass"; + + new TestCase( + SECTION, + "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")", + true, + j == 10 ); + + new TestCase( + SECTION, + "DoWhile_2: " +description +" - code after labeled continue should not be executed", + "pass", + result1 ); + + new TestCase( + SECTION, + "DoWhile_2: " +description +" - code after loop but inside label should be executed", + "pass", + result2 ); +} + +/** + * While with a labeled break. + * + */ +function DoWhile_3() { + var description = "while with a labeled break statement"; + var result1 = "pass"; + var result2 = "pass"; + var result3 = "fail: did not get to code after label"; + +woohoo: { + while( true ) { + break woohoo; + result1 = "fail: got to code after a break"; } + result2 = "fail: got to code outside of loop but inside label"; + } - function DoWhile_1() { - description = "return statement in a while block"; + result3 = "pass"; - result = dowhile(); + new TestCase( + SECTION, + "DoWhile_3: " +description +" - verify break out of loop", + "pass", + result1 ); - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_1" + description, - "pass", - result ); + + new TestCase( + SECTION, + "DoWhile_3: " +description +" - verify break out of label", + "pass", + result2 ); + + new TestCase( + SECTION, + "DoWhile_3: " +description + " - verify correct exit from label", + "pass", + result3 ); +} + + +/** + * Labled while with an unlabeled break + * + */ +function DoWhile_4() { + var description = "labeled while with an unlabeled break"; + var result1 = "pass"; + var result2 = "pass"; + var result3 = "fail: did not evaluate statement after label"; + +woohooboy: { + while( true ) { + break woohooboy; + result1 = "fail: got to code after the break"; } + result2 = "fail: broke out of while, but not out of label"; + } + result3 = "pass"; - /** - * While with a labeled continue statement. Verify that statements - * after the continue statement are not evaluated. - * - * Tests: 12.6.2 step 8. - * - */ - function DoWhile_2() { - var description = "while with a labeled continue statement"; - var result1 = "pass"; - var result2 = "fail: did not execute code after loop, but inside label"; - var i = 0; - var j = 0; + new TestCase( + SECTION, + "DoWhile_4: " +description +" - verify break out of while loop", + "pass", + result1 ); - theloop: - while( i++ < 10 ) { - j++; - continue theloop; - result1 = "failed: hit code after continue statement"; - } - result2 = "pass"; + new TestCase( + SECTION, + "DoWhile_4: " +description + " - verify break out of label", + "pass", + result2 ); - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")", - true, - j == 10 ); + new TestCase( + SECTION, + "DoWhile_4: " +description +" - verify that statements after label are evaluated", + "pass", + result3 ); +} - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_2: " +description +" - code after labeled continue should not be executed", - "pass", - result1 ); +/** + * in this case, should behave the same way as + * + * + */ +function DoWhile_5() { + var description = "while with a labeled continue statement"; + var result1 = "pass"; + var result2 = "fail: did not execute code after loop, but inside label"; + var i = 0; + var j = 0; - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_2: " +description +" - code after loop but inside label should be executed", - "pass", - result2 ); +theloop: { + j++; + while( i++ < 10 ) { + continue; + result1 = "failed: hit code after continue statement"; } + result2 = "pass"; + } - /** - * While with a labeled break. - * - */ - function DoWhile_3() { - var description = "while with a labeled break statement"; - var result1 = "pass"; - var result2 = "pass"; - var result3 = "fail: did not get to code after label"; + new TestCase( + SECTION, + "DoWhile_5: " +description + " - continue should not execute statements above the loop", + true, + ( j == 1 ) ); - woohoo: { - while( true ) { - break woohoo; - result1 = "fail: got to code after a break"; - } - result2 = "fail: got to code outside of loop but inside label"; - } + new TestCase( + SECTION, + "DoWhile_5: " +description +" - code after labeled continue should not be executed", + "pass", + result1 ); - result3 = "pass"; - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_3: " +description +" - verify break out of loop", - "pass", - result1 ); - - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_3: " +description +" - verify break out of label", - "pass", - result2 ); - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_3: " +description + " - verify correct exit from label", - "pass", - result3 ); - } - - - /** - * Labled while with an unlabeled break - * - */ - function DoWhile_4() { - var description = "labeled while with an unlabeled break"; - var result1 = "pass"; - var result2 = "pass"; - var result3 = "fail: did not evaluate statement after label"; - - woohooboy: { - while( true ) { - break woohooboy; - result1 = "fail: got to code after the break"; - } - result2 = "fail: broke out of while, but not out of label"; - } - result3 = "pass"; - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_4: " +description +" - verify break out of while loop", - "pass", - result1 ); - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_4: " +description + " - verify break out of label", - "pass", - result2 ); - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_4: " +description +" - verify that statements after label are evaluated", - "pass", - result3 ); - } - - /** - * in this case, should behave the same way as - * - * - */ - function DoWhile_5() { - var description = "while with a labeled continue statement"; - var result1 = "pass"; - var result2 = "fail: did not execute code after loop, but inside label"; - var i = 0; - var j = 0; - - theloop: { - j++; - while( i++ < 10 ) { - continue; - result1 = "failed: hit code after continue statement"; - } - result2 = "pass"; - } - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_5: " +description + " - continue should not execute statements above the loop", - true, - ( j == 1 ) ); - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_5: " +description +" - code after labeled continue should not be executed", - "pass", - result1 ); - - testcases[tc++] = new TestCase( - SECTION, - "DoWhile_5: " +description +" - code after loop but inside label should be executed", - "pass", - result2 ); - } + new TestCase( + SECTION, + "DoWhile_5: " +description +" - code after loop but inside label should be executed", + "pass", + result2 ); +} diff --git a/mozilla/js/tests/ecma_2/String/browser.js b/mozilla/js/tests/ecma_2/String/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/String/match-001.js b/mozilla/js/tests/ecma_2/String/match-001.js index 738264eea63..7edf2af08fb 100644 --- a/mozilla/js/tests/ecma_2/String/match-001.js +++ b/mozilla/js/tests/ecma_2/String/match-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: String/match-001.js * ECMA Section: 15.6.4.9 @@ -29,72 +30,72 @@ * transferred to other kinds of objects for use as a method. */ - var SECTION = "String/match-001.js"; - var VERSION = "ECMA_2"; - var TITLE = "String.prototype.match( regexp )"; +var SECTION = "String/match-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.match( regexp )"; - startTest(); +startTest(); - // the regexp argument is not a RegExp object - // this is not a string object +// the regexp argument is not a RegExp object +// this is not a string object - // cases in which the regexp global property is false +// cases in which the regexp global property is false - AddRegExpCases( 3, "3", "1234567890", 1, 2, ["3"] ); +AddRegExpCases( 3, "3", "1234567890", 1, 2, ["3"] ); - // cases in which the regexp object global property is true +// cases in which the regexp object global property is true - AddGlobalRegExpCases( /34/g, "/34/g", "343443444", 3, ["34", "34", "34"] ); - AddGlobalRegExpCases( /\d{1}/g, "/d{1}/g", "123456abcde7890", 10, - ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] ); +AddGlobalRegExpCases( /34/g, "/34/g", "343443444", 3, ["34", "34", "34"] ); +AddGlobalRegExpCases( /\d{1}/g, "/d{1}/g", "123456abcde7890", 10, + ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] ); - AddGlobalRegExpCases( /\d{2}/g, "/d{2}/g", "123456abcde7890", 5, - ["12", "34", "56", "78", "90"] ); +AddGlobalRegExpCases( /\d{2}/g, "/d{2}/g", "123456abcde7890", 5, + ["12", "34", "56", "78", "90"] ); - AddGlobalRegExpCases( /\D{2}/g, "/d{2}/g", "123456abcde7890", 2, - ["ab", "cd"] ); +AddGlobalRegExpCases( /\D{2}/g, "/d{2}/g", "123456abcde7890", 2, + ["ab", "cd"] ); - test(); +test(); function AddRegExpCases( - regexp, str_regexp, string, length, index, matches_array ) { + regexp, str_regexp, string, length, index, matches_array ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + string, + string.match(regexp).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - length, - string.match(regexp).length ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - string, - string.match(regexp).input ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } } function AddGlobalRegExpCases( - regexp, str_regexp, string, length, matches_array ) { + regexp, str_regexp, string, length, matches_array ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + length, + string.match(regexp).length ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - length, - string.match(regexp).length ); - - for ( var matches = 0; matches < matches_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/String/match-002.js b/mozilla/js/tests/ecma_2/String/match-002.js index 83ac2fa4bde..aac35cc7374 100644 --- a/mozilla/js/tests/ecma_2/String/match-002.js +++ b/mozilla/js/tests/ecma_2/String/match-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: String/match-002.js * ECMA Section: 15.6.4.9 @@ -33,136 +34,136 @@ * */ - var SECTION = "String/match-002.js"; - var VERSION = "ECMA_2"; - var TITLE = "String.prototype.match( regexp )"; +var SECTION = "String/match-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.match( regexp )"; - startTest(); +startTest(); - // the regexp argument is not a RegExp object - // this is not a string object +// the regexp argument is not a RegExp object +// this is not a string object - AddRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/, - "/([\d]{5})([-\ ]?[\d]{4})?$/", - "Boston, Mass. 02134", - 14, - ["02134", "02134", undefined]); +AddRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/, + "/([\d]{5})([-\ ]?[\d]{4})?$/", + "Boston, Mass. 02134", + 14, + ["02134", "02134", undefined]); - AddGlobalRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/g, - "/([\d]{5})([-\ ]?[\d]{4})?$/g", - "Boston, Mass. 02134", - ["02134"]); +AddGlobalRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/g, + "/([\d]{5})([-\ ]?[\d]{4})?$/g", + "Boston, Mass. 02134", + ["02134"]); - // set the value of lastIndex - re = /([\d]{5})([-\ ]?[\d]{4})?$/; - re.lastIndex = 0; +// set the value of lastIndex +re = /([\d]{5})([-\ ]?[\d]{4})?$/; +re.lastIndex = 0; - s = "Boston, MA 02134"; +s = "Boston, MA 02134"; - AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex =0", - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); +AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex =0", + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); - re.lastIndex = s.length; +re.lastIndex = s.length; - AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.length, - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined] ); +AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.length, + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined] ); - re.lastIndex = s.lastIndexOf("0"); +re.lastIndex = s.lastIndexOf("0"); - AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.lastIndexOf("0"), - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); +AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0"), + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); - re.lastIndex = s.lastIndexOf("0") + 1; +re.lastIndex = s.lastIndexOf("0") + 1; - AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.lastIndexOf("0") +1, - s, - s.lastIndexOf("0"), - ["02134", "02134", undefined]); +AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0") +1, + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); - test(); +test(); function AddRegExpCases( - regexp, str_regexp, string, index, matches_array ) { + regexp, str_regexp, string, index, matches_array ) { // prevent a runtime error - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - + if ( regexp.exec(string) == null || matches_array == null ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); + string + ".match(" + regexp +")", + matches_array, + string.match(regexp) ); + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + string, + string.match(regexp).input ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - string, - string.match(regexp).input ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } } function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { + regexp, str_regexp, string, matches_array ) { // prevent a runtime error - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + string +")", - matches_array, - regexp.exec(string) ); - - return; - } - + if ( regexp.exec(string) == null || matches_array == null ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); + regexp + ".exec(" + string +")", + matches_array, + regexp.exec(string) ); - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; + return; + } - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/String/match-003.js b/mozilla/js/tests/ecma_2/String/match-003.js index f63e9e28c5b..995941b746a 100644 --- a/mozilla/js/tests/ecma_2/String/match-003.js +++ b/mozilla/js/tests/ecma_2/String/match-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: String/match-003.js * ECMA Section: 15.6.4.9 @@ -29,14 +30,14 @@ * transferred to other kinds of objects for use as a method. */ - var SECTION = "String/match-003.js"; - var VERSION = "ECMA_2"; - var TITLE = "String.prototype.match( regexp )"; +var SECTION = "String/match-003.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.match( regexp )"; - startTest(); +startTest(); - // the regexp argument is not a RegExp object - // this is not a string object +// the regexp argument is not a RegExp object +// this is not a string object // [if regexp.global is true] set the regexp.lastIndex property to 0 and @@ -48,79 +49,79 @@ // of RegExp.prototype.exec. - // set the value of lastIndex - re = /([\d]{5})([-\ ]?[\d]{4})?$/g; +// set the value of lastIndex +re = /([\d]{5})([-\ ]?[\d]{4})?$/g; - s = "Boston, MA 02134"; +s = "Boston, MA 02134"; - AddGlobalRegExpCases( re, - "re = " + re, - s, - ["02134" ]); +AddGlobalRegExpCases( re, + "re = " + re, + s, + ["02134" ]); - re.lastIndex = 0; +re.lastIndex = 0; - AddGlobalRegExpCases( - re, - "re = " + re + "; re.lastIndex = 0 ", - s, - ["02134"]); +AddGlobalRegExpCases( + re, + "re = " + re + "; re.lastIndex = 0 ", + s, + ["02134"]); - re.lastIndex = s.length; +re.lastIndex = s.length; - AddGlobalRegExpCases( - re, - "re = " + re + "; re.lastIndex = " + s.length, - s, - ["02134"] ); +AddGlobalRegExpCases( + re, + "re = " + re + "; re.lastIndex = " + s.length, + s, + ["02134"] ); - re.lastIndex = s.lastIndexOf("0"); +re.lastIndex = s.lastIndexOf("0"); - AddGlobalRegExpCases( - re, - "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"), - s, - ["02134"]); +AddGlobalRegExpCases( + re, + "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"), + s, + ["02134"]); - re.lastIndex = s.lastIndexOf("0") + 1; +re.lastIndex = s.lastIndexOf("0") + 1; - AddGlobalRegExpCases( - re, - "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1), - s, - ["02134"]); +AddGlobalRegExpCases( + re, + "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1), + s, + ["02134"]); - test(); +test(); function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { + regexp, str_regexp, string, matches_array ) { // prevent a runtime error - if ( string.match(regexp) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + str_regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - + if ( string.match(regexp) == null || matches_array == null ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); + string + ".match(" + str_regexp +")", + matches_array, + string.match(regexp) ); - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; + return; + } - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/String/match-004.js b/mozilla/js/tests/ecma_2/String/match-004.js index c35d9889fb4..9f8febe444e 100644 --- a/mozilla/js/tests/ecma_2/String/match-004.js +++ b/mozilla/js/tests/ecma_2/String/match-004.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: String/match-004.js * ECMA Section: 15.6.4.9 @@ -34,134 +35,134 @@ * */ - var SECTION = "String/match-004.js"; - var VERSION = "ECMA_2"; - var TITLE = "String.prototype.match( regexp )"; +var SECTION = "String/match-004.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.match( regexp )"; - var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=345818"; +var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=345818"; - startTest(); +startTest(); - // set the value of lastIndex - re = /0./; - s = 10203040506070809000; +// set the value of lastIndex +re = /0./; +s = 10203040506070809000; - Number.prototype.match = String.prototype.match; +Number.prototype.match = String.prototype.match; - AddRegExpCases( re, - "re = " + re , - s, - String(s), - 1, - ["02"]); +AddRegExpCases( re, + "re = " + re , + s, + String(s), + 1, + ["02"]); - re.lastIndex = 0; - AddRegExpCases( re, - "re = " + re +" [lastIndex is " + re.lastIndex+"]", - s, - String(s), - 1, - ["02"]); +re.lastIndex = 0; +AddRegExpCases( re, + "re = " + re +" [lastIndex is " + re.lastIndex+"]", + s, + String(s), + 1, + ["02"]); /* - re.lastIndex = s.length; +re.lastIndex = s.length; - AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.length, - s, - s.lastIndexOf("0"), - null ); +AddRegExpCases( re, +"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + +s.length, +s, +s.lastIndexOf("0"), +null ); - re.lastIndex = s.lastIndexOf("0"); +re.lastIndex = s.lastIndexOf("0"); - AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.lastIndexOf("0"), - s, - s.lastIndexOf("0"), - ["02134"]); +AddRegExpCases( re, +"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + +s.lastIndexOf("0"), +s, +s.lastIndexOf("0"), +["02134"]); - re.lastIndex = s.lastIndexOf("0") + 1; +re.lastIndex = s.lastIndexOf("0") + 1; - AddRegExpCases( re, - "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + - s.lastIndexOf("0") +1, - s, - 0, - null); +AddRegExpCases( re, +"re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + +s.lastIndexOf("0") +1, +s, +0, +null); */ - test(); +test(); function AddRegExpCases( - regexp, str_regexp, string, str_string, index, matches_array ) { + regexp, str_regexp, string, str_string, index, matches_array ) { // prevent a runtime error - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - string + ".match(" + regexp +")", - matches_array, - string.match(regexp) ); - - return; - } - + if ( regexp.exec(string) == null || matches_array == null ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); + string + ".match(" + regexp +")", + matches_array, + string.match(regexp) ); + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + str_string, + string.match(regexp).input ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").index", - index, - string.match(regexp).index ); - - AddTestCase( - "( " + string + " ).match(" + str_regexp +").input", - str_string, - string.match(regexp).input ); - - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; - - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } } function AddGlobalRegExpCases( - regexp, str_regexp, string, matches_array ) { + regexp, str_regexp, string, matches_array ) { // prevent a runtime error - if ( regexp.exec(string) == null || matches_array == null ) { - AddTestCase( - regexp + ".exec(" + string +")", - matches_array, - regexp.exec(string) ); - - return; - } - + if ( regexp.exec(string) == null || matches_array == null ) { AddTestCase( - "( " + string + " ).match(" + str_regexp +").length", - matches_array.length, - string.match(regexp).length ); + regexp + ".exec(" + string +")", + matches_array, + regexp.exec(string) ); - var limit = matches_array.length > string.match(regexp).length ? - matches_array.length : - string.match(regexp).length; + return; + } - for ( var matches = 0; matches < limit; matches++ ) { - AddTestCase( - "( " + string + " ).match(" + str_regexp +")[" + matches +"]", - matches_array[matches], - string.match(regexp)[matches] ); - } + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/String/replace-001.js b/mozilla/js/tests/ecma_2/String/replace-001.js index 5ff8dc098c7..46a076005cf 100644 --- a/mozilla/js/tests/ecma_2/String/replace-001.js +++ b/mozilla/js/tests/ecma_2/String/replace-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: String/replace-001.js * ECMA Section: 15.6.4.10 @@ -7,54 +8,54 @@ * Date: 19 February 1999 */ - var SECTION = "String/replace-001.js"; - var VERSION = "ECMA_2"; - var TITLE = "String.prototype.replace( regexp, replaceValue )"; +var SECTION = "String/replace-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.replace( regexp, replaceValue )"; - startTest(); +startTest(); - /* - * If regexp is not an object of type RegExp, it is replaced with the - * result of the expression new RegExp(regexp). Let string denote the - * result of converting the this value to a string. String is searched - * for the first occurrence of the regular expression pattern regexp if - * regexp.global is false, or all occurrences if regexp.global is true. - * - * The match is performed as in String.prototype.match, including the - * update of regexp.lastIndex. Let m be the number of matched - * parenthesized subexpressions as specified in section 15.7.5.3. - * - * If replaceValue is a function, then for each matched substring, call - * the function with the following m + 3 arguments. Argument 1 is the - * substring that matched. The next m arguments are all of the matched - * subexpressions. Argument m + 2 is the length of the left context, and - * argument m + 3 is string. - * - * The result is a string value derived from the original input by - * replacing each matched substring with the corresponding return value - * of the function call, converted to a string if need be. - * - * Otherwise, let newstring denote the result of converting replaceValue - * to a string. The result is a string value derived from the original - * input string by replacing each matched substring with a string derived - * from newstring by replacing characters in newstring by replacement text - * as specified in the following table: - * - * $& The matched substring. - * $‘ The portion of string that precedes the matched substring. - * $’ The portion of string that follows the matched substring. - * $+ The substring matched by the last parenthesized subexpressions in - * the regular expression. - * $n The corresponding matched parenthesized subexpression n, where n - * is a single digit 0-9. If there are fewer than n subexpressions, “$n - * is left unchanged. - * - * Note that the replace function is intentionally generic; it does not - * require that its this value be a string object. Therefore, it can be - * transferred to other kinds of objects for use as a method. - */ +/* + * If regexp is not an object of type RegExp, it is replaced with the + * result of the expression new RegExp(regexp). Let string denote the + * result of converting the this value to a string. String is searched + * for the first occurrence of the regular expression pattern regexp if + * regexp.global is false, or all occurrences if regexp.global is true. + * + * The match is performed as in String.prototype.match, including the + * update of regexp.lastIndex. Let m be the number of matched + * parenthesized subexpressions as specified in section 15.7.5.3. + * + * If replaceValue is a function, then for each matched substring, call + * the function with the following m + 3 arguments. Argument 1 is the + * substring that matched. The next m arguments are all of the matched + * subexpressions. Argument m + 2 is the length of the left context, and + * argument m + 3 is string. + * + * The result is a string value derived from the original input by + * replacing each matched substring with the corresponding return value + * of the function call, converted to a string if need be. + * + * Otherwise, let newstring denote the result of converting replaceValue + * to a string. The result is a string value derived from the original + * input string by replacing each matched substring with a string derived + * from newstring by replacing characters in newstring by replacement text + * as specified in the following table: + * + * $& The matched substring. + * $‘ The portion of string that precedes the matched substring. + * $’ The portion of string that follows the matched substring. + * $+ The substring matched by the last parenthesized subexpressions in + * the regular expression. + * $n The corresponding matched parenthesized subexpression n, where n + * is a single digit 0-9. If there are fewer than n subexpressions, “$n + * is left unchanged. + * + * Note that the replace function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ - testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" }; +// testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" }; - test(); +test(); diff --git a/mozilla/js/tests/ecma_2/String/shell.js b/mozilla/js/tests/ecma_2/String/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/String/split-001.js b/mozilla/js/tests/ecma_2/String/split-001.js index b2d7c9c6bdd..eae00b8e572 100644 --- a/mozilla/js/tests/ecma_2/String/split-001.js +++ b/mozilla/js/tests/ecma_2/String/split-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: String/split-001.js * ECMA Section: 15.6.4.9 @@ -24,83 +25,83 @@ * */ - var SECTION = "ecma_2/String/split-001.js"; - var VERSION = "ECMA_2"; - var TITLE = "String.prototype.split( regexp, [,limit] )"; +var SECTION = "ecma_2/String/split-001.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.split( regexp, [,limit] )"; - startTest(); +startTest(); - // the separator is not supplied - // separator is undefined - // separator is an empty string +// the separator is not supplied +// separator is undefined +// separator is an empty string - AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); - AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); +AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); +AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); - // separartor is a regexp - // separator regexp value global setting is set - // string is an empty string - // if separator is an empty string, split each by character +// separartor is a regexp +// separator regexp value global setting is set +// string is an empty string +// if separator is an empty string, split each by character - // this is not a String object +// this is not a String object - // limit is not a number - // limit is undefined - // limit is larger than 2^32-1 - // limit is a negative number +// limit is not a number +// limit is undefined +// limit is larger than 2^32-1 +// limit is a negative number - test(); +test(); function AddSplitCases( string, separator, str_sep, split_array ) { - // verify that the result of split is an object of type Array + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +").constructor == Array", + true, + string.split(separator).constructor == Array ); + + // check the number of items in the array + AddTestCase( + "( " + string + " ).split(" + str_sep +").length", + split_array.length, + string.split(separator).length ); + + // check the value of each array item + var limit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator).length; + + for ( var matches = 0; matches < split_array.length; matches++ ) { AddTestCase( - "( " + string + " ).split(" + str_sep +").constructor == Array", - true, - string.split(separator).constructor == Array ); - - // check the number of items in the array - AddTestCase( - "( " + string + " ).split(" + str_sep +").length", - split_array.length, - string.split(separator).length ); - - // check the value of each array item - var limit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator).length; - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +")[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } + "( " + string + " ).split(" + str_sep +")[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } } function AddLimitedSplitCases( - string, separator, str_sep, limit, str_limit, split_array ) { + string, separator, str_sep, limit, str_limit, split_array ) { - // verify that the result of split is an object of type Array + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + + " ).constructor == Array", + true, + string.split(separator, limit).constructor == Array ); + + // check the length of the array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + " ).length", + length, + string.split(separator).length ); + + // check the value of each array item + + for ( var matches = 0; matches < split_array.length; matches++ ) { AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + - " ).constructor == Array", - true, - string.split(separator, limit).constructor == Array ); - - // check the length of the array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + " ).length", - length, - string.split(separator).length ); - - // check the value of each array item - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + str_limit + " )[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } + "( " + string + " ).split(" + str_sep +", " + str_limit + " )[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/String/split-002.js b/mozilla/js/tests/ecma_2/String/split-002.js index 1007a3143cc..16df9e064bf 100644 --- a/mozilla/js/tests/ecma_2/String/split-002.js +++ b/mozilla/js/tests/ecma_2/String/split-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: String/split-002.js * ECMA Section: 15.6.4.9 @@ -24,241 +25,241 @@ * */ - var SECTION = "ecma_2/String/split-002.js"; - var VERSION = "ECMA_2"; - var TITLE = "String.prototype.split( regexp, [,limit] )"; +var SECTION = "ecma_2/String/split-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.split( regexp, [,limit] )"; - startTest(); +startTest(); - // the separator is not supplied - // separator is undefined - // separator is an empty string +// the separator is not supplied +// separator is undefined +// separator is an empty string // AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); // AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); - // separator is an empty regexp - // separator is not supplied +// separator is an empty regexp +// separator is not supplied - CompareSplit( "hello", "ll" ); +CompareSplit( "hello", "ll" ); - CompareSplit( "hello", "l" ); - CompareSplit( "hello", "x" ); - CompareSplit( "hello", "h" ); - CompareSplit( "hello", "o" ); - CompareSplit( "hello", "hello" ); - CompareSplit( "hello", undefined ); +CompareSplit( "hello", "l" ); +CompareSplit( "hello", "x" ); +CompareSplit( "hello", "h" ); +CompareSplit( "hello", "o" ); +CompareSplit( "hello", "hello" ); +CompareSplit( "hello", undefined ); - CompareSplit( "hello", ""); - CompareSplit( "hello", "hellothere" ); +CompareSplit( "hello", ""); +CompareSplit( "hello", "hellothere" ); - CompareSplit( new String("hello" ) ); +CompareSplit( new String("hello" ) ); - Number.prototype.split = String.prototype.split; +Number.prototype.split = String.prototype.split; - CompareSplit( new Number(100111122133144155), 1 ); - CompareSplitWithLimit(new Number(100111122133144155), 1, 1 ); +CompareSplit( new Number(100111122133144155), 1 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, 1 ); - CompareSplitWithLimit(new Number(100111122133144155), 1, 2 ); - CompareSplitWithLimit(new Number(100111122133144155), 1, 0 ); - CompareSplitWithLimit(new Number(100111122133144155), 1, 100 ); - CompareSplitWithLimit(new Number(100111122133144155), 1, void 0 ); - CompareSplitWithLimit(new Number(100111122133144155), 1, Math.pow(2,32)-1 ); - CompareSplitWithLimit(new Number(100111122133144155), 1, "boo" ); - CompareSplitWithLimit(new Number(100111122133144155), 1, -(Math.pow(2,32)-1) ); - CompareSplitWithLimit( "hello", "l", NaN ); - CompareSplitWithLimit( "hello", "l", 0 ); - CompareSplitWithLimit( "hello", "l", 1 ); - CompareSplitWithLimit( "hello", "l", 2 ); - CompareSplitWithLimit( "hello", "l", 3 ); - CompareSplitWithLimit( "hello", "l", 4 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, 2 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, 0 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, 100 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, void 0 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, Math.pow(2,32)-1 ); +CompareSplitWithLimit(new Number(100111122133144155), 1, "boo" ); +CompareSplitWithLimit(new Number(100111122133144155), 1, -(Math.pow(2,32)-1) ); +CompareSplitWithLimit( "hello", "l", NaN ); +CompareSplitWithLimit( "hello", "l", 0 ); +CompareSplitWithLimit( "hello", "l", 1 ); +CompareSplitWithLimit( "hello", "l", 2 ); +CompareSplitWithLimit( "hello", "l", 3 ); +CompareSplitWithLimit( "hello", "l", 4 ); /* - CompareSplitWithLimit( "hello", "ll", 0 ); - CompareSplitWithLimit( "hello", "ll", 1 ); - CompareSplitWithLimit( "hello", "ll", 2 ); - CompareSplit( "", " " ); - CompareSplit( "" ); + CompareSplitWithLimit( "hello", "ll", 0 ); + CompareSplitWithLimit( "hello", "ll", 1 ); + CompareSplitWithLimit( "hello", "ll", 2 ); + CompareSplit( "", " " ); + CompareSplit( "" ); */ - // separartor is a regexp - // separator regexp value global setting is set - // string is an empty string - // if separator is an empty string, split each by character +// separartor is a regexp +// separator regexp value global setting is set +// string is an empty string +// if separator is an empty string, split each by character - // this is not a String object +// this is not a String object - // limit is not a number - // limit is undefined - // limit is larger than 2^32-1 - // limit is a negative number +// limit is not a number +// limit is undefined +// limit is larger than 2^32-1 +// limit is a negative number - test(); +test(); function CompareSplit( string, separator ) { - split_1 = string.split( separator ); - split_2 = string_split( string, separator ); + split_1 = string.split( separator ); + split_2 = string_split( string, separator ); + AddTestCase( + "( " + string +".split(" + separator + ") ).length" , + split_2.length, + split_1.length ); + + var limit = split_1.length > split_2.length ? + split_1.length : split_2.length; + + for ( var split_item = 0; split_item < limit; split_item++ ) { AddTestCase( - "( " + string +".split(" + separator + ") ).length" , - split_2.length, - split_1.length ); - - var limit = split_1.length > split_2.length ? - split_1.length : split_2.length; - - for ( var split_item = 0; split_item < limit; split_item++ ) { - AddTestCase( - string + ".split(" + separator + ")["+split_item+"]", - split_2[split_item], - split_1[split_item] ); - } + string + ".split(" + separator + ")["+split_item+"]", + split_2[split_item], + split_1[split_item] ); + } } function CompareSplitWithLimit( string, separator, splitlimit ) { - split_1 = string.split( separator, splitlimit ); - split_2 = string_split( string, separator, splitlimit ); + split_1 = string.split( separator, splitlimit ); + split_2 = string_split( string, separator, splitlimit ); + AddTestCase( + "( " + string +".split(" + separator + ", " + splitlimit+") ).length" , + split_2.length, + split_1.length ); + + var limit = split_1.length > split_2.length ? + split_1.length : split_2.length; + + for ( var split_item = 0; split_item < limit; split_item++ ) { AddTestCase( - "( " + string +".split(" + separator + ", " + splitlimit+") ).length" , - split_2.length, - split_1.length ); - - var limit = split_1.length > split_2.length ? - split_1.length : split_2.length; - - for ( var split_item = 0; split_item < limit; split_item++ ) { - AddTestCase( - string + ".split(" + separator + ", " + splitlimit+")["+split_item+"]", - split_2[split_item], - split_1[split_item] ); - } + string + ".split(" + separator + ", " + splitlimit+")["+split_item+"]", + split_2[split_item], + split_1[split_item] ); + } } function string_split ( __this, separator, limit ) { - var S = String(__this ); // 1 + var S = String(__this ); // 1 - var A = new Array(); // 2 + var A = new Array(); // 2 - if ( limit == undefined ) { // 3 - lim = Math.pow(2, 31 ) -1; - } else { - lim = ToUint32( limit ); - } + if ( limit == undefined ) { // 3 + lim = Math.pow(2, 31 ) -1; + } else { + lim = ToUint32( limit ); + } - var s = S.length; // 4 - var p = 0; // 5 + var s = S.length; // 4 + var p = 0; // 5 - if ( separator == undefined ) { // 8 - A[0] = S; - return A; - } + if ( separator == undefined ) { // 8 + A[0] = S; + return A; + } - if ( separator.constructor == RegExp ) // 6 - R = separator; - else - R = separator.toString(); + if ( separator.constructor == RegExp ) // 6 + R = separator; + else + R = separator.toString(); - if (lim == 0) return A; // 7 + if (lim == 0) return A; // 7 - if ( separator == undefined ) { // 8 - A[0] = S; - return A; - } + if ( separator == undefined ) { // 8 + A[0] = S; + return A; + } - if (s == 0) { // 9 - z = SplitMatch(R, S, 0); - if (z != false) return A; - A[0] = S; - return A; - } + if (s == 0) { // 9 + z = SplitMatch(R, S, 0); + if (z != false) return A; + A[0] = S; + return A; + } - var q = p; // 10 + var q = p; // 10 loop: - while (true ) { + while (true ) { - if ( q == s ) break; // 11 + if ( q == s ) break; // 11 - z = SplitMatch(R, S, q); // 12 + z = SplitMatch(R, S, q); // 12 //print("Returned ", z); - if (z != false) { // 13 - e = z.endIndex; // 14 - cap = z.captures; // 14 - if (e != p) { // 15 + if (z != false) { // 13 + e = z.endIndex; // 14 + cap = z.captures; // 14 + if (e != p) { // 15 //print("S = ", S, ", p = ", p, ", q = ", q); - T = S.slice(p, q); // 16 + T = S.slice(p, q); // 16 //print("T = ", T); - A[A.length] = T; // 17 - if (A.length == lim) return A; // 18 - p = e; // 19 - i = 0; // 20 - while (true) { // 25 - if (i == cap.length) { // 21 - q = p; // 10 - continue loop; - } - i = i + 1; // 22 - A[A.length] = cap[i] // 23 - if (A.length == lim) return A; // 24 - } - } - } + A[A.length] = T; // 17 + if (A.length == lim) return A; // 18 + p = e; // 19 + i = 0; // 20 + while (true) { // 25 + if (i == cap.length) { // 21 + q = p; // 10 + continue loop; + } + i = i + 1; // 22 + A[A.length] = cap[i] // 23 + if (A.length == lim) return A; // 24 + } + } + } - q = q + 1; // 26 - } + q = q + 1; // 26 + } - T = S.slice(p, q); - A[A.length] = T; - return A; + T = S.slice(p, q); + A[A.length] = T; + return A; } function SplitMatch(R, S, q) { - if (R.constructor == RegExp) { // 1 - var reResult = R.match(S, q); // 8 - if (reResult == undefined) - return false; - else { - a = new Array(reResult.length - 1); - for (var i = 1; i < reResult.length; i++) - a[a.length] = reResult[i]; - return { endIndex : reResult.index + reResult[0].length, captures : cap }; - } - } - else { - var r = R.length; // 2 - s = S.length; // 3 - if ((q + r) > s) return false; // 4 - for (var i = 0; i < r; i++) { + if (R.constructor == RegExp) { // 1 + var reResult = R.match(S, q); // 8 + if (reResult == undefined) + return false; + else { + a = new Array(reResult.length - 1); + for (var i = 1; i < reResult.length; i++) + a[a.length] = reResult[i]; + return { endIndex : reResult.index + reResult[0].length, captures : cap }; + } + } + else { + var r = R.length; // 2 + s = S.length; // 3 + if ((q + r) > s) return false; // 4 + for (var i = 0; i < r; i++) { //print("S.charAt(", q + i, ") = ", S.charAt(q + i), ", R.charAt(", i, ") = ", R.charAt(i)); - if (S.charAt(q + i) != R.charAt(i)) // 5 - return false; - } - cap = new Array(); // 6 - return { endIndex : q + r, captures : cap }; // 7 - } + if (S.charAt(q + i) != R.charAt(i)) // 5 + return false; + } + cap = new Array(); // 6 + return { endIndex : q + r, captures : cap }; // 7 + } } function ToUint32( n ) { - n = Number( n ); - var sign = ( n < 0 ) ? -1 : 1; + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; - if ( Math.abs( n ) == 0 - || Math.abs( n ) == Number.POSITIVE_INFINITY - || n != n) { - return 0; - } - n = sign * Math.floor( Math.abs(n) ) + if ( Math.abs( n ) == 0 + || Math.abs( n ) == Number.POSITIVE_INFINITY + || n != n) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) n = n % Math.pow(2,32); - if ( n < 0 ){ - n += Math.pow(2,32); - } + if ( n < 0 ){ + n += Math.pow(2,32); + } - return ( n ); + return ( n ); } diff --git a/mozilla/js/tests/ecma_2/String/split-003.js b/mozilla/js/tests/ecma_2/String/split-003.js index e2f2b924bc4..4f8bf34ef62 100644 --- a/mozilla/js/tests/ecma_2/String/split-003.js +++ b/mozilla/js/tests/ecma_2/String/split-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /** * File Name: String/split-003.js * ECMA Section: 15.6.4.9 @@ -24,94 +25,94 @@ * */ - var SECTION = "ecma_2/String/split-003.js"; - var VERSION = "ECMA_2"; - var TITLE = "String.prototype.split( regexp, [,limit] )"; +var SECTION = "ecma_2/String/split-003.js"; +var VERSION = "ECMA_2"; +var TITLE = "String.prototype.split( regexp, [,limit] )"; - startTest(); +startTest(); - // separartor is a regexp - // separator regexp value global setting is set - // string is an empty string - // if separator is an empty string, split each by character +// separator is a regexp +// separator regexp value global setting is set +// string is an empty string +// if separator is an empty string, split each by character - AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); +AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); - AddSplitCases( "hello", /l/, "/l/", ["he","","o"] ); - AddLimitedSplitCases( "hello", /l/, "/l/", 0, [] ); - AddLimitedSplitCases( "hello", /l/, "/l/", 1, ["he"] ); - AddLimitedSplitCases( "hello", /l/, "/l/", 2, ["he",""] ); - AddLimitedSplitCases( "hello", /l/, "/l/", 3, ["he","","o"] ); - AddLimitedSplitCases( "hello", /l/, "/l/", 4, ["he","","o"] ); - AddLimitedSplitCases( "hello", /l/, "/l/", void 0, ["he","","o"] ); - AddLimitedSplitCases( "hello", /l/, "/l/", "hi", [] ); - AddLimitedSplitCases( "hello", /l/, "/l/", undefined, ["he","","o"] ); +AddSplitCases( "hello", /l/, "/l/", ["he","","o"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 0, [] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 1, ["he"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 2, ["he",""] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 3, ["he","","o"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", 4, ["he","","o"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", void 0, ["he","","o"] ); +AddLimitedSplitCases( "hello", /l/, "/l/", "hi", [] ); +AddLimitedSplitCases( "hello", /l/, "/l/", undefined, ["he","","o"] ); - AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); - AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 0, [] ); - AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 1, ["h"] ); - AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 2, ["h","e"] ); - AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 3, ["h","e","l"] ); - AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 4, ["h","e","l","l"] ); - AddLimitedSplitCases( "hello", new RegExp, "new RegExp", void 0, ["h","e","l","l","o"] ); - AddLimitedSplitCases( "hello", new RegExp, "new RegExp", "hi", [] ); - AddLimitedSplitCases( "hello", new RegExp, "new RegExp", undefined, ["h","e","l","l","o"] ); +AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 0, [] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 1, ["h"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 2, ["h","e"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 3, ["h","e","l"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 4, ["h","e","l","l"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", void 0, ["h","e","l","l","o"] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", "hi", [] ); +AddLimitedSplitCases( "hello", new RegExp, "new RegExp", undefined, ["h","e","l","l","o"] ); - test(); +test(); function AddSplitCases( string, separator, str_sep, split_array ) { - // verify that the result of split is an object of type Array + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +").constructor == Array", + true, + string.split(separator).constructor == Array ); + + // check the number of items in the array + AddTestCase( + "( " + string + " ).split(" + str_sep +").length", + split_array.length, + string.split(separator).length ); + + // check the value of each array item + var limit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator).length; + + for ( var matches = 0; matches < split_array.length; matches++ ) { AddTestCase( - "( " + string + " ).split(" + str_sep +").constructor == Array", - true, - string.split(separator).constructor == Array ); - - // check the number of items in the array - AddTestCase( - "( " + string + " ).split(" + str_sep +").length", - split_array.length, - string.split(separator).length ); - - // check the value of each array item - var limit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator).length; - - for ( var matches = 0; matches < split_array.length; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +")[" + matches +"]", - split_array[matches], - string.split( separator )[matches] ); - } + "( " + string + " ).split(" + str_sep +")[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } } function AddLimitedSplitCases( - string, separator, str_sep, limit, split_array ) { + string, separator, str_sep, limit, split_array ) { - // verify that the result of split is an object of type Array + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + + " ).constructor == Array", + true, + string.split(separator, limit).constructor == Array ); + + // check the length of the array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + " ).length", + split_array.length, + string.split(separator, limit).length ); + + // check the value of each array item + + var slimit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator, limit).length; + + for ( var matches = 0; matches < slimit; matches++ ) { AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + - " ).constructor == Array", - true, - string.split(separator, limit).constructor == Array ); - - // check the length of the array - - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + " ).length", - split_array.length, - string.split(separator, limit).length ); - - // check the value of each array item - - var slimit = (split_array.length > string.split(separator).length ) - ? split_array.length : string.split(separator, limit).length; - - for ( var matches = 0; matches < slimit; matches++ ) { - AddTestCase( - "( " + string + " ).split(" + str_sep +", " + limit + " )[" + matches +"]", - split_array[matches], - string.split( separator, limit )[matches] ); - } + "( " + string + " ).split(" + str_sep +", " + limit + " )[" + matches +"]", + split_array[matches], + string.split( separator, limit )[matches] ); + } } diff --git a/mozilla/js/tests/ecma_2/browser.js b/mozilla/js/tests/ecma_2/browser.js index 2083941f784..5b99a652955 100644 --- a/mozilla/js/tests/ecma_2/browser.js +++ b/mozilla/js/tests/ecma_2/browser.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -49,50 +50,78 @@ * */ -onerror = err; - var GLOBAL = "[object Window]"; -function startTest() { - writeHeaderToLog( SECTION + " "+ TITLE); - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; -} - function writeLineToLog( string ) { - document.write( string + "
\n"); + document.write( string + "
\n"); } function writeHeaderToLog( string ) { - document.write( "

" + string + "

" ); + document.write( "

" + string + "

" ); } -function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } - document.write( "
" ); -} -function writeFormattedResult( expect, actual, string, passed ) { - var s = ""+ string ; - s += "" ; - s += ( passed ) ? "  " + PASSED - : " " + FAILED + expect + ""; - writeLineToLog( s + "" ); - return passed; -} -function err( msg, page, line ) { - writeLineToLog( "Test failed on line " + line + " with the message: " + msg ); - testcases[tc].actual = "error"; - testcases[tc].reason = msg; - writeTestCaseResult( testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual + - ": " + testcases[tc].reason ); - stopTest(); - return true; +function writeFormattedResult( expect, actual, string, passed ) { + var s = ""+ string ; + s += "" ; + s += ( passed ) ? "  " + PASSED + : " " + FAILED + expect + ""; + writeLineToLog( s + "" ); + return passed; } + + +/* + * The earlier versions of the test code used exceptions + * to terminate the test script in "negative" test cases + * before the failure reporting code could run. In order + * to be able to capture errors for the "negative" case + * where the exception is a sign the test actually passed, + * the err online handler will assume that any error is a + * failure unless gExceptionExpected is true. + */ +window.onerror = err; +var gExceptionExpected = false; + +function err( msg, page, line ) { + var testcase; + + if (typeof(EXPECTED) == "undefined" || EXPECTED != "error") { + /* + * an unexpected exception occured + */ + writeLineToLog( "Test failed with the message: " + msg ); + testcase = new TestCase(SECTION, "unknown", "unknown", "unknown"); + testcase.passed = false; + testcase.reason = "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + return; + } + + if (typeof SECTION == 'undefined') + { + SECTION = 'Unknown'; + } + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + + testcase = new TestCase(SECTION, DESCRIPTION, EXPECTED, "error"); + testcase.reason += "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + stopTest(); +} + +var gVersion = 0; + +function version(v) +{ + if (v) { + gVersion = v; + } + return gVersion; +} + diff --git a/mozilla/js/tests/ecma_2/instanceof/browser.js b/mozilla/js/tests/ecma_2/instanceof/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/instanceof/instanceof-002.js b/mozilla/js/tests/ecma_2/instanceof/instanceof-002.js index d07292dd4fc..d26759de7e3 100644 --- a/mozilla/js/tests/ecma_2/instanceof/instanceof-002.js +++ b/mozilla/js/tests/ecma_2/instanceof/instanceof-002.js @@ -15,47 +15,31 @@ startTest(); writeHeaderToLog( SECTION + " "+ TITLE); - var tc = 0; - var testcases = new Array(); - var b = new Boolean(); - testcases[tc++] = new TestCase( SECTION, - "var b = new Boolean(); b instanceof Boolean", - true, - b instanceof Boolean ); + new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); - testcases[tc++] = new TestCase( SECTION, - "b instanceof Object", - true, - b instanceof Object ); + new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); - testcases[tc++] = new TestCase( SECTION, - "b instanceof Array", - false, - b instanceof Array ); + new TestCase( SECTION, + "b instanceof Array", + false, + b instanceof Array ); - testcases[tc++] = new TestCase( SECTION, - "true instanceof Boolean", - false, - true instanceof Boolean ); + new TestCase( SECTION, + "true instanceof Boolean", + false, + true instanceof Boolean ); - testcases[tc++] = new TestCase( SECTION, - "Boolean instanceof Object", - true, - Boolean instanceof Object ); + new TestCase( SECTION, + "Boolean instanceof Object", + true, + Boolean instanceof Object ); test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/ecma_2/instanceof/shell.js b/mozilla/js/tests/ecma_2/instanceof/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_2/shell.js b/mozilla/js/tests/ecma_2/shell.js index d72fd34ddc1..bdc9a186f08 100644 --- a/mozilla/js/tests/ecma_2/shell.js +++ b/mozilla/js/tests/ecma_2/shell.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,7 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ - /* * JavaScript shared functions file for running the tests in either * stand-alone JavaScript engine. To run a test, first load this file, @@ -42,183 +42,222 @@ */ var completed = false; -var testcases; -var tc = 0; +var testcases = new Array(); +var tc = testcases.length; -SECTION = ""; -VERSION = ""; -BUGNUMBER=""; +var SECTION = ""; +var VERSION = ""; +var BUGNUMBER=""; var TZ_DIFF = getTimeZoneDiff(); -var DEBUG = false; -var GLOBAL = "[object global]"; +/* + * constant strings + */ +var GLOBAL = "[object global]"; var PASSED = " PASSED!" var FAILED = " FAILED! expected: "; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var DEBUG = false; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); + +/* + * wrapper for test case constructor that doesn't require the SECTION + * argument. + */ + +function AddTestCase( description, expect, actual ) { + new TestCase( SECTION, description, expect, actual ); } + +/* + * TestCase constructor + * + */ function TestCase( n, d, e, a ) { - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; - this.bugnumber = BUGNUMBER; + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; - this.passed = getTestCaseResult( this.expect, this.actual ); - if ( DEBUG ) { - writeLineToLog( "added " + this.description ); - } + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } + /* + * testcases are solely maintained in the TestCase + * constructor. tc will _always_ point to one past the + * last testcase. If an exception occurs during the call + * to the constructor, then we are assured that the tc + * index has not been incremented. + */ + + testcases[tc++] = this; } + +/* + * Set up test environment. + * + */ function startTest() { - if ( version ) { - // JavaScript 1.3 is supposed to be compliant ecma version 1.0 - if ( VERSION == "ECMA_1" ) { - version ( 130 ); - } - if ( VERSION == "JS_13" ) { - version ( 130 ); - } - if ( VERSION == "JS_12" ) { - version ( 120 ); - } - if ( VERSION == "JS_11" ) { - version ( 110 ); - } + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( 130 ); } - - - // for ecma version 2.0, we will leave the javascript version to - // the default ( for now ). - - writeHeaderToLog( SECTION + " "+ TITLE); - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + if ( VERSION == "JS_13" ) { + version ( 130 ); } + if ( VERSION == "JS_12" ) { + version ( 120 ); + } + if ( VERSION == "JS_11" ) { + version ( 110 ); + } + } + + + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + + writeHeaderToLog( SECTION + " "+ TITLE); + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } - testcases = new Array(); - tc = 0; } +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + try + { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + catch(e) + { + writeLineToLog('test(): empty testcase for tc = ' + tc + ' ' + e); + } + } + stopTest(); + return ( testcases ); +} + + +/* + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ function getTestCaseResult( expect, actual ) { - // because ( NaN == NaN ) always returns false, need to do - // a special compare to see if we got the right result. - if ( actual != actual ) { - if ( typeof actual == "object" ) { - actual = "NaN object"; - } else { - actual = "NaN number"; - } - } - if ( expect != expect ) { - if ( typeof expect == "object" ) { - expect = "NaN object"; - } else { - expect = "NaN number"; - } - } + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } - var passed = ( expect == actual ) ? true : false; + var passed = ( expect == actual ) ? true : false; - // if both objects are numbers - // need to replace w/ IEEE standard for rounding - if ( !passed - && typeof(actual) == "number" - && typeof(expect) == "number" - ) { - if ( Math.abs(actual-expect) < 0.0000001 ) { - passed = true; - } - } + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } - // verify type is the same - if ( typeof(expect) != typeof(actual) ) { - passed = false; - } + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } - return passed; + return passed; } + +/* + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. + */ + function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; } function writeFormattedResult( expect, actual, string, passed ) { - var s = string ; - s += ( passed ) ? PASSED : FAILED + expect; - writeLineToLog( s); - return passed; + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; } function writeLineToLog( string ) { - print( string ); + print( string ); } function writeHeaderToLog( string ) { - print( string ); + print( string ); } +/* end of print functions */ + +/* + * When running in the shell, run the garbage collector after the + * test has completed. + */ + function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } + var gc; + if ( gc != undefined ) { + gc(); + } } + +/* + * Convenience function for displaying failed test cases. Useful + * when running tests manually. + * + */ function getFailedCases() { for ( var i = 0; i < testcases.length; i++ ) { - if ( ! testcases[i].passed ) { - print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); - } - } -} -function err( msg, page, line ) { - writeLineToLog( page + " failed with error: " + msg + " on line " + line ); - testcases[tc].actual = "error"; - testcases[tc].reason = msg; - writeTestCaseResult( testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual + - ": " + testcases[tc].reason ); - stopTest(); - return true; -} - -function Enumerate ( o ) { - var properties = new Array(); - for ( p in o ) { - properties[ properties.length ] = new Array( p, o[p] ); + if ( ! testcases[i].passed ) { + writeLineToLog( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); } - return properties; -} - -function getFailedCases() { - for ( var i = 0; i < testcases.length; i++ ) { - if ( ! testcases[i].passed ) { - writeLineToLog( testcases[i].description +" = " +testcases[i].actual + - " expected: "+ testcases[i].expect ); - } } } -function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; } - /* * Originally, the test suite used a hard-coded value TZ_DIFF = -8. * But that was only valid for testers in the Pacific Standard Time Zone! @@ -229,3 +268,4 @@ function getTimeZoneDiff() { return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; } + diff --git a/mozilla/js/tests/ecma_2/template.js b/mozilla/js/tests/ecma_2/template.js index f193cf02d2a..dd5b43e6104 100644 --- a/mozilla/js/tests/ecma_2/template.js +++ b/mozilla/js/tests/ecma_2/template.js @@ -41,14 +41,14 @@ * Author: ** replace with your e-mail address ** */ - var SECTION = ""; // if ECMA test, provide section number - var VERSION = "ECMA_2"; // Version of JavaScript or ECMA - var TITLE = ""; // Provide ECMA section title or description - var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report +var SECTION = ""; // if ECMA test, provide section number +var VERSION = "ECMA_2"; // Version of JavaScript or ECMA +var TITLE = ""; // Provide ECMA section title or description +var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report - startTest(); // leave this alone +startTest(); // leave this alone - /* Calls to AddTestCase here */ +/* Calls to AddTestCase here */ - test(); // leave this alone +test(); // leave this alone diff --git a/mozilla/js/tests/ecma_3/Array/browser.js b/mozilla/js/tests/ecma_3/Array/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Array/shell.js b/mozilla/js/tests/ecma_3/Array/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Date/15.9.5.3.js b/mozilla/js/tests/ecma_3/Date/15.9.5.3.js index 22dc721121d..583e9ea817b 100644 --- a/mozilla/js/tests/ecma_3/Date/15.9.5.3.js +++ b/mozilla/js/tests/ecma_3/Date/15.9.5.3.js @@ -126,7 +126,7 @@ function addTestCase() { - testcases[tc++] = new TestCase( SECTION, status, expect, actual); + new TestCase( SECTION, status, expect, actual); } @@ -161,4 +161,4 @@ function test() } stopTest(); return (testcases); -} \ No newline at end of file +} diff --git a/mozilla/js/tests/ecma_3/Date/15.9.5.4.js b/mozilla/js/tests/ecma_3/Date/15.9.5.4.js index b7a343757b0..0ae5e5dc466 100644 --- a/mozilla/js/tests/ecma_3/Date/15.9.5.4.js +++ b/mozilla/js/tests/ecma_3/Date/15.9.5.4.js @@ -133,7 +133,7 @@ function addTestCase() { - testcases[tc++] = new TestCase( SECTION, status, expect, actual); + new TestCase( SECTION, status, expect, actual); } diff --git a/mozilla/js/tests/ecma_3/Date/15.9.5.5.js b/mozilla/js/tests/ecma_3/Date/15.9.5.5.js index 02f24a81ec4..ae3a5d70cc0 100644 --- a/mozilla/js/tests/ecma_3/Date/15.9.5.5.js +++ b/mozilla/js/tests/ecma_3/Date/15.9.5.5.js @@ -127,7 +127,7 @@ function addTestCase() { - testcases[tc++] = new TestCase( SECTION, status, expect, actual); + new TestCase( SECTION, status, expect, actual); } @@ -155,4 +155,4 @@ function test() } stopTest(); return (testcases); -} \ No newline at end of file +} diff --git a/mozilla/js/tests/ecma_3/Date/15.9.5.6.js b/mozilla/js/tests/ecma_3/Date/15.9.5.6.js index 74e496a6ac3..637a8c62898 100644 --- a/mozilla/js/tests/ecma_3/Date/15.9.5.6.js +++ b/mozilla/js/tests/ecma_3/Date/15.9.5.6.js @@ -128,7 +128,7 @@ function addTestCase() { - testcases[tc++] = new TestCase( SECTION, status, expect, actual); + new TestCase( SECTION, status, expect, actual); } @@ -163,4 +163,4 @@ function test() } stopTest(); return (testcases); -} \ No newline at end of file +} diff --git a/mozilla/js/tests/ecma_3/Date/15.9.5.7.js b/mozilla/js/tests/ecma_3/Date/15.9.5.7.js index 8d759eebb74..363cca054aa 100644 --- a/mozilla/js/tests/ecma_3/Date/15.9.5.7.js +++ b/mozilla/js/tests/ecma_3/Date/15.9.5.7.js @@ -136,7 +136,7 @@ function addTestCase() { - testcases[tc++] = new TestCase( SECTION, status, expect, actual); + new TestCase( SECTION, status, expect, actual); } diff --git a/mozilla/js/tests/ecma_3/Date/browser.js b/mozilla/js/tests/ecma_3/Date/browser.js new file mode 100644 index 00000000000..5afc6ab43bb --- /dev/null +++ b/mozilla/js/tests/ecma_3/Date/browser.js @@ -0,0 +1,98 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ + +var GLOBAL = "[object Window]"; + +function writeLineToLog( string ) { + document.write( string + "
\n"); +} + +function writeHeaderToLog( string ) { + document.write( "

" + string + "

" ); +} + +function writeFormattedResult( expect, actual, string, passed ) { + var s = ""+ string ; + s += "" ; + s += ( passed ) ? "  " + PASSED + : " " + FAILED + expect + ""; + writeLineToLog( s + "" ); + return passed; +} + +/* + * The earlier versions of the test code used exceptions + * to terminate the test script in "negative" test cases + * before the failure reporting code could run. In order + * to be able to capture errors for the "negative" case + * where the exception is a sign the test actually passed, + * the err online handler will assume that any error is a + * failure unless gExceptionExpected is true. + */ +window.onerror = err; +var gExceptionExpected = false; + +function err( msg, page, line ) { + var testcase; + + if (typeof(EXPECTED) == "undefined" || EXPECTED != "error") { + /* + * an unexpected exception occured + */ + writeLineToLog( "Test failed with the message: " + msg ); + testcase = new TestCase(SECTION, "unknown", "unknown", "unknown"); + testcase.passed = false; + testcase.reason = "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + return + } + + testcase = new TestCase(SECTION, DESCRIPTION, EXPECTED, "error"); + testcase.reason += "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + stopTest(); +} + +var gVersion = 0; + +function version(v) +{ + if (v) { + gVersion = v; + } + return gVersion; +} diff --git a/mozilla/js/tests/ecma_3/Date/shell.js b/mozilla/js/tests/ecma_3/Date/shell.js index c5eda103638..91036141173 100644 --- a/mozilla/js/tests/ecma_3/Date/shell.js +++ b/mozilla/js/tests/ecma_3/Date/shell.js @@ -41,12 +41,12 @@ */ var completed = false; -var testcases; -var tc = 0; +var testcases = new Array(); +var tc = testcases.length; -SECTION = ""; -VERSION = ""; -BUGNUMBER = ""; +var SECTION = ""; +var VERSION = ""; +var BUGNUMBER = ""; /* * constant strings @@ -54,609 +54,656 @@ BUGNUMBER = ""; var GLOBAL = "[object global]"; var PASSED = " PASSED!" var FAILED = " FAILED! expected: "; + var DEBUG = false; - -/* -* Wrapper for test case constructor that doesn't require the SECTION argument. +/* + * wrapper for test case constructor that doesn't require the SECTION + * argument. */ -function AddTestCase( description, expect, actual ) -{ - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); -} +function AddTestCase( description, expect, actual ) { + new TestCase( SECTION, description, expect, actual ); +} /* * TestCase constructor -*/ -function TestCase( n, d, e, a ) -{ - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; - this.bugnumber = BUGNUMBER; - this.passed = getTestCaseResult( this.expect, this.actual ); - if ( DEBUG ) {writeLineToLog("added " + this.description);} -} + * + */ +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } + /* + * testcases are solely maintained in the TestCase + * constructor. tc will _always_ point to one past the + * last testcase. If an exception occurs during the call + * to the constructor, then we are assured that the tc + * index has not been incremented. + */ + + testcases[tc++] = this; +} /* * Set up test environment. -*/ -function startTest() -{ - if ( version ) - { - // JavaScript 1.3 is supposed to be compliant ECMA version 1.0 - if (VERSION == "ECMA_1" ) {version ("130");} - if (VERSION == "JS_1.3" ) {version ( "130");} - if (VERSION == "JS_1.2" ) {version ( "120");} - if (VERSION == "JS_1.1" ) {version( "110");} - - // for ECMA version 2.0, we will leave the JavaScript version - // to the default ( for now ). - } - - // print out bugnumber - if ( BUGNUMBER ) - { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + * + */ +function startTest() { + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.3" ) { + version ( "130" ); + } + if ( VERSION == "JS_1.2" ) { + version ( "120" ); + } + if ( VERSION == "JS_1.1" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). } - testcases = new Array(); - tc = 0; + // print out bugnumber + + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } } - -function test() -{ - for ( tc=0; tc < testcases.length; tc++ ) - { +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + try + { testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual ); - + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual ); testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; } - + catch(e) + { + writeLineToLog('test(): empty testcase for tc = ' + tc + ' ' + e); + } + } stopTest(); return ( testcases ); } - /* * Compare expected result to the actual result and figure out whether * the test case passed. */ -function getTestCaseResult(expect, actual ) -{ - //because ( NaN == NaN ) always returns false, need to do - //a special compare to see if we got the right result. - if ( actual != actual ) - { - if ( typeof actual == "object" ) {actual = "NaN object";} - else {actual = "NaN number";} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } } - if ( expect != expect ) - { - if ( typeof expect == "object" ) {expect = "NaN object";} - else {expect = "NaN number";} + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } } - var passed = ( expect == actual ) ? true : false; - - // if both objects are numbers, need to replace w/ IEEE standard for rounding - if ( !passed && typeof(actual) == "number" && typeof(expect) == "number" ) - { - if ( Math.abs(actual-expect) < 0.0000001 ) {passed = true;} + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; } - //verify type is the same - if ( typeof(expect) != typeof(actual) ) {passed = false;} - return passed; } - /* - * Begin printing functions. These functions use the shell's print function. -* When running tests in the browser, override these functions with functions -* that use document.write. + * Begin printing functions. These functions use the shell's + * print function. When running tests in the browser, these + * functions, override these functions with functions that use + * document.write. */ -function writeTestCaseResult( expect, actual, string ) -{ - var passed = getTestCaseResult(expect, actual ); + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); writeFormattedResult( expect, actual, string, passed ); return passed; } - - -function writeFormattedResult( expect, actual, string, passed ) -{ +function writeFormattedResult( expect, actual, string, passed ) { var s = string ; s += ( passed ) ? PASSED : FAILED + expect; writeLineToLog( s); return passed; } - - -function writeLineToLog( string ) -{ +function writeLineToLog( string ) { print( string ); } - - -function writeHeaderToLog( string ) -{ +function writeHeaderToLog( string ) { print( string ); } -/* End of printing functions */ +/* end of print functions */ /* - * When running in the shell, run the garbage collector after the test has completed. + * When running in the shell, run the garbage collector after the + * test has completed. */ -function stopTest() -{ + +function stopTest() { var gc; - if ( gc != undefined ) - { + if ( gc != undefined ) { gc(); } } - /* - * Convenience function for displaying failed test cases. - * Useful when running tests manually. -*/ -function getFailedCases() -{ - for (var i = 0; i < testcases.length; i++ ) - { - if ( !testcases[i].passed ) - { - print( testcases[i].description + " = " + testcases[i].actual + " expected: " + testcases[i].expect ); + * Convenience function for displaying failed test cases. Useful + * when running tests manually. + * + */ +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + writeLineToLog( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); } } } - - - /* - * Date constants and functions used by tests in Date suite -*/ -var msPerDay = 86400000; -var HoursPerDay = 24; +/* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; var MinutesPerHour = 60; var SecondsPerMinute = 60; -var msPerSecond = 1000; -var msPerMinute = 60000; // msPerSecond * SecondsPerMinute -var msPerHour = 3600000; // msPerMinute * MinutesPerHour -var TZ_DIFF = getTimeZoneDiff(); +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour +var TZ_DIFF = getTimeZoneDiff(); // offset of tester's timezone from UTC var TZ_ADJUST = TZ_DIFF * msPerHour; -var TIME_1970 = 0; -var TIME_2000 = 946684800000; -var TIME_1900 = -2208988800000; +var TZ_PST = -8; // offset of Pacific Standard Time from UTC +var PST_DIFF = TZ_DIFF - TZ_PST; // offset of tester's timezone from PST +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; var UTC_29_FEB_2000 = TIME_2000 + 31*msPerDay + 28*msPerDay; var UTC_1_JAN_2005 = TIME_2000 + TimeInYear(2000) + TimeInYear(2001) + - TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); + TimeInYear(2002) + TimeInYear(2003) + TimeInYear(2004); var now = new Date(); var TIME_NOW = now.valueOf(); //valueOf() is to accurate to the millisecond - //Date.parse() is accurate only to the second - - + //Date.parse() is accurate only to the second /* * Originally, the test suite used a hard-coded value TZ_DIFF = -8. * But that was only valid for testers in the Pacific Standard Time Zone! * We calculate the proper number dynamically for any tester. We just - * have to be careful to use a date not subject to Daylight Savings Time... -*/ + * have to be careful not to use a date subject to Daylight Savings Time... + */ function getTimeZoneDiff() { return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; } -function Day( t) +/* + * Date test "ResultArrays" are hard-coded for Pacific Standard Time. + * We must adjust them for the tester's own timezone - + */ +function adjustResultArray(ResultArray, msMode) { - return ( Math.floor( t/msPerDay ) ); + // If the tester's system clock is in PST, no need to continue - + if (!PST_DIFF) {return;} + + /* The date testcases instantiate Date objects in two different ways: + * + * millisecond mode: e.g. dt = new Date(10000000); + * year-month-day mode: dt = new Date(2000, 5, 1, ...); + * + * In the first case, the date is measured from Time 0 in Greenwich (i.e. UTC). + * In the second case, it is measured with reference to the tester's local timezone. + * + * In the first case we must correct those values expected for local measurements, + * like dt.getHours() etc. No correction is necessary for dt.getUTCHours() etc. + * + * In the second case, it is exactly the other way around - + */ + if (msMode) + { + // The hard-coded UTC milliseconds from Time 0 derives from a UTC date. + // Shift to the right by the offset between UTC and the tester. + var t = ResultArray[TIME] + TZ_DIFF*msPerHour; + + // Use our date arithmetic functions to determine the local hour, day, etc. + ResultArray[HOURS] = HourFromTime(t); + ResultArray[DAY] = WeekDay(t); + ResultArray[DATE] = DateFromTime(t); + ResultArray[MONTH] = MonthFromTime(t); + ResultArray[YEAR] = YearFromTime(t); + } + else + { + // The hard-coded UTC milliseconds from Time 0 derives from a PST date. + // Shift to the left by the offset between PST and the tester. + var t = ResultArray[TIME] - PST_DIFF*msPerHour; + + // Use our date arithmetic functions to determine the UTC hour, day, etc. + ResultArray[TIME] = t; + ResultArray[UTC_HOURS] = HourFromTime(t); + ResultArray[UTC_DAY] = WeekDay(t); + ResultArray[UTC_DATE] = DateFromTime(t); + ResultArray[UTC_MONTH] = MonthFromTime(t); + ResultArray[UTC_YEAR] = YearFromTime(t); + } } -function DaysInYear( y ) -{ - if ( y % 4 != 0 ) {return 365;} - - if ( (y%4 == 0) && (y%100 != 0) ) {return 366;} - - if ( (y%100 == 0) && (y%400 != 0) ) {return 365;} - - if ( (y%400 == 0)){return 366;} - else {return "ERROR: DaysInYear(" + y + ") case not covered";} +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); } - - -function TimeInYear( y ) -{ +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { return ( DaysInYear(y) * msPerDay ); } - - -function DayNumber( t ) -{ +function DayNumber( t ) { return ( Math.floor( t / msPerDay ) ); } - - -function TimeWithinDay( t ) -{ - if ( t < 0 ) {return ( (t%msPerDay) + msPerDay );} - else {return ( t % msPerDay );} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } } - - -function YearNumber( t ) -{ +function YearNumber( t ) { } - - -function TimeFromYear( y ) -{ +function TimeFromYear( y ) { return ( msPerDay * DayFromYear(y) ); } - - -function DayFromYear( y ) -{ - return ( 365*(y-1970) + Math.floor((y-1969)/4) - Math.floor((y-1901)/100) - + Math.floor((y-1601)/400) ); +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); } - - -function InLeapYear( t ) -{ - if ( DaysInYear(YearFromTime(t)) == 365 ) {return 0;} - - if ( DaysInYear(YearFromTime(t)) == 366 ) {return 1;} - else {return "ERROR: InLeapYear(" + t + ") case not covered";} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+ t + ") case not covered"; + } } - - -function YearFromTime( t ) -{ - t =Number( t ); +function YearFromTime( t ) { + t = Number( t ); var sign = ( t < 0 ) ? -1 : 1; var year = ( sign < 0 ) ? 1969 : 1970; - - for (var timeToTimeZero = t; ; ) - { + for ( var timeToTimeZero = t; ; ) { // subtract the current year's time from the time that's left. timeToTimeZero -= sign * TimeInYear(year) - // if there's less than the current year's worth of time left, then break. - if ( sign < 0 ) - { - if ( sign * timeToTimeZero <= 0 ) {break;} - else {year += sign;} - } - else - { - if ( sign * timeToTimeZero < 0 ) {break;} - else {year += sign;} - } + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } } - return ( year ); } - - -function MonthFromTime( t ) -{ +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA var day = DayWithinYear( t ); var leap = InLeapYear(t); - // I know I could use switch but I'd rather not until it's part of ECMA - if ( (0 <= day) && (day < 31) ) {return 0;} - if ( (31 <= day) && (day < (59+leap) )) {return 1;} - if ( ((59+leap) <= day) && (day < (90+leap) )) {return 2;} - if ( ((90+leap) <= day) && (day < (120+leap) )) {return 3;} - if ( ((120+leap) <= day) && (day < (151+leap) )) {return 4;} - if ( ((151+leap) <= day) && (day < (181+leap) )) {return 5;} - if ( ((181+leap) <= day) && (day < (212+leap) )) {return 6;} - if ( ((212+leap) <= day) && (day < (243+leap)) ) {return 7;} - if ( ((243+leap) <= day) && (day < (273+leap) )) {return 8;} - if ( ((273+leap) <= day) && (day < (304+leap)) ) {return 9;} - if ( ((304+leap) <= day) && (day < (334+leap)) ) {return 10;} - if ( ((334+leap) <= day) && (day < (365+leap)) ) {return 11;} - else {return "ERROR: MonthFromTime(" + t + ") not known";} + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } } - - -function DayWithinYear( t ) -{ - return(Day(t) - DayFromYear(YearFromTime(t)) ); +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); } - - -function DateFromTime( t ) -{ +function DateFromTime( t ) { var day = DayWithinYear(t); var month = MonthFromTime(t); - if ( month == 0) {return ( day + 1 );} - if ( month == 1) {return ( day - 30 );} - if ( month == 2) {return ( day - 58 - InLeapYear(t) );} - if ( month == 3) {return ( day - 89 - InLeapYear(t));} - if ( month == 4) {return ( day - 119 - InLeapYear(t));} - if ( month == 5) {return ( day - 150 - InLeapYear(t));} - if ( month == 6) {return ( day - 180 - InLeapYear(t));} - if ( month == 7) {return ( day - 211 - InLeapYear(t));} - if ( month == 8) {return ( day - 242 - InLeapYear(t));} - if ( month == 9) {return ( day - 272 - InLeapYear(t));} - if ( month == 10) {return ( day - 303 - InLeapYear(t));} - if ( month == 11) {return ( day - 333 - InLeapYear(t));} - return ("ERROR: DateFromTime("+t+") not known" ); + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); } - - -function WeekDay( t ) -{ - var weekday = (Day(t)+4)%7; - return( weekday < 0 ? 7+weekday : weekday ); +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); } - // missing daylight savings time adjustment - -function HourFromTime( t ) -{ - var h = Math.floor( t / msPerHour )%HoursPerDay; +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; return ( (h<0) ? HoursPerDay + h : h ); } - - -function MinFromTime( t ) -{ - var min = Math.floor( t / msPerMinute )%MinutesPerHour; - return( (min < 0 ) ? MinutesPerHour + min : min ); +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); } - - -function SecFromTime( t ) -{ - var sec = Math.floor( t / msPerSecond )%SecondsPerMinute; - return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); } - - -function msFromTime( t ) -{ - var ms = t%msPerSecond; +function msFromTime( t ) { + var ms = t % msPerSecond; return ( (ms < 0 ) ? msPerSecond + ms : ms ); } - - -function LocalTZA() -{ +function LocalTZA() { return ( TZ_DIFF * msPerHour ); } - - -function UTC( t ) -{ - return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); } - -function DaylightSavingTA( t ) -{ +function DaylightSavingTA( t ) { t = t - LocalTZA(); - var dst_start = GetFirstSundayInApril(t) + 2*msPerHour; - var dst_end = GetLastSundayInOctober(t) + 2*msPerHour; + var dst_start = GetFirstSundayInApril(t) + 2*msPerHour; + var dst_end = GetLastSundayInOctober(t)+ 2*msPerHour; - if ( t >= dst_start && t < dst_end ) {return msPerHour;} - else {return 0;} + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } - // Daylight Savings Time starts on the first Sunday in April at 2:00AM in PST. - // Other time zones will need to override this function. + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. -print( new Date( UTC(dst_start + LocalTZA())) ); -return UTC(dst_start + LocalTZA()); + writeLineToLog( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); } - - -function GetFirstSundayInApril( t ) -{ +function GetFirstSundayInApril( t ) { var year = YearFromTime(t); var leap = InLeapYear(t); - var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + TimeInMonth(2,leap); + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); - for ( var first_sunday = april; WeekDay(first_sunday) > 0; first_sunday += msPerDay ) - { + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { ; } return first_sunday; } - - -function GetLastSundayInOctober( t ) -{ +function GetLastSundayInOctober( t ) { var year = YearFromTime(t); var leap = InLeapYear(t); - for ( var oct = TimeFromYear(year), m =0; m < 9; m++ ) - { + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { oct += TimeInMonth(m, leap); } - - for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; last_sunday -= msPerDay ) + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) { ; } - return last_sunday; } - - -function LocalTime( t ) -{ +function LocalTime( t ) { return ( t + LocalTZA() + DaylightSavingTA(t) ); } - - -function MakeTime( hour, min, sec, ms ) -{ - if ( isNaN(hour) || isNaN(min) || isNaN(sec) || isNaN(ms) ){return Number.NaN;} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } hour = ToInteger(hour); min = ToInteger( min); sec = ToInteger( sec); - ms = ToInteger( ms ); + ms = ToInteger( ms ); - return( (hour*msPerHour) + (min*msPerMinute) + (sec*msPerSecond) + ms ); + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); } - - -function MakeDay( year, month, date ) -{ - if ( isNaN(year) || isNaN(month) || isNaN(date)) {return Number.NaN;} - +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } year = ToInteger(year); month = ToInteger(month); date = ToInteger(date ); - var sign = ( year < 1970 ) ? -1 : 1; - var t = ( year < 1970 ) ? 1 : 0; - var y = ( year < 1970 ) ? 1969 : 1970; + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; var result5 = year + Math.floor( month/12 ); - var result6= month%12; + var result6 = month % 12; - if ( year < 1970 ) - { - for ( y = 1969; y >= year; y += sign ) - { + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { t += sign * TimeInYear(y); } - } - else - { - for ( y = 1970 ; y < year; y += sign ) - { + } else { + for ( y = 1970 ; y < year; y += sign ) { t += sign * TimeInYear(y); } } var leap = InLeapYear( t ); - for ( var m = 0; m < month; m++) - { + for ( var m = 0; m < month; m++ ) { t += TimeInMonth( m, leap ); } - if ( YearFromTime(t) != result5 ) {return Number.NaN;} - if ( MonthFromTime(t) != result6 ) {return Number.NaN;} - if ( DateFromTime(t) != 1 ){return Number.NaN;} + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } return ( (Day(t)) + date - 1 ); } +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 - -function TimeInMonth( month, leap ) -{ - // Jan 0 Feb 1 Mar 2 Apr 3 May 4 June 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec11 - - // April June September November - if ( month == 3 || month == 5 || month == 8 || month == 10 ) {return ( 30*msPerDay );} + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } // all the rest - if ( month == 0 || month == 2 || month == 4 || month == 6 || - month == 7 || month == 9 || month == 11 ) {return ( 31*msPerDay );} + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } - // save February - return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); } - - -function MakeDate( day, time ) -{ - if (day == Number.POSITIVE_INFINITY || +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || day == Number.NEGATIVE_INFINITY || - day == Number.NaN ) - { + day == Number.NaN ) { return Number.NaN; } - if ( time == Number.POSITIVE_INFINITY || - time == Number.POSITIVE_INFINITY || - day == Number.NaN) - { + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { return Number.NaN; } - return ( day * msPerDay ) + time; } - - -function TimeClip( t ) -{ - if ( isNaN( t )) {return ( Number.NaN);} - if ( Math.abs( t ) > 8.64e15 ) {return ( Number.NaN);} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } return ( ToInteger( t ) ); } - - -function ToInteger( t ) -{ +function ToInteger( t ) { t = Number( t ); - if ( isNaN( t )) {return ( Number.NaN);} - - if ( t == 0 || t == -0 || - t == Number.POSITIVE_INFINITY || - t == Number.NEGATIVE_INFINITY) - { + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { return 0; } - var sign = ( t < 0 ) ? -1 : 1; + var sign = ( t < 0 ) ? -1 : 1; return ( sign * Math.floor( Math.abs( t ) ) ); } - - -function Enumerate( o ) -{ +function Enumerate ( o ) { var p; - for ( p in o ) {print( p + ": " + o[p] );} + for ( p in o ) { + writeLineToLog( p +": " + o[p] ); + } } - /* these functions are useful for running tests manually in Rhino */ -function GetContext() -{ +function GetContext() { return Packages.com.netscape.javascript.Context.getCurrentContext(); } - - -function OptLevel( i ) -{ +function OptLevel( i ) { i = Number(i); var cx = GetContext(); cx.setOptimizationLevel(i); } - /* end of Rhino functions */ diff --git a/mozilla/js/tests/ecma_3/Exceptions/15.11.7.6-002.js b/mozilla/js/tests/ecma_3/Exceptions/15.11.7.6-002.js index ee2f577ae46..46f5449788f 100644 --- a/mozilla/js/tests/ecma_3/Exceptions/15.11.7.6-002.js +++ b/mozilla/js/tests/ecma_3/Exceptions/15.11.7.6-002.js @@ -58,8 +58,15 @@ var expectedvalues = []; */ function testDontDelete(F) { + var e; var orig = F.prototype; - delete F.prototype; + try + { + delete F.prototype; + } + catch (e) + { + } return F.prototype === orig; } diff --git a/mozilla/js/tests/ecma_3/Exceptions/15.11.7.6-003.js b/mozilla/js/tests/ecma_3/Exceptions/15.11.7.6-003.js index 0eefe7e2fa0..40faa584e4c 100644 --- a/mozilla/js/tests/ecma_3/Exceptions/15.11.7.6-003.js +++ b/mozilla/js/tests/ecma_3/Exceptions/15.11.7.6-003.js @@ -58,8 +58,15 @@ var expectedvalues = []; */ function testReadOnly(F) { + var e; var orig = F.prototype; - F.prototype = new Object(); + try + { + F.prototype = new Object(); + } + catch (e) + { + } return F.prototype === orig; } diff --git a/mozilla/js/tests/ecma_3/Exceptions/binding-001.js b/mozilla/js/tests/ecma_3/Exceptions/binding-001.js index 29ecde65c32..142a4ef0f7f 100644 --- a/mozilla/js/tests/ecma_3/Exceptions/binding-001.js +++ b/mozilla/js/tests/ecma_3/Exceptions/binding-001.js @@ -48,6 +48,7 @@ * print(sum); // should fail with 'sum is not defined' " * */ + //----------------------------------------------------------------------------- var UBound = 0; var bug = '(none)'; @@ -65,7 +66,7 @@ var expect= ERR_REF_YES; try { var f = function sum(){}; - print(sum); + writeLineToLog(sum); } catch (e) { diff --git a/mozilla/js/tests/ecma_3/Exceptions/browser.js b/mozilla/js/tests/ecma_3/Exceptions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Exceptions/shell.js b/mozilla/js/tests/ecma_3/Exceptions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/ExecutionContexts/10.1.3-1.js b/mozilla/js/tests/ecma_3/ExecutionContexts/10.1.3-1.js index f905b67fabb..07afbb54aba 100644 --- a/mozilla/js/tests/ecma_3/ExecutionContexts/10.1.3-1.js +++ b/mozilla/js/tests/ecma_3/ExecutionContexts/10.1.3-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * diff --git a/mozilla/js/tests/ecma_3/ExecutionContexts/browser.js b/mozilla/js/tests/ecma_3/ExecutionContexts/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/ExecutionContexts/shell.js b/mozilla/js/tests/ecma_3/ExecutionContexts/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Expressions/browser.js b/mozilla/js/tests/ecma_3/Expressions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Expressions/shell.js b/mozilla/js/tests/ecma_3/Expressions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/FunExpr/browser.js b/mozilla/js/tests/ecma_3/FunExpr/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/FunExpr/fe-001-n.js b/mozilla/js/tests/ecma_3/FunExpr/fe-001-n.js index 830688f0b51..dde7b7a9239 100644 --- a/mozilla/js/tests/ecma_3/FunExpr/fe-001-n.js +++ b/mozilla/js/tests/ecma_3/FunExpr/fe-001-n.js @@ -38,6 +38,9 @@ * * ***** END LICENSE BLOCK ***** */ +DESCRIPTION = "Previous statement should have thrown a ReferenceError"; +EXPECTED = "error"; + test(); function test() @@ -48,6 +51,6 @@ function test() var x = function f(){return "inner";}(); var y = f(); reportFailure ("Previous statement should have thrown a ReferenceError"); - + exitFunc ("test"); } diff --git a/mozilla/js/tests/ecma_3/FunExpr/shell.js b/mozilla/js/tests/ecma_3/FunExpr/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Function/browser.js b/mozilla/js/tests/ecma_3/Function/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Function/call-001.js b/mozilla/js/tests/ecma_3/Function/call-001.js index c2c472cfdc7..477171e15a1 100644 --- a/mozilla/js/tests/ecma_3/Function/call-001.js +++ b/mozilla/js/tests/ecma_3/Function/call-001.js @@ -57,6 +57,7 @@ * global object. * */ + //----------------------------------------------------------------------------- var UBound = 0; var bug = '(none)'; diff --git a/mozilla/js/tests/ecma_3/Function/regress-104584.js b/mozilla/js/tests/ecma_3/Function/regress-104584.js index 9c7d183fb28..55024ef8be5 100644 --- a/mozilla/js/tests/ecma_3/Function/regress-104584.js +++ b/mozilla/js/tests/ecma_3/Function/regress-104584.js @@ -44,6 +44,7 @@ * call F,G WITHOUT providing an argument. This caused a crash * on the second call to obj.toString() or print(obj) below - */ + //----------------------------------------------------------------------------- var bug = 104584; var summary = "Testing that we don't crash on this code -"; @@ -68,7 +69,7 @@ function G(obj) { if(!obj) obj = {}; - print(obj); + writeLineToLog(obj); gc(); - print(obj); + writeLineToLog(obj); } diff --git a/mozilla/js/tests/ecma_3/Function/shell.js b/mozilla/js/tests/ecma_3/Function/shell.js new file mode 100644 index 00000000000..a76d3066f46 --- /dev/null +++ b/mozilla/js/tests/ecma_3/Function/shell.js @@ -0,0 +1,7 @@ +// needed for browser and rhino +if (typeof gc == 'undefined') +{ + gc = function () {}; +} + + \ No newline at end of file diff --git a/mozilla/js/tests/ecma_3/Number/browser.js b/mozilla/js/tests/ecma_3/Number/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Number/shell.js b/mozilla/js/tests/ecma_3/Number/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/NumberFormatting/browser.js b/mozilla/js/tests/ecma_3/NumberFormatting/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/NumberFormatting/shell.js b/mozilla/js/tests/ecma_3/NumberFormatting/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Object/browser.js b/mozilla/js/tests/ecma_3/Object/browser.js new file mode 100644 index 00000000000..0e57d1fcd06 --- /dev/null +++ b/mozilla/js/tests/ecma_3/Object/browser.js @@ -0,0 +1,7 @@ +var GLOBAL = 'Window'; + +function isObject(obj) +{ + return obj instanceof Object || obj == window; +} + diff --git a/mozilla/js/tests/ecma_3/Object/class-001.js b/mozilla/js/tests/ecma_3/Object/class-001.js index a4be51dccaf..786e453ef68 100644 --- a/mozilla/js/tests/ecma_3/Object/class-001.js +++ b/mozilla/js/tests/ecma_3/Object/class-001.js @@ -55,7 +55,7 @@ var expect= ''; var expectedvalue = [ ]; status = 'the global object'; actual = getJSClass(this); -expect = 'global'; +expect = GLOBAL; addThis(); status = 'new Object()'; diff --git a/mozilla/js/tests/ecma_3/Object/shell.js b/mozilla/js/tests/ecma_3/Object/shell.js index ed33b241713..a858b5763fa 100644 --- a/mozilla/js/tests/ecma_3/Object/shell.js +++ b/mozilla/js/tests/ecma_3/Object/shell.js @@ -55,7 +55,7 @@ var cnNoObject = 'Unexpected Error!!! Parameter to this function must be an object'; var cnNoClass = 'Unexpected Error!!! Cannot find Class property'; var cnObjectToString = Object.prototype.toString; - +var GLOBAL = 'global'; // checks that it's safe to call findType() function getJSType(obj) @@ -97,3 +97,4 @@ function isObject(obj) { return obj instanceof Object; } + diff --git a/mozilla/js/tests/ecma_3/Operators/browser.js b/mozilla/js/tests/ecma_3/Operators/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Operators/shell.js b/mozilla/js/tests/ecma_3/Operators/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/README b/mozilla/js/tests/ecma_3/README new file mode 100755 index 00000000000..eebd421c2ed --- /dev/null +++ b/mozilla/js/tests/ecma_3/README @@ -0,0 +1 @@ +ECMA 262 Edition 3 diff --git a/mozilla/js/tests/ecma_3/RegExp/15.10.4.1-5-n.js b/mozilla/js/tests/ecma_3/RegExp/15.10.4.1-5-n.js index abcf6d02ca0..637341f9c7e 100644 --- a/mozilla/js/tests/ecma_3/RegExp/15.10.4.1-5-n.js +++ b/mozilla/js/tests/ecma_3/RegExp/15.10.4.1-5-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -33,7 +34,8 @@ * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * - * ***** END LICENSE BLOCK ***** + * ***** END LICENSE BLOCK ***** */ +/* * * Date: 26 November 2000 * @@ -60,6 +62,7 @@ * This should throw an exception ... we test for this. * */ + //------------------------------------------------------------------------------------------------- var bug = '61266'; var summary = 'Negative test: Passing (RegExp object, flag) to RegExp() constructor'; @@ -87,6 +90,9 @@ flags[1] = 'g'; flags[2] = 'm'; +DESCRIPTION = "Negative test: Passing (RegExp object, flag) to RegExp() constructor" +EXPECTED = "error"; + //------------------------------------------------------------------------------------------------- test(); @@ -95,37 +101,37 @@ test(); function test() { - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); - for (i in patterns) - { - s = patterns[i]; - - for (j in flags) + for (i in patterns) { - f = flags[j]; - printStatus(getStatus(s, f)); - obj1 = new RegExp(s, f); - obj2 = new RegExp(obj1, f); // this should cause an exception + s = patterns[i]; - // WE SHOULD NEVER REACH THIS POINT - - reportFailure(cnFAILURE); + for (j in flags) + { + f = flags[j]; + printStatus(getStatus(s, f)); + obj1 = new RegExp(s, f); + obj2 = new RegExp(obj1, f); // this should cause an exception + + // WE SHOULD NEVER REACH THIS POINT - + reportFailure(cnFAILURE); + } } - } - - exitFunc ('test'); + + exitFunc ('test'); } function getStatus(regexp, flag) { - return (statprefix + quote(regexp) + statsuffix + flag); + return (statprefix + quote(regexp) + statsuffix + flag); } function quote(text) { - return (singlequote + text + singlequote); -} \ No newline at end of file + return (singlequote + text + singlequote); +} diff --git a/mozilla/js/tests/ecma_3/RegExp/browser.js b/mozilla/js/tests/ecma_3/RegExp/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/RegExp/regress-228087.js b/mozilla/js/tests/ecma_3/RegExp/regress-228087.js index fafe591c7bf..16a6d600017 100644 --- a/mozilla/js/tests/ecma_3/RegExp/regress-228087.js +++ b/mozilla/js/tests/ecma_3/RegExp/regress-228087.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -60,124 +61,264 @@ var actualmatch = ''; var actualmatches = new Array(); var expectedmatch = ''; var expectedmatches = new Array(); +var e; string = 'foo {1} foo {2} foo'; - // try an example with the braces escaped - status = inSection(1); - pattern = /\{1.*\}/g; - actualmatch = string.match(pattern); - expectedmatch = Array('{1} foo {2}'); - addThis(); +// try an example with the braces escaped +status = inSection(1); +try +{ + pattern = new RegExp('\{1.*\}', 'g'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('{1} foo {2}'); +addThis(); - // just like Section 1, without the braces being escaped - status = inSection(2); - pattern = /{1.*}/g; - actualmatch = string.match(pattern); - expectedmatch = Array('{1} foo {2}'); - addThis(); +// just like Section 1, without the braces being escaped +status = inSection(2); +try +{ + pattern = new RegExp('{1.*}', 'g'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('{1} foo {2}'); +addThis(); - // try an example with the braces escaped - status = inSection(3); - pattern = /\{1[.!\}]*\}/g; - actualmatch = string.match(pattern); - expectedmatch = Array('{1}'); - addThis(); +// try an example with the braces escaped +status = inSection(3); +try +{ + pattern = new RegExp('\{1[.!\}]*\}', 'g'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('{1}'); +addThis(); - // just like Section 3, without the braces being escaped - status = inSection(4); - pattern = /{1[.!}]*}/g; - actualmatch = string.match(pattern); - expectedmatch = Array('{1}'); - addThis(); +// just like Section 3, without the braces being escaped +status = inSection(4); +try +{ + pattern = new RegExp('{1[.!}]*}', 'g'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('{1}'); +addThis(); string = 'abccccc{3 }c{ 3}c{3, }c{3 ,}c{3 ,4}c{3, 4}c{3,4 }de'; - // use braces in a normal quantifier construct - status = inSection(5); - pattern = /c{3}/; - actualmatch = string.match(pattern); - expectedmatch = Array('ccc'); - addThis(); +// use braces in a normal quantifier construct +status = inSection(5); +try +{ + pattern = new RegExp('c{3}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('ccc'); +addThis(); - // now disrupt the quantifer - the braces should now be interpreted literally - status = inSection(6); - pattern = /c{3 }/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3 }'); - addThis(); +// now disrupt the quantifer - the braces should now be interpreted literally +status = inSection(6); +try +{ + pattern = new RegExp('c{3 }'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 }'); +addThis(); - status = inSection(7); - pattern = /c{3.}/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3 }'); - addThis(); +status = inSection(7); +try +{ + pattern = new RegExp('c{3.}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 }'); +addThis(); - status = inSection(8); - pattern = /c{3\s}/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3 }'); - addThis(); +status = inSection(8); +try +{ + // need to escape the \ in \s since + // this has been converted to a constructor call + // instead of a literal regexp + pattern = new RegExp('c{3\\s}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 }'); +addThis(); - status = inSection(9); - pattern = /c{3[ ]}/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3 }'); - addThis(); +status = inSection(9); +try +{ + pattern = new RegExp('c{3[ ]}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 }'); +addThis(); - status = inSection(10); - pattern = /c{ 3}/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{ 3}'); - addThis(); +status = inSection(10); +try +{ + pattern = new RegExp('c{ 3}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{ 3}'); +addThis(); - // using braces in a normal quantifier construct again - status = inSection(11); - pattern = /c{3,}/; - actualmatch = string.match(pattern); - expectedmatch = Array('ccccc'); - addThis(); +// using braces in a normal quantifier construct again +status = inSection(11); +try +{ + pattern = new RegExp('c{3,}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('ccccc'); +addThis(); - // now disrupt it - the braces should now be interpreted literally - status = inSection(12); - pattern = /c{3, }/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3, }'); - addThis(); +// now disrupt it - the braces should now be interpreted literally +status = inSection(12); +try +{ + pattern = new RegExp('c{3, }'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3, }'); +addThis(); - status = inSection(13); - pattern = /c{3 ,}/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3 ,}'); - addThis(); +status = inSection(13); +try +{ + pattern = new RegExp('c{3 ,}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 ,}'); +addThis(); - // using braces in a normal quantifier construct again - status = inSection(14); - pattern = /c{3,4}/; - actualmatch = string.match(pattern); - expectedmatch = Array('cccc'); - addThis(); +// using braces in a normal quantifier construct again +status = inSection(14); +try +{ + pattern = new RegExp('c{3,4}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('cccc'); +addThis(); - // now disrupt it - the braces should now be interpreted literally - status = inSection(15); - pattern = /c{3 ,4}/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3 ,4}'); - addThis(); +// now disrupt it - the braces should now be interpreted literally +status = inSection(15); +try +{ + pattern = new RegExp('c{3 ,4}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3 ,4}'); +addThis(); - status = inSection(16); - pattern = /c{3, 4}/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3, 4}'); - addThis(); +status = inSection(16); +try +{ + pattern = new RegExp('c{3, 4}'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3, 4}'); +addThis(); - status = inSection(17); - pattern = /c{3,4 }/; - actualmatch = string.match(pattern); - expectedmatch = Array('c{3,4 }'); - addThis(); +status = inSection(17); +try +{ + pattern = new RegExp('c{3,4 }'); + actualmatch = string.match(pattern); +} +catch (e) +{ + pattern = 'error'; + actualmatch = ''; +} +expectedmatch = Array('c{3,4 }'); +addThis(); @@ -190,20 +331,20 @@ test(); function addThis() { - statusmessages[i] = status; - patterns[i] = pattern; - strings[i] = string; - actualmatches[i] = actualmatch; - expectedmatches[i] = expectedmatch; - i++; + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; } function test() { - enterFunc ('test'); - printBugNumber (bug); - printStatus (summary); - testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); - exitFunc ('test'); + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); } diff --git a/mozilla/js/tests/ecma_3/RegExp/shell.js b/mozilla/js/tests/ecma_3/RegExp/shell.js index 3d47bf89bbd..efdc59a14de 100644 --- a/mozilla/js/tests/ecma_3/RegExp/shell.js +++ b/mozilla/js/tests/ecma_3/RegExp/shell.js @@ -80,44 +80,53 @@ function testRegExp(statuses, patterns, strings, actualmatches, expectedmatches) expectedmatch=expectedmatches[i]; state = getState(status, pattern, string); + description = status; if(actualmatch) { + actual = formatArray(actualmatch); if(expectedmatch) { // expectedmatch and actualmatch are arrays - lExpect = expectedmatch.length; lActual = actualmatch.length; + expected = formatArray(expectedmatch); + if (lActual != lExpect) { reportFailure( state + ERR_LENGTH + - MSG_EXPECT + formatArray(expectedmatch) + - MSG_ACTUAL + formatArray(actualmatch) + + MSG_EXPECT + expected + + MSG_ACTUAL + actual + CHAR_NL ); continue; } // OK, the arrays have same length - - if (formatArray(expectedmatch) != formatArray(actualmatch)) + if (expected != actual) { reportFailure( state + ERR_MATCH + - MSG_EXPECT + formatArray(expectedmatch) + - MSG_ACTUAL + formatArray(actualmatch) + + MSG_EXPECT + expected + + MSG_ACTUAL + actual + CHAR_NL ); } + else + { + reportCompare(expected, actual, state) + } } else //expectedmatch is null - that is, we did not expect a match - { + expected = expectedmatch; reportFailure( state + ERR_UNEXP_MATCH + MSG_EXPECT + expectedmatch + - MSG_ACTUAL + formatArray(actualmatch) + + MSG_ACTUAL + actual + CHAR_NL ); } @@ -127,9 +136,10 @@ function testRegExp(statuses, patterns, strings, actualmatches, expectedmatches) { if (expectedmatch) { + actual = actualmatch; reportFailure( state + ERR_NO_MATCH + - MSG_EXPECT + formatArray(expectedmatch) + + MSG_EXPECT + expectedmatch + MSG_ACTUAL + actualmatch + CHAR_NL ); @@ -137,6 +147,8 @@ function testRegExp(statuses, patterns, strings, actualmatches, expectedmatches) else // we did not expect a match { // Being ultra-cautious. Presumably expectedmatch===actualmatch===null + expected = expectedmatch; + actual = actualmatch; reportCompare (expectedmatch, actualmatch, state); } } @@ -246,3 +258,4 @@ function singleQuote(text) { return CHAR_QT + text + CHAR_QT; } + diff --git a/mozilla/js/tests/ecma_3/Statements/browser.js b/mozilla/js/tests/ecma_3/Statements/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Statements/regress-121744.js b/mozilla/js/tests/ecma_3/Statements/regress-121744.js index cb1f166a602..ec1287aec87 100644 --- a/mozilla/js/tests/ecma_3/Statements/regress-121744.js +++ b/mozilla/js/tests/ecma_3/Statements/regress-121744.js @@ -94,7 +94,7 @@ try { for (var i in undefined) { - print(i); + writeLineToLog(i); } } catch(e) @@ -118,7 +118,7 @@ try { for (var i in null) { - print(i); + writeLineToLog(i); } } catch(e) @@ -145,7 +145,7 @@ try { for (var i in this.ZZZ) { - print(i); + writeLineToLog(i); } } catch(e) @@ -170,7 +170,7 @@ try { for (var i in 'bbb'.match(/aaa/)) { - print(i); + writeLineToLog(i); } } catch(e) diff --git a/mozilla/js/tests/ecma_3/Statements/regress-131348.js b/mozilla/js/tests/ecma_3/Statements/regress-131348.js index 24c39fa20ee..4e6ee8fc7da 100644 --- a/mozilla/js/tests/ecma_3/Statements/regress-131348.js +++ b/mozilla/js/tests/ecma_3/Statements/regress-131348.js @@ -75,7 +75,7 @@ try { for (var i in undefined) { - print(i); + writeLineToLog(i); } } catch(e) @@ -93,7 +93,7 @@ try { for (var i in null) { - print(i); + writeLineToLog(i); } } catch(e) @@ -117,7 +117,7 @@ try { for (var i in this.ZZZ) { - print(i); + writeLineToLog(i); } } catch(e) @@ -139,7 +139,7 @@ try { for (var i in 'bbb'.match(/aaa/)) { - print(i); + writeLineToLog(i); } } catch(e) diff --git a/mozilla/js/tests/ecma_3/Statements/shell.js b/mozilla/js/tests/ecma_3/Statements/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/String/browser.js b/mozilla/js/tests/ecma_3/String/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/String/shell.js b/mozilla/js/tests/ecma_3/String/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Unicode/browser.js b/mozilla/js/tests/ecma_3/Unicode/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Unicode/shell.js b/mozilla/js/tests/ecma_3/Unicode/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/ecma_3/Unicode/uc-002-n.js b/mozilla/js/tests/ecma_3/Unicode/uc-002-n.js index 695a3185f2d..6b3b19afd4f 100644 --- a/mozilla/js/tests/ecma_3/Unicode/uc-002-n.js +++ b/mozilla/js/tests/ecma_3/Unicode/uc-002-n.js @@ -38,17 +38,16 @@ * * ***** END LICENSE BLOCK ***** */ -test(); +DESCRIPTION = "Non-character escapes in identifiers negative test."; +EXPECTED = "error"; -function test() -{ - enterFunc ("test"); +enterFunc ("test"); - printStatus ("Non-character escapes in identifiers negative test."); - printBugNumber (23607); +printStatus ("Non-character escapes in identifiers negative test."); +printBugNumber (23607); - reportCompare ("error", eval("\u0020 = 5"), - "Non-character escapes in identifiers negative test."); +eval("\u0020 = 5"); +reportFailure("Previous statement should have thrown an error."); + +exitFunc ("test"); - exitFunc ("test"); -} diff --git a/mozilla/js/tests/ecma_3/browser.js b/mozilla/js/tests/ecma_3/browser.js new file mode 100755 index 00000000000..cc01d79d880 --- /dev/null +++ b/mozilla/js/tests/ecma_3/browser.js @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * + * + * + */ + +function writeLineToLog( string ) { + document.write( string + "
\n"); +} + +var testcases = new Array(); +var tc = testcases.length; +var bug = ''; +var summary = ''; +var description = ''; +var expected = ''; +var actual = ''; +var msg = ''; + +function TestCase(n, d, e, a) +{ + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = ( e == a ); + this.reason = ''; + this.bugnumber = typeof(bug) != 'undefined' ? bug : ''; + testcases[tc++] = this; +} + +var gInReportCompare = false; + +var _reportCompare = reportCompare; + +reportCompare = function(expected, actual, description) +{ + gInReportCompare = true; + + var testcase = new TestCase(gTestName, description, expected, actual); + testcase.passed = _reportCompare(expected, actual, description); + + gInReportCompare = false; +}; + +var _reportFailure = reportFailure; +reportFailure = function (msg, page, line) +{ + var testcase; + + if (gInReportCompare) + { + testcase = testcases[tc - 1]; + testcase.passed = false; + } + else + { + if (typeof(summary) == "undefined") + { + summary = "unknown"; + } + if (typeof(expect) == "undefined") + { + expect = "unknown"; + } + testcase = new TestCase(gTestName, summary, expect, "error"); + } + + testcase.reason += msg; + + if (typeof(page) != 'undefined') + { + testcase.reason += ' Page: ' + page; + } + if (typeof(line) != 'undefined') + { + testcase.reason += ' Line: ' + line; + } + _reportFailure(msg); + +}; + +function quit() +{ +} + +window.onerror = reportFailure; diff --git a/mozilla/js/tests/ecma_3/shell.js b/mozilla/js/tests/ecma_3/shell.js index 45835da6ab6..38fd5372272 100644 --- a/mozilla/js/tests/ecma_3/shell.js +++ b/mozilla/js/tests/ecma_3/shell.js @@ -46,6 +46,9 @@ var SECT_SUFFIX = ' of test -'; var VERBOSE = false; var callStack = new Array(); +function writeLineToLog( string ) { + print( string ); +} /* * The test driver searches for such a phrase in the test output. * If such phrase exists, it will set n as the expected exit code. @@ -53,7 +56,7 @@ var callStack = new Array(); function expectExitCode(n) { - print('--- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE ' + n + ' ---'); + writeLineToLog('--- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE ' + n + ' ---'); } @@ -72,7 +75,7 @@ function inSection(x) */ function inRhino() { - return (typeof defineClass == "function"); + return (typeof defineClass == "function"); } /* @@ -86,7 +89,7 @@ function reportFailure (msg) var prefix = (funcName) ? "[reported from " + funcName + "] ": ""; for (var i=0; i Import Test List - +

- -  Clear all selections berofe import.
+ +  Clear all selections before import.
diff --git a/mozilla/js/tests/importList.js b/mozilla/js/tests/importList.js new file mode 100644 index 00000000000..c8395a0ecb8 --- /dev/null +++ b/mozilla/js/tests/importList.js @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +function doImport() +{ + var lines = + document.forms["foo"].elements["testList"].value.split(/\r?\n/); + var suites = window.opener.suites; + var elems = window.opener.document.forms["testCases"].elements; + + if (document.forms["foo"].elements["clear_all"].checked) + window.opener._selectNone(); + + for (var l in lines) + { + if (!lines[l]) + { + continue; + } + + if (lines[l].search(/^\s$|\s*\#/) == -1) + { + var ary = lines[l].match (/(.*)\/(.*)\/(.*)/); + + if (!ary) + { + if (!confirm ("Line " + l + " '" + + lines[l] + "' is confusing, " + + "continue with import?")) + { + return; + } + } + + if (suites[ary[1]] && + suites[ary[1]].testDirs[ary[2]] && + suites[ary[1]].testDirs[ary[2]].tests[ary[3]]) + { + var radioname = suites[ary[1]].testDirs[ary[2]].tests[ary[3]].id; + var radio = elems[radioname]; + if (!radio.checked) + { + radio.checked = true; + window.opener.onRadioClick(radio); + } + } + } + } + + setTimeout('window.close();', 200); + +} diff --git a/mozilla/js/tests/js-test-driver-begin.js b/mozilla/js/tests/js-test-driver-begin.js new file mode 100644 index 00000000000..5adc7c481bb --- /dev/null +++ b/mozilla/js/tests/js-test-driver-begin.js @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +var gVersion = 150; +var gTestName = ''; + +function init() +{ + if (document.location.search.indexOf('?') != 0) + { + // not called with a query string + return; + } + + var re = /test=([^;]+);language=(language|type);([a-zA-Z0-9.=;\/]+)/; + var matches = re.exec(document.location.search); + + // testpath http://machine/path-to-suite/sub-suite/test.js + var testpath = matches[1]; + var attribute = matches[2]; + var value = matches[3]; + + var ise4x = /e4x\//.test(testpath); + + if (value.indexOf('1.1') != -1) + { + gVersion = 110; + } + else if (value.indexOf('1.2') != -1) + { + gVersion = 120; + } + else if (value.indexOf('1.3') != -1) + { + gVersion = 130; + } + else if (value.indexOf('1.4') != -1) + { + gVersion = 140; + } + else if(value.indexOf('1.5') != -1) + { + gVersion = 150; + } + + var testpathparts = testpath.split(/\//); + + if (testpathparts.length < 3) + { + // must have at least suitepath/subsuite/testcase.js + return; + } + var suitepath = testpathparts.slice(0,testpathparts.length-2).join('/'); + var subsuite = testpathparts[testpathparts.length - 2]; + var test = testpathparts[testpathparts.length - 1]; + + gTestName = test; + + outputscripttag(suitepath + '/shell.js', attribute, value, ise4x); + outputscripttag(suitepath + '/browser.js', attribute, value, ise4x); + outputscripttag(suitepath + '/' + subsuite + '/shell.js', attribute, value, ise4x); + outputscripttag(suitepath + '/' + subsuite + '/browser.js', attribute, value, ise4x); + outputscripttag(suitepath + '/' + subsuite + '/' + test, attribute, value, ise4x); + + document.write('' + suitepath + '/' + subsuite + '/' + test + '<\/title>'); + return; +} + +function outputscripttag(src, attribute, value, ise4x) +{ + if (!src) + { + return; + } + + var s = '<script src="' + src + '" '; + + if (ise4x) + { + if (attribute == 'type') + { + value += ';e4x=1 '; + } + else + { + s += ' type="text/javascript'; + if (gVersion != 150) + { + s += ';version=' + gVersion/100; + } + s += ';e4x=1" '; + } + } + + s += attribute + '="' + value + '"><\/script>'; + + document.write(s); +} + +init(); + diff --git a/mozilla/js/tests/js-test-driver-end.js b/mozilla/js/tests/js-test-driver-end.js new file mode 100644 index 00000000000..a0ac8fecb3e --- /dev/null +++ b/mozilla/js/tests/js-test-driver-end.js @@ -0,0 +1,5 @@ +if (window.opener && window.opener.runNextTest) +{ + setTimeout('window.opener.runNextTest()', 250); +} + diff --git a/mozilla/js/tests/js-test-driver-quirks.html b/mozilla/js/tests/js-test-driver-quirks.html new file mode 100644 index 00000000000..dd6e79b6e17 --- /dev/null +++ b/mozilla/js/tests/js-test-driver-quirks.html @@ -0,0 +1,18 @@ +<html> + <head> + <!-- + This test driver is to be invoked using + js-tests-driver.html?test=path-to-test-js&language=javascriptx.x + + It will load the associated test javascript file and + using the requested script language attribute, then execute the + test. + --> + <script type="text/javascript" src="js-test-driver-begin.js"> + </script> + </head> + <body> + <script type="text/javascript" src="js-test-driver-end.js"> + </script> + </body> +</html> diff --git a/mozilla/js/tests/js-test-driver-standards.html b/mozilla/js/tests/js-test-driver-standards.html new file mode 100644 index 00000000000..e14ded18334 --- /dev/null +++ b/mozilla/js/tests/js-test-driver-standards.html @@ -0,0 +1,22 @@ +<!DOCTYPE html +PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> + +<html> + <head> + <!-- + This test driver is to be invoked using + js-tests-driver.html?test=path-to-test-js&language=javascriptx.x + + It will load the associated test javascript file and + using the requested script language attribute, then execute the + test. + --> + <script type="text/javascript" src="js-test-driver-begin.js"> + </script> + </head> + <body> + <script type="text/javascript" src="js-test-driver-end.js"> + </script> + </body> +</html> diff --git a/mozilla/js/tests/js1_1/README b/mozilla/js/tests/js1_1/README new file mode 100755 index 00000000000..eb5b5cc9355 --- /dev/null +++ b/mozilla/js/tests/js1_1/README @@ -0,0 +1 @@ +JavaScript 1.1 diff --git a/mozilla/js/tests/js1_1/browser.js b/mozilla/js/tests/js1_1/browser.js index 922fb136e05..1f3774b4413 100644 --- a/mozilla/js/tests/js1_1/browser.js +++ b/mozilla/js/tests/js1_1/browser.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -49,47 +50,74 @@ * <script src="./mytest.js"></script> */ -onerror = err; - -function startTest() { - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; -} +GLOBAL = "[object Window]"; function writeLineToLog( string ) { - document.write( string + "<br>\n"); + document.write( string + "<br>\n"); } function writeHeaderToLog( string ) { - document.write( "<h2>" + string + "</h2>" ); + document.write( "<h2>" + string + "</h2>" ); } -function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } - document.write( "<hr>" ); -} -function writeFormattedResult( expect, actual, string, passed ) { - var s = "<tt>"+ string ; - s += "<b>" ; - s += ( passed ) ? "<font color=#009900>  " + PASSED - : "<font color=#aa0000> " + FAILED + expect + "</tt>"; - writeLineToLog( s + "</font></b></tt>" ); - return passed; -} -function err( msg, page, line ) { - writeLineToLog( "Test failed with the message: " + msg ); - testcases[tc].actual = "error"; - testcases[tc].reason = msg; - writeTestCaseResult( testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual + - ": " + testcases[tc].reason ); - stopTest(); - return true; +function writeFormattedResult( expect, actual, string, passed ) { + var s = "<tt>"+ string ; + s += "<b>" ; + s += ( passed ) ? "<font color=#009900>  " + PASSED + : "<font color=#aa0000> " + FAILED + expect + "</tt>"; + writeLineToLog( s + "</font></b></tt>" ); + return passed; +} + +/* + * The earlier versions of the test code used exceptions + * to terminate the test script in "negative" test cases + * before the failure reporting code could run. In order + * to be able to capture errors for the "negative" case + * where the exception is a sign the test actually passed, + * the err online handler will assume that any error is a + * failure unless gExceptionExpected is true. + */ +window.onerror = err; +var gExceptionExpected = false; + +function err( msg, page, line ) { + var testcase; + + if (typeof(EXPECTED) == "undefined" || EXPECTED != "error") { + /* + * an unexpected exception occured + */ + writeLineToLog( "Test failed with the message: " + msg ); + testcase = new TestCase(SECTION, "unknown", "unknown", "unknown"); + testcase.passed = false; + testcase.reason = "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + return; + } + + if (typeof SECTION == 'undefined') + { + SECTION = 'Unknown'; + } + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + + testcase = new TestCase(SECTION, DESCRIPTION, EXPECTED, "error"); + testcase.reason += "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + stopTest(); +} + +function version(v) { + if (v) + { + gVersion = v; + } + return gVersion; } diff --git a/mozilla/js/tests/js1_1/regress/browser.js b/mozilla/js/tests/js1_1/regress/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_1/regress/function-001.js b/mozilla/js/tests/js1_1/regress/function-001.js index 8f6ff4fac7c..adfa54adc5c 100644 --- a/mozilla/js/tests/js1_1/regress/function-001.js +++ b/mozilla/js/tests/js1_1/regress/function-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -41,51 +42,35 @@ * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 * * eval("function f(){}function g(){}") at top level is an error for JS1.2 - and above (missing ; between named function expressions), but declares f - and g as functions below 1.2. + and above (missing ; between named function expressions), but declares f + and g as functions below 1.2. * * Fails to produce error regardless of version: * js> version(100) -120 -js> eval("function f(){}function g(){}") -js> version(120); -100 -js> eval("function f(){}function g(){}") -js> + 120 + js> eval("function f(){}function g(){}") + js> version(120); + 100 + js> eval("function f(){}function g(){}") + js> * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "boolean-001.js"; - var VERSION = "JS1_1"; - var TITLE = "functions not separated by semicolons are not errors in version 110 "; - var BUGNUMBER="99232"; +var SECTION = "function-001.js"; +var VERSION = "JS1_1"; +var TITLE = "functions not separated by semicolons are not errors in version 110 "; +var BUGNUMBER="99232"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +result = "passed"; - result = "passed"; +new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\")", + void 0, + eval("function f(){}function g(){}") ); - testcases[tc++] = new TestCase( - SECTION, - "eval(\"function f(){}function g(){}\")", - void 0, - eval("function f(){}function g(){}") ); +test(); - test(); - - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_1/regress/shell.js b/mozilla/js/tests/js1_1/regress/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_1/shell.js b/mozilla/js/tests/js1_1/shell.js index 63c8269be50..0fda404b4d9 100644 --- a/mozilla/js/tests/js1_1/shell.js +++ b/mozilla/js/tests/js1_1/shell.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,94 +36,136 @@ * ***** END LICENSE BLOCK ***** */ var completed = false; -var testcases; -var tc = 0; +var testcases = new Array(); +var tc = testcases.length; -SECTION = ""; -VERSION = ""; -BUGNUMBER = ""; +var SECTION = ""; +var VERSION = ""; +var BUGNUMBER = ""; -var GLOBAL = "[object global]"; +/* + * constant strings + */ +var GLOBAL = "[object global]"; var PASSED = " PASSED!" var FAILED = " FAILED! expected: "; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var DEBUG = false; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -/* wrapper for test cas constructor that doesn't require the SECTION +/* + * wrapper for test case constructor that doesn't require the SECTION * argument. */ function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); + new TestCase( SECTION, description, expect, actual ); } +/* + * TestCase constructor + * + */ + function TestCase( n, d, e, a ) { - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; - this.passed = getTestCaseResult( this.expect, this.actual ); + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } + /* + * testcases are solely maintained in the TestCase + * constructor. tc will _always_ point to one past the + * last testcase. If an exception occurs during the call + * to the constructor, then we are assured that the tc + * index has not been incremented. + */ + + testcases[tc++] = this; } + +/* + * Set up test environment. + * + */ function startTest() { - version(110); + version(110); - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } - testcases = new Array(); - tc = 0; + testcases = new Array(); + tc = 0; } + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + try + { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + catch(e) + { + writeLineToLog('test(): empty testcase for tc = ' + tc + ' ' + e); + } + } + stopTest(); + return ( testcases ); +} + +/* + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ function getTestCaseResult( expect, actual ) { - // because ( NaN == NaN ) always returns false, need to do - // a special compare to see if we got the right result. - if ( actual != actual ) { - if ( typeof actual == "object" ) { - actual = "NaN object"; - } else { - actual = "NaN number"; - } - } - if ( expect != expect ) { - if ( typeof expect == "object" ) { - expect = "NaN object"; - } else { - expect = "NaN number"; - } - } + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } - var passed = ( expect == actual ) ? true : false; + var passed = ( expect == actual ) ? true : false; - // if both objects are numbers, give a little leeway for rounding. - if ( !passed - && typeof(actual) == "number" - && typeof(expect) == "number" - ) { - if ( Math.abs(actual-expect) < 0.0000001 ) { - passed = true; - } - } + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } - // verify type is the same - if ( typeof(expect) != typeof(actual) ) { - passed = false; - } + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } - return passed; + return passed; } /* * Begin printing functions. These functions use the shell's @@ -132,27 +175,46 @@ function getTestCaseResult( expect, actual ) { */ function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; } function writeFormattedResult( expect, actual, string, passed ) { - var s = string ; - s += ( passed ) ? PASSED : FAILED + expect; - writeLineToLog( s); - return passed; + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; } function writeLineToLog( string ) { - print( string ); + print( string ); } function writeHeaderToLog( string ) { - print( string ); + print( string ); } /* end of print functions */ + +/* + * When running in the shell, run the garbage collector after the + * test has completed. + */ function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } + var gc; + if ( gc != undefined ) { + gc(); + } } + +/* + * Convenience function for displaying failed test cases. Useful + * when running tests manually. + * + */ +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + writeLineToLog( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} + diff --git a/mozilla/js/tests/js1_2/Array/array_split_1.js b/mozilla/js/tests/js1_2/Array/array_split_1.js index 76a4e7c4d51..72ff7f33f9d 100644 --- a/mozilla/js/tests/js1_2/Array/array_split_1.js +++ b/mozilla/js/tests/js1_2/Array/array_split_1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,53 +36,48 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: array_split_1.js - ECMA Section: Array.split() - Description: + File Name: array_split_1.js + ECMA Section: Array.split() + Description: - These are tests from free perl suite. + These are tests from free perl suite. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "Free Perl"; - var VERSION = "JS1_2"; - var TITLE = "Array.split()"; +var SECTION = "Free Perl"; +var VERSION = "JS1_2"; +var TITLE = "Array.split()"; - startTest(); +startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); + +new TestCase( SECTION, + "('a,b,c'.split(',')).length", + 3, + ('a,b,c'.split(',')).length ); +new TestCase( SECTION, + "('a,b'.split(',')).length", + 2, + ('a,b'.split(',')).length ); - testcases[tc++] = new TestCase( SECTION, - "('a,b,c'.split(',')).length", - 3, - ('a,b,c'.split(',')).length ); - - testcases[tc++] = new TestCase( SECTION, - "('a,b'.split(',')).length", - 2, - ('a,b'.split(',')).length ); - - testcases[tc++] = new TestCase( SECTION, - "('a'.split(',')).length", - 1, - ('a'.split(',')).length ); +new TestCase( SECTION, + "('a'.split(',')).length", + 1, + ('a'.split(',')).length ); /* * Deviate from ECMA by never splitting an empty string by any separator * string into a non-empty array (an array of length 1 that contains the * empty string). */ - testcases[tc++] = new TestCase( SECTION, - "(''.split(',')).length", - 0, - (''.split(',')).length ); +new TestCase( SECTION, + "(''.split(',')).length", + 0, + (''.split(',')).length ); - - - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/Array/browser.js b/mozilla/js/tests/js1_2/Array/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/Array/general1.js b/mozilla/js/tests/js1_2/Array/general1.js index 13f53e569d7..bdbee84d985 100644 --- a/mozilla/js/tests/js1_2/Array/general1.js +++ b/mozilla/js/tests/js1_2/Array/general1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,43 +36,40 @@ * * ***** END LICENSE BLOCK ***** */ /** - Filename: general1.js - Description: 'This tests out some of the functionality on methods on the Array objects' + Filename: general1.js + Description: 'This tests out some of the functionality on methods on the Array objects' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String:push,unshift,shift'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String:push,unshift,shift'; - writeHeaderToLog('Executing script: general1.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: general1.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var array1 = []; - var array1 = []; +array1.push(123); //array1 = [123] +array1.push("dog"); //array1 = [123,dog] +array1.push(-99); //array1 = [123,dog,-99] +array1.push("cat"); //array1 = [123,dog,-99,cat] +new TestCase( SECTION, "array1.pop()", array1.pop(),'cat'); +//array1 = [123,dog,-99] +array1.push("mouse"); //array1 = [123,dog,-99,mouse] +new TestCase( SECTION, "array1.shift()", array1.shift(),123); +//array1 = [dog,-99,mouse] +array1.unshift(96); //array1 = [96,dog,-99,mouse] +new TestCase( SECTION, "state of array", String([96,"dog",-99,"mouse"]), String(array1)); +new TestCase( SECTION, "array1.length", array1.length,4); +array1.shift(); //array1 = [dog,-99,mouse] +array1.shift(); //array1 = [-99,mouse] +array1.shift(); //array1 = [mouse] +new TestCase( SECTION, "array1.shift()", array1.shift(),"mouse"); +new TestCase( SECTION, "array1.shift()", "undefined", String(array1.shift())); - array1.push(123); //array1 = [123] - array1.push("dog"); //array1 = [123,dog] - array1.push(-99); //array1 = [123,dog,-99] - array1.push("cat"); //array1 = [123,dog,-99,cat] - testcases[count++] = new TestCase( SECTION, "array1.pop()", array1.pop(),'cat'); - //array1 = [123,dog,-99] - array1.push("mouse"); //array1 = [123,dog,-99,mouse] - testcases[count++] = new TestCase( SECTION, "array1.shift()", array1.shift(),123); - //array1 = [dog,-99,mouse] - array1.unshift(96); //array1 = [96,dog,-99,mouse] - testcases[count++] = new TestCase( SECTION, "state of array", String([96,"dog",-99,"mouse"]), String(array1)); - testcases[count++] = new TestCase( SECTION, "array1.length", array1.length,4); - array1.shift(); //array1 = [dog,-99,mouse] - array1.shift(); //array1 = [-99,mouse] - array1.shift(); //array1 = [mouse] - testcases[count++] = new TestCase( SECTION, "array1.shift()", array1.shift(),"mouse"); - testcases[count++] = new TestCase( SECTION, "array1.shift()", "undefined", String(array1.shift())); - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/Array/general2.js b/mozilla/js/tests/js1_2/Array/general2.js index 74db8690d09..44e62ec6819 100644 --- a/mozilla/js/tests/js1_2/Array/general2.js +++ b/mozilla/js/tests/js1_2/Array/general2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,59 +36,55 @@ * * ***** END LICENSE BLOCK ***** */ /** - Filename: general2.js - Description: 'This tests out some of the functionality on methods on the Array objects' + Filename: general2.js + Description: 'This tests out some of the functionality on methods on the Array objects' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String:push,splice,concat,unshift,sort'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String:push,splice,concat,unshift,sort'; - writeHeaderToLog('Executing script: general2.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: general2.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +array1 = new Array(); +array2 = []; +size = 10; +// this for loop populates array1 and array2 as follows: +// array1 = [0,1,2,3,4,....,size - 2,size - 1] +// array2 = [size - 1, size - 2,...,4,3,2,1,0] +for (var i = 0; i < size; i++) +{ + array1.push(i); + array2.push(size - 1 - i); +} - array1 = new Array(); - array2 = []; - size = 10; +// the following for loop reverses the order of array1 so +// that it should be similarly ordered to array2 +for (i = array1.length; i > 0; i--) +{ + array3 = array1.slice(1,i); + array1.splice(1,i-1); + array1 = array3.concat(array1); +} - // this for loop populates array1 and array2 as follows: - // array1 = [0,1,2,3,4,....,size - 2,size - 1] - // array2 = [size - 1, size - 2,...,4,3,2,1,0] - for (var i = 0; i < size; i++) - { - array1.push(i); - array2.push(size - 1 - i); - } +// the following for loop reverses the order of array1 +// and array2 +for (i = 0; i < size; i++) +{ + array1.push(array1.shift()); + array2.unshift(array2.pop()); +} - // the following for loop reverses the order of array1 so - // that it should be similarly ordered to array2 - for (i = array1.length; i > 0; i--) - { - array3 = array1.slice(1,i); - array1.splice(1,i-1); - array1 = array3.concat(array1); - } +new TestCase( SECTION, "Array.push,pop,shift,unshift,slice,splice", true,String(array1) == String(array2)); +array1.sort(); +array2.sort(); +new TestCase( SECTION, "Array.sort", true,String(array1) == String(array2)); - // the following for loop reverses the order of array1 - // and array2 - for (i = 0; i < size; i++) - { - array1.push(array1.shift()); - array2.unshift(array2.pop()); - } - - testcases[count++] = new TestCase( SECTION, "Array.push,pop,shift,unshift,slice,splice", true,String(array1) == String(array2)); - array1.sort(); - array2.sort(); - testcases[count++] = new TestCase( SECTION, "Array.sort", true,String(array1) == String(array2)); - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/Array/shell.js b/mozilla/js/tests/js1_2/Array/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/Array/slice.js b/mozilla/js/tests/js1_2/Array/slice.js index 9d9eaa8342f..1579d031aa9 100644 --- a/mozilla/js/tests/js1_2/Array/slice.js +++ b/mozilla/js/tests/js1_2/Array/slice.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,105 +35,87 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: slice.js - Description: 'This tests out some of the functionality on methods on the Array objects' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: slice.js + Description: 'This tests out some of the functionality on methods on the Array objects' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String:slice'; - - writeHeaderToLog('Executing script: slice.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String:slice'; +writeHeaderToLog('Executing script: slice.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - function mySlice(a, from, to) +var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; +var b = [1,2,3,4,5,6,7,8,9,0]; + +exhaustiveSliceTest("exhaustive slice test 1", a); +exhaustiveSliceTest("exhaustive slice test 2", b); + +test(); + +function mySlice(a, from, to) +{ + var from2 = from; + var to2 = to; + var returnArray = []; + var i; + + if (from2 < 0) from2 = a.length + from; + if (to2 < 0) to2 = a.length + to; + + if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length)) + { + if (from2 < 0) from2 = 0; + if (to2 > a.length) to2 = a.length; + + for (i = from2; i < to2; ++i) returnArray.push(a[i]); + } + return returnArray; +} + +// This function tests the slice command on an Array +// passed in. The arguments passed into slice range in +// value from -5 to the length of the array + 4. Every +// combination of the two arguments is tested. The expected +// result of the slice(...) method is calculated and +// compared to the actual result from the slice(...) method. +// If the Arrays are not similar false is returned. +function exhaustiveSliceTest(testname, a) +{ + var x = 0; + var y = 0; + var errorMessage; + var reason = ""; + var passed = true; + + for (x = -(2 + a.length); x <= (2 + a.length); x++) + for (y = (2 + a.length); y >= -(2 + a.length); y--) { - var from2 = from; - var to2 = to; - var returnArray = []; - var i; + var b = a.slice(x,y); + var c = mySlice(a,x,y); - if (from2 < 0) from2 = a.length + from; - if (to2 < 0) to2 = a.length + to; - - if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length)) + if (String(b) != String(c)) { - if (from2 < 0) from2 = 0; - if (to2 > a.length) to2 = a.length; - - for (i = from2; i < to2; ++i) returnArray.push(a[i]); + errorMessage = + "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + + " test: " + "a.slice(" + x + "," + y + ")\n" + + " a: " + String(a) + "\n" + + " actual result: " + String(b) + "\n" + + " expected result: " + String(c) + "\n"; + writeHeaderToLog(errorMessage); + reason = reason + errorMessage; + passed = false; } - return returnArray; } - - // This function tests the slice command on an Array - // passed in. The arguments passed into slice range in - // value from -5 to the length of the array + 4. Every - // combination of the two arguments is tested. The expected - // result of the slice(...) method is calculated and - // compared to the actual result from the slice(...) method. - // If the Arrays are not similar false is returned. - function exhaustiveSliceTest(testname, a) - { - var x = 0; - var y = 0; - var errorMessage; - var reason = ""; - var passed = true; - - for (x = -(2 + a.length); x <= (2 + a.length); x++) - for (y = (2 + a.length); y >= -(2 + a.length); y--) - { - var b = a.slice(x,y); - var c = mySlice(a,x,y); - - if (String(b) != String(c)) - { - errorMessage = - "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + - " test: " + "a.slice(" + x + "," + y + ")\n" + - " a: " + String(a) + "\n" + - " actual result: " + String(b) + "\n" + - " expected result: " + String(c) + "\n"; - writeHeaderToLog(errorMessage); - reason = reason + errorMessage; - passed = false; - } - } - var testCase = new TestCase(SECTION, testname, true, passed); - if (passed == false) - testCase.reason = reason; - return testCase; - } - - var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; - var b = [1,2,3,4,5,6,7,8,9,0]; - - testcases[count++] = exhaustiveSliceTest("exhaustive slice test 1", a); - testcases[count++] = exhaustiveSliceTest("exhaustive slice test 2", b); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); - + var testCase = new TestCase(SECTION, testname, true, passed); + if (passed == false) + testCase.reason = reason; + return testCase; +} diff --git a/mozilla/js/tests/js1_2/Array/splice1.js b/mozilla/js/tests/js1_2/Array/splice1.js index a23e3774d75..36020179ae2 100644 --- a/mozilla/js/tests/js1_2/Array/splice1.js +++ b/mozilla/js/tests/js1_2/Array/splice1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,134 +35,117 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: splice1.js - Description: 'Tests Array.splice(x,y) w/no var args' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: splice1.js + Description: 'Tests Array.splice(x,y) w/no var args' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String:splice 1'; - var BUGNUMBER="123795"; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String:splice 1'; +var BUGNUMBER="123795"; - writeHeaderToLog('Executing script: splice1.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: splice1.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; +var b = [1,2,3,4,5,6,7,8,9,0]; + +exhaustiveSpliceTest("exhaustive splice w/no optional args 1",a); +exhaustiveSpliceTest("exhaustive splice w/no optional args 1",b); + +test(); - function mySplice(testArray, splicedArray, first, len, elements) +function mySplice(testArray, splicedArray, first, len, elements) +{ + var removedArray = []; + var adjustedFirst = first; + var adjustedLen = len; + + if (adjustedFirst < 0) adjustedFirst = testArray.length + first; + if (adjustedFirst < 0) adjustedFirst = 0; + + if (adjustedLen < 0) adjustedLen = 0; + + for (i = 0; (i < adjustedFirst)&&(i < testArray.length); ++i) + splicedArray.push(testArray[i]); + + if (adjustedFirst < testArray.length) + for (i = adjustedFirst; (i < adjustedFirst + adjustedLen) && + (i < testArray.length); ++i) { - var removedArray = []; - var adjustedFirst = first; - var adjustedLen = len; + removedArray.push(testArray[i]); + } + for (i = 0; i < elements.length; i++) splicedArray.push(elements[i]); + + for (i = adjustedFirst + adjustedLen; i < testArray.length; i++) + splicedArray.push(testArray[i]); + + return removedArray; +} + +function exhaustiveSpliceTest(testname, testArray) +{ + var errorMessage; + var passed = true; + var reason = ""; + + for (var first = -(testArray.length+2); first <= 2 + testArray.length; first++) + { + var actualSpliced = []; + var expectedSpliced = []; + var actualRemoved = []; + var expectedRemoved = []; + + for (var len = 0; len < testArray.length + 2; len++) + { + actualSpliced = []; + expectedSpliced = []; + + for (var i = 0; i < testArray.length; ++i) + actualSpliced.push(testArray[i]); + + actualRemoved = actualSpliced.splice(first,len); + expectedRemoved = mySplice(testArray,expectedSpliced,first,len,[]); + + var adjustedFirst = first; if (adjustedFirst < 0) adjustedFirst = testArray.length + first; if (adjustedFirst < 0) adjustedFirst = 0; - if (adjustedLen < 0) adjustedLen = 0; - - for (i = 0; (i < adjustedFirst)&&(i < testArray.length); ++i) - splicedArray.push(testArray[i]); - - if (adjustedFirst < testArray.length) - for (i = adjustedFirst; (i < adjustedFirst + adjustedLen) && - (i < testArray.length); ++i) - { - removedArray.push(testArray[i]); - } - - for (i = 0; i < elements.length; i++) splicedArray.push(elements[i]); - - for (i = adjustedFirst + adjustedLen; i < testArray.length; i++) - splicedArray.push(testArray[i]); - - return removedArray; - } - - function exhaustiveSpliceTest(testname, testArray) - { - var errorMessage; - var passed = true; - var reason = ""; - - for (var first = -(testArray.length+2); first <= 2 + testArray.length; first++) + if ( (String(actualSpliced) != String(expectedSpliced)) + ||(String(actualRemoved) != String(expectedRemoved))) { - var actualSpliced = []; - var expectedSpliced = []; - var actualRemoved = []; - var expectedRemoved = []; + if ( (String(actualSpliced) == String(expectedSpliced)) + &&(String(actualRemoved) != String(expectedRemoved)) ) + { + if ( (expectedRemoved.length == 1) + &&(String(actualRemoved) == String(expectedRemoved[0]))) continue; + if ( expectedRemoved.length == 0 && actualRemoved == void 0) continue; + } - for (var len = 0; len < testArray.length + 2; len++) - { - actualSpliced = []; - expectedSpliced = []; - - for (var i = 0; i < testArray.length; ++i) - actualSpliced.push(testArray[i]); - - actualRemoved = actualSpliced.splice(first,len); - expectedRemoved = mySplice(testArray,expectedSpliced,first,len,[]); - - var adjustedFirst = first; - if (adjustedFirst < 0) adjustedFirst = testArray.length + first; - if (adjustedFirst < 0) adjustedFirst = 0; - - if ( (String(actualSpliced) != String(expectedSpliced)) - ||(String(actualRemoved) != String(expectedRemoved))) - { - if ( (String(actualSpliced) == String(expectedSpliced)) - &&(String(actualRemoved) != String(expectedRemoved)) ) - { - if ( (expectedRemoved.length == 1) - &&(String(actualRemoved) == String(expectedRemoved[0]))) continue; - if ( expectedRemoved.length == 0 && actualRemoved == void 0) continue; - } - - errorMessage = - "ERROR: 'TEST FAILED'\n" + - " test: " + "a.splice(" + first + "," + len + ",-97,new String('test arg'),[],9.8)\n" + - " a: " + String(testArray) + "\n" + - " actual spliced: " + String(actualSpliced) + "\n" + - " expected spliced: " + String(expectedSpliced) + "\n" + - " actual removed: " + String(actualRemoved) + "\n" + - " expected removed: " + String(expectedRemoved) + "\n"; - writeHeaderToLog(errorMessage); - reason = reason + errorMessage; - passed = false; - } - } + errorMessage = + "ERROR: 'TEST FAILED'\n" + + " test: " + "a.splice(" + first + "," + len + ",-97,new String('test arg'),[],9.8)\n" + + " a: " + String(testArray) + "\n" + + " actual spliced: " + String(actualSpliced) + "\n" + + " expected spliced: " + String(expectedSpliced) + "\n" + + " actual removed: " + String(actualRemoved) + "\n" + + " expected removed: " + String(expectedRemoved) + "\n"; + writeHeaderToLog(errorMessage); + reason = reason + errorMessage; + passed = false; } - var testcase = new TestCase( SECTION, testname, true, passed); - if (!passed) - testcase.reason = reason; - return testcase; } - - var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; - var b = [1,2,3,4,5,6,7,8,9,0]; - - testcases[count++] = exhaustiveSpliceTest("exhaustive splice w/no optional args 1",a); - testcases[count++] = exhaustiveSpliceTest("exhaustive splice w/no optional args 1",b); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); - + } + var testcase = new TestCase( SECTION, testname, true, passed); + if (!passed) + testcase.reason = reason; + return testcase; +} diff --git a/mozilla/js/tests/js1_2/Array/splice2.js b/mozilla/js/tests/js1_2/Array/splice2.js index 59f4af07643..b6cc9297dcd 100644 --- a/mozilla/js/tests/js1_2/Array/splice2.js +++ b/mozilla/js/tests/js1_2/Array/splice2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,132 +35,114 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: splice2.js - Description: 'Tests Array.splice(x,y) w/4 var args' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: splice2.js + Description: 'Tests Array.splice(x,y) w/4 var args' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String:splice 2'; - var BUGNUMBER="123795"; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String:splice 2'; +var BUGNUMBER="123795"; - writeHeaderToLog('Executing script: splice2.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: splice2.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; +var b = [1,2,3,4,5,6,7,8,9,0]; + +exhaustiveSpliceTestWithArgs("exhaustive splice w/2 optional args 1",a); +exhaustiveSpliceTestWithArgs("exhaustive splice w/2 optional args 2",b); + +test(); - function mySplice(testArray, splicedArray, first, len, elements) +function mySplice(testArray, splicedArray, first, len, elements) +{ + var removedArray = []; + var adjustedFirst = first; + var adjustedLen = len; + + if (adjustedFirst < 0) adjustedFirst = testArray.length + first; + if (adjustedFirst < 0) adjustedFirst = 0; + + if (adjustedLen < 0) adjustedLen = 0; + + for (i = 0; (i < adjustedFirst)&&(i < testArray.length); ++i) + splicedArray.push(testArray[i]); + + if (adjustedFirst < testArray.length) + for (i = adjustedFirst; (i < adjustedFirst + adjustedLen) && (i < testArray.length); ++i) + removedArray.push(testArray[i]); + + for (i = 0; i < elements.length; i++) splicedArray.push(elements[i]); + + for (i = adjustedFirst + adjustedLen; i < testArray.length; i++) + splicedArray.push(testArray[i]); + + return removedArray; +} + +function exhaustiveSpliceTestWithArgs(testname, testArray) +{ + var passed = true; + var errorMessage; + var reason = ""; + for (var first = -(testArray.length+2); first <= 2 + testArray.length; first++) + { + var actualSpliced = []; + var expectedSpliced = []; + var actualRemoved = []; + var expectedRemoved = []; + + for (var len = 0; len < testArray.length + 2; len++) { - var removedArray = []; - var adjustedFirst = first; - var adjustedLen = len; + actualSpliced = []; + expectedSpliced = []; + for (var i = 0; i < testArray.length; ++i) + actualSpliced.push(testArray[i]); + + actualRemoved = actualSpliced.splice(first,len,-97,new String("test arg"),[],9.8); + expectedRemoved = mySplice(testArray,expectedSpliced,first,len,[-97,new String("test arg"),[],9.8]); + + var adjustedFirst = first; if (adjustedFirst < 0) adjustedFirst = testArray.length + first; if (adjustedFirst < 0) adjustedFirst = 0; - if (adjustedLen < 0) adjustedLen = 0; - for (i = 0; (i < adjustedFirst)&&(i < testArray.length); ++i) - splicedArray.push(testArray[i]); - - if (adjustedFirst < testArray.length) - for (i = adjustedFirst; (i < adjustedFirst + adjustedLen) && (i < testArray.length); ++i) - removedArray.push(testArray[i]); - - for (i = 0; i < elements.length; i++) splicedArray.push(elements[i]); - - for (i = adjustedFirst + adjustedLen; i < testArray.length; i++) - splicedArray.push(testArray[i]); - - return removedArray; - } - - function exhaustiveSpliceTestWithArgs(testname, testArray) - { - var passed = true; - var errorMessage; - var reason = ""; - for (var first = -(testArray.length+2); first <= 2 + testArray.length; first++) + if ( (String(actualSpliced) != String(expectedSpliced)) + ||(String(actualRemoved) != String(expectedRemoved))) { - var actualSpliced = []; - var expectedSpliced = []; - var actualRemoved = []; - var expectedRemoved = []; + if ( (String(actualSpliced) == String(expectedSpliced)) + &&(String(actualRemoved) != String(expectedRemoved)) ) + { - for (var len = 0; len < testArray.length + 2; len++) - { - actualSpliced = []; - expectedSpliced = []; + if ( (expectedRemoved.length == 1) + &&(String(actualRemoved) == String(expectedRemoved[0]))) continue; + if ( expectedRemoved.length == 0 && actualRemoved == void 0 ) continue; + } - for (var i = 0; i < testArray.length; ++i) - actualSpliced.push(testArray[i]); - - actualRemoved = actualSpliced.splice(first,len,-97,new String("test arg"),[],9.8); - expectedRemoved = mySplice(testArray,expectedSpliced,first,len,[-97,new String("test arg"),[],9.8]); - - var adjustedFirst = first; - if (adjustedFirst < 0) adjustedFirst = testArray.length + first; - if (adjustedFirst < 0) adjustedFirst = 0; - - - if ( (String(actualSpliced) != String(expectedSpliced)) - ||(String(actualRemoved) != String(expectedRemoved))) - { - if ( (String(actualSpliced) == String(expectedSpliced)) - &&(String(actualRemoved) != String(expectedRemoved)) ) - { - - if ( (expectedRemoved.length == 1) - &&(String(actualRemoved) == String(expectedRemoved[0]))) continue; - if ( expectedRemoved.length == 0 && actualRemoved == void 0 ) continue; - } - - errorMessage = - "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + - " test: " + "a.splice(" + first + "," + len + ",-97,new String('test arg'),[],9.8)\n" + - " a: " + String(testArray) + "\n" + - " actual spliced: " + String(actualSpliced) + "\n" + - " expected spliced: " + String(expectedSpliced) + "\n" + - " actual removed: " + String(actualRemoved) + "\n" + - " expected removed: " + String(expectedRemoved); - reason = reason + errorMessage; - writeHeaderToLog(errorMessage); - passed = false; - } - } + errorMessage = + "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + + " test: " + "a.splice(" + first + "," + len + ",-97,new String('test arg'),[],9.8)\n" + + " a: " + String(testArray) + "\n" + + " actual spliced: " + String(actualSpliced) + "\n" + + " expected spliced: " + String(expectedSpliced) + "\n" + + " actual removed: " + String(actualRemoved) + "\n" + + " expected removed: " + String(expectedRemoved); + reason = reason + errorMessage; + writeHeaderToLog(errorMessage); + passed = false; } - var testcase = new TestCase(SECTION, testname, true, passed); - if (!passed) testcase.reason = reason; - return testcase; } - - - var a = ['a','test string',456,9.34,new String("string object"),[],['h','i','j','k']]; - var b = [1,2,3,4,5,6,7,8,9,0]; - - testcases[count++] = exhaustiveSpliceTestWithArgs("exhaustive splice w/2 optional args 1",a); - testcases[count++] = exhaustiveSpliceTestWithArgs("exhaustive splice w/2 optional args 2",b); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); - + } + var testcase = new TestCase(SECTION, testname, true, passed); + if (!passed) testcase.reason = reason; + return testcase; +} diff --git a/mozilla/js/tests/js1_2/Array/tostring_1.js b/mozilla/js/tests/js1_2/Array/tostring_1.js index c2a90caf107..11168f63107 100644 --- a/mozilla/js/tests/js1_2/Array/tostring_1.js +++ b/mozilla/js/tests/js1_2/Array/tostring_1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,105 +36,88 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: tostring_1.js - ECMA Section: Array.toString() - Description: + File Name: tostring_1.js + ECMA Section: Array.toString() + Description: - This checks the ToString value of Array objects under JavaScript 1.2. + This checks the ToString value of Array objects under JavaScript 1.2. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "JS1_2"; - var VERSION = "JS1_2"; - startTest(); - var TITLE = "Array.toString()"; +var SECTION = "JS1_2"; +var VERSION = "JS1_2"; +startTest(); +var TITLE = "Array.toString()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var a = new Array(); - var a = new Array(); +var VERSION = 0; - var VERSION = 0; - - if ( typeof version == "function" ) { - version(120); - VERSION = "120"; - } else { - function version() { return 0; }; - } - - testcases[tc++] = new TestCase ( SECTION, - "var a = new Array(); a.toString()", - ( VERSION == "120" ? "[]" : "" ), - a.toString() ); - - a[0] = void 0; - - testcases[tc++] = new TestCase ( SECTION, - "a[0] = void 0; a.toString()", - ( VERSION == "120" ? "[, ]" : "" ), - a.toString() ); - - - testcases[tc++] = new TestCase( SECTION, - "a.length", - 1, - a.length ); - - a[1] = void 0; - - testcases[tc++] = new TestCase( SECTION, - "a[1] = void 0; a.toString()", - ( VERSION == "120" ? "[, , ]" : "," ), - a.toString() ); - - a[1] = "hi"; - - testcases[tc++] = new TestCase( SECTION, - "a[1] = \"hi\"; a.toString()", - ( VERSION == "120" ? "[, \"hi\"]" : ",hi" ), - a.toString() ); - - a[2] = void 0; - - testcases[tc++] = new TestCase( SECTION, - "a[2] = void 0; a.toString()", - ( VERSION == "120" ?"[, \"hi\", , ]":",hi,"), - a.toString() ); - - var b = new Array(1000); - var bstring = ""; - for ( blen=0; blen<999; blen++) { - bstring += ","; - } - - - testcases[tc++] = new TestCase ( SECTION, - "var b = new Array(1000); b.toString()", - ( VERSION == "120" ? "[1000]" : bstring ), - b.toString() ); - - - testcases[tc++] = new TestCase( SECTION, - "b.length", - ( VERSION == "120" ? 1 : 1000 ), - b.length ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +if ( version() == 120 ) { + VERSION = "120"; +} else { + VERSION = ""; } + +new TestCase ( SECTION, + "var a = new Array(); a.toString()", + ( VERSION == "120" ? "[]" : "" ), + a.toString() ); + +a[0] = void 0; + +new TestCase ( SECTION, + "a[0] = void 0; a.toString()", + ( VERSION == "120" ? "[, ]" : "" ), + a.toString() ); + + +new TestCase( SECTION, + "a.length", + 1, + a.length ); + +a[1] = void 0; + +new TestCase( SECTION, + "a[1] = void 0; a.toString()", + ( VERSION == "120" ? "[, , ]" : "," ), + a.toString() ); + +a[1] = "hi"; + +new TestCase( SECTION, + "a[1] = \"hi\"; a.toString()", + ( VERSION == "120" ? "[, \"hi\"]" : ",hi" ), + a.toString() ); + +a[2] = void 0; + +new TestCase( SECTION, + "a[2] = void 0; a.toString()", + ( VERSION == "120" ?"[, \"hi\", , ]":",hi,"), + a.toString() ); + +var b = new Array(1000); +var bstring = ""; +for ( blen=0; blen<999; blen++) { + bstring += ","; +} + + +new TestCase ( SECTION, + "var b = new Array(1000); b.toString()", + ( VERSION == "120" ? "[1000]" : bstring ), + b.toString() ); + + +new TestCase( SECTION, + "b.length", + ( VERSION == "120" ? 1 : 1000 ), + b.length ); + +test(); diff --git a/mozilla/js/tests/js1_2/Array/tostring_2.js b/mozilla/js/tests/js1_2/Array/tostring_2.js index 06512e03ff9..0a6da87dda1 100644 --- a/mozilla/js/tests/js1_2/Array/tostring_2.js +++ b/mozilla/js/tests/js1_2/Array/tostring_2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,62 +36,44 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: tostring_2.js - Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=114564 - Description: toString in version 120 + File Name: tostring_2.js + Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=114564 + Description: toString in version 120 - Author: christine@netscape.com - Date: 15 June 1998 + Author: christine@netscape.com + Date: 15 June 1998 */ - var SECTION = "Array/tostring_2.js"; - var VERSION = "JS_12"; - startTest(); - var TITLE = "Array.toString"; +var SECTION = "Array/tostring_2.js"; +var VERSION = "JS_12"; +startTest(); +var TITLE = "Array.toString"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - var a = []; +var a = []; - if ( typeof version == "function" ) { - writeLineToLog("version 120"); - version(120); - VERSION = "120"; - } else { - function version() { return 0; }; - } - - testcases[tc++] = new TestCase ( SECTION, - "a.toString()", - ( VERSION == "120" ? "[]" : "" ), - a.toString() ); - - testcases[tc++] = new TestCase ( SECTION, - "String( a )", - ( VERSION == "120" ? "[]" : "" ), - String( a ) ); - - testcases[tc++] = new TestCase ( SECTION, - "a +''", - ( VERSION == "120" ? "[]" : "" ), - a+"" ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +if ( version() == 120 ) { + VERSION = "120"; +} else { + VERSION = ""; } + +new TestCase ( SECTION, + "a.toString()", + ( VERSION == "120" ? "[]" : "" ), + a.toString() ); + +new TestCase ( SECTION, + "String( a )", + ( VERSION == "120" ? "[]" : "" ), + String( a ) ); + +new TestCase ( SECTION, + "a +''", + ( VERSION == "120" ? "[]" : "" ), + a+"" ); + +test(); diff --git a/mozilla/js/tests/js1_2/Objects/browser.js b/mozilla/js/tests/js1_2/Objects/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/Objects/shell.js b/mozilla/js/tests/js1_2/Objects/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/Objects/toString-001.js b/mozilla/js/tests/js1_2/Objects/toString-001.js index c46735e65f0..1bf70625533 100644 --- a/mozilla/js/tests/js1_2/Objects/toString-001.js +++ b/mozilla/js/tests/js1_2/Objects/toString-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,75 +36,59 @@ * * ***** END LICENSE BLOCK ***** */ /** - File Name: toString_1.js - ECMA Section: Object.toString() - Description: + File Name: toString_1.js + ECMA Section: Object.toString() + Description: - This checks the ToString value of Object objects under JavaScript 1.2. + This checks the ToString value of Object objects under JavaScript 1.2. - In JavaScript 1.2, Object.toString() + In JavaScript 1.2, Object.toString() - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "JS1_2"; - var VERSION = "JS1_2"; - startTest(); - var TITLE = "Object.toString()"; +var SECTION = "JS1_2"; +var VERSION = "JS1_2"; +startTest(); +var TITLE = "Object.toString()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var o = new Object(); - var o = new Object(); +new TestCase( SECTION, + "var o = new Object(); o.toString()", + "{}", + o.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "var o = new Object(); o.toString()", - "{}", - o.toString() ); +o = {}; - o = {}; +new TestCase( SECTION, + "o = {}; o.toString()", + "{}", + o.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "o = {}; o.toString()", - "{}", - o.toString() ); +o = { name:"object", length:0, value:"hello" } - o = { name:"object", length:0, value:"hello" } +new TestCase( SECTION, + "o = { name:\"object\", length:0, value:\"hello\" }; o.toString()", + true, + checkObjectToString(o.toString(), ['name:"object"', 'length:0', + 'value:"hello"'])); - testcases[testcases.length] = new TestCase( SECTION, - "o = { name:\"object\", length:0, value:\"hello\" }; o.toString()", - true, - checkObjectToString(o.toString(), ['name:"object"', 'length:0', - 'value:"hello"'])); +o = { name:"object", length:0, value:"hello", + toString:new Function( "return this.value+''" ) } - o = { name:"object", length:0, value:"hello", - toString:new Function( "return this.value+''" ) } - - testcases[testcases.length] = new TestCase( SECTION, - "o = { name:\"object\", length:0, value:\"hello\", "+ - "toString:new Function( \"return this.value+''\" ) }; o.toString()", - "hello", - o.toString() ); +new TestCase( SECTION, + "o = { name:\"object\", length:0, value:\"hello\", "+ + "toString:new Function( \"return this.value+''\" ) }; o.toString()", + "hello", + o.toString() ); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); /** * checkObjectToString @@ -117,7 +102,7 @@ function test() { function checkObjectToString(s, a) { var m = /^\{(.*)\}$/(s); if (!m) - return false; // should begin and end with curly brackets + return false; // should begin and end with curly brackets var a2 = m[1].split(", "); if (a.length != a2.length) return false; // should be same length @@ -125,7 +110,7 @@ function checkObjectToString(s, a) { a2.sort(); for (var i=0; i < a.length; i++) { if (a[i] != a2[i]) - return false; // should have identical elements + return false; // should have identical elements } return true; } diff --git a/mozilla/js/tests/js1_2/README b/mozilla/js/tests/js1_2/README new file mode 100755 index 00000000000..550890ec4ab --- /dev/null +++ b/mozilla/js/tests/js1_2/README @@ -0,0 +1 @@ +JavaScript 1.2 diff --git a/mozilla/js/tests/js1_2/String/browser.js b/mozilla/js/tests/js1_2/String/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/String/charCodeAt.js b/mozilla/js/tests/js1_2/String/charCodeAt.js index 7d67c3c9331..a6cdb64c2f9 100644 --- a/mozilla/js/tests/js1_2/String/charCodeAt.js +++ b/mozilla/js/tests/js1_2/String/charCodeAt.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,36 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: charCodeAt.js - Description: 'This tests new String object method: charCodeAt' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: charCodeAt.js + Description: 'This tests new String object method: charCodeAt' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String:charCodeAt'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String:charCodeAt'; - writeHeaderToLog('Executing script: charCodeAt.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); +writeHeaderToLog('Executing script: charCodeAt.js'); +writeHeaderToLog( SECTION + " "+ TITLE); +var aString = new String("tEs5"); - var aString = new String("tEs5"); +new TestCase( SECTION, "aString.charCodeAt(-2)", NaN, aString.charCodeAt(-2)); +new TestCase( SECTION, "aString.charCodeAt(-1)", NaN, aString.charCodeAt(-1)); +new TestCase( SECTION, "aString.charCodeAt( 0)", 116, aString.charCodeAt( 0)); +new TestCase( SECTION, "aString.charCodeAt( 1)", 69, aString.charCodeAt( 1)); +new TestCase( SECTION, "aString.charCodeAt( 2)", 115, aString.charCodeAt( 2)); +new TestCase( SECTION, "aString.charCodeAt( 3)", 53, aString.charCodeAt( 3)); +new TestCase( SECTION, "aString.charCodeAt( 4)", NaN, aString.charCodeAt( 4)); +new TestCase( SECTION, "aString.charCodeAt( 5)", NaN, aString.charCodeAt( 5)); +new TestCase( SECTION, "aString.charCodeAt( Infinity)", NaN, aString.charCodeAt( Infinity)); +new TestCase( SECTION, "aString.charCodeAt(-Infinity)", NaN, aString.charCodeAt(-Infinity)); +//new TestCase( SECTION, "aString.charCodeAt( )", 116, aString.charCodeAt( )); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-2)", NaN, aString.charCodeAt(-2)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-1)", NaN, aString.charCodeAt(-1)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 0)", 116, aString.charCodeAt( 0)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 1)", 69, aString.charCodeAt( 1)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 2)", 115, aString.charCodeAt( 2)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 3)", 53, aString.charCodeAt( 3)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 4)", NaN, aString.charCodeAt( 4)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( 5)", NaN, aString.charCodeAt( 5)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( Infinity)", NaN, aString.charCodeAt( Infinity)); - testcases[count++] = new TestCase( SECTION, "aString.charCodeAt(-Infinity)", NaN, aString.charCodeAt(-Infinity)); - //testcases[count++] = new TestCase( SECTION, "aString.charCodeAt( )", 116, aString.charCodeAt( )); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/String/concat.js b/mozilla/js/tests/js1_2/String/concat.js index 1751bcc1f6f..413e0a12086 100644 --- a/mozilla/js/tests/js1_2/String/concat.js +++ b/mozilla/js/tests/js1_2/String/concat.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,64 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: concat.js - Description: 'This tests the new String object method: concat' - Author: NickLerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: concat.js + Description: 'This tests the new String object method: concat' + + Author: NickLerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String:concat'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String:concat'; - writeHeaderToLog('Executing script: concat.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: concat.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var aString = new String("test string"); +var bString = new String(" another "); +new TestCase( SECTION, "aString.concat(' more')", "test string more", aString.concat(' more').toString()); +new TestCase( SECTION, "aString.concat(bString)", "test string another ", aString.concat(bString).toString()); +new TestCase( SECTION, "aString ", "test string", aString.toString()); +new TestCase( SECTION, "bString ", " another ", bString.toString()); +new TestCase( SECTION, "aString.concat(345) ", "test string345", aString.concat(345).toString()); +new TestCase( SECTION, "aString.concat(true) ", "test stringtrue", aString.concat(true).toString()); +new TestCase( SECTION, "aString.concat(null) ", "test stringnull", aString.concat(null).toString()); +new TestCase( SECTION, "aString.concat([]) ", "test string[]", aString.concat([]).toString()); +new TestCase( SECTION, "aString.concat([1,2,3])", "test string[1, 2, 3]", aString.concat([1,2,3]).toString()); - var aString = new String("test string"); - var bString = new String(" another "); +new TestCase( SECTION, "'abcde'.concat(' more')", "abcde more", 'abcde'.concat(' more').toString()); +new TestCase( SECTION, "'abcde'.concat(bString)", "abcde another ", 'abcde'.concat(bString).toString()); +new TestCase( SECTION, "'abcde' ", "abcde", 'abcde'); +new TestCase( SECTION, "'abcde'.concat(345) ", "abcde345", 'abcde'.concat(345).toString()); +new TestCase( SECTION, "'abcde'.concat(true) ", "abcdetrue", 'abcde'.concat(true).toString()); +new TestCase( SECTION, "'abcde'.concat(null) ", "abcdenull", 'abcde'.concat(null).toString()); +new TestCase( SECTION, "'abcde'.concat([]) ", "abcde[]", 'abcde'.concat([]).toString()); +new TestCase( SECTION, "'abcde'.concat([1,2,3])", "abcde[1, 2, 3]", 'abcde'.concat([1,2,3]).toString()); - testcases[count++] = new TestCase( SECTION, "aString.concat(' more')", "test string more", aString.concat(' more').toString()); - testcases[count++] = new TestCase( SECTION, "aString.concat(bString)", "test string another ", aString.concat(bString).toString()); - testcases[count++] = new TestCase( SECTION, "aString ", "test string", aString.toString()); - testcases[count++] = new TestCase( SECTION, "bString ", " another ", bString.toString()); - testcases[count++] = new TestCase( SECTION, "aString.concat(345) ", "test string345", aString.concat(345).toString()); - testcases[count++] = new TestCase( SECTION, "aString.concat(true) ", "test stringtrue", aString.concat(true).toString()); - testcases[count++] = new TestCase( SECTION, "aString.concat(null) ", "test stringnull", aString.concat(null).toString()); - testcases[count++] = new TestCase( SECTION, "aString.concat([]) ", "test string[]", aString.concat([]).toString()); - testcases[count++] = new TestCase( SECTION, "aString.concat([1,2,3])", "test string[1, 2, 3]", aString.concat([1,2,3]).toString()); +//what should this do: +new TestCase( SECTION, "'abcde'.concat() ", "abcde", 'abcde'.concat().toString()); - testcases[count++] = new TestCase( SECTION, "'abcde'.concat(' more')", "abcde more", 'abcde'.concat(' more').toString()); - testcases[count++] = new TestCase( SECTION, "'abcde'.concat(bString)", "abcde another ", 'abcde'.concat(bString).toString()); - testcases[count++] = new TestCase( SECTION, "'abcde' ", "abcde", 'abcde'); - testcases[count++] = new TestCase( SECTION, "'abcde'.concat(345) ", "abcde345", 'abcde'.concat(345).toString()); - testcases[count++] = new TestCase( SECTION, "'abcde'.concat(true) ", "abcdetrue", 'abcde'.concat(true).toString()); - testcases[count++] = new TestCase( SECTION, "'abcde'.concat(null) ", "abcdenull", 'abcde'.concat(null).toString()); - testcases[count++] = new TestCase( SECTION, "'abcde'.concat([]) ", "abcde[]", 'abcde'.concat([]).toString()); - testcases[count++] = new TestCase( SECTION, "'abcde'.concat([1,2,3])", "abcde[1, 2, 3]", 'abcde'.concat([1,2,3]).toString()); - - //what should this do: - testcases[count++] = new TestCase( SECTION, "'abcde'.concat() ", "abcde", 'abcde'.concat().toString()); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/String/match.js b/mozilla/js/tests/js1_2/String/match.js index 18fbf17a23e..7b7d1756b9a 100644 --- a/mozilla/js/tests/js1_2/String/match.js +++ b/mozilla/js/tests/js1_2/String/match.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,44 +35,27 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: match.js - Description: 'This tests the new String object method: match' - Author: NickLerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: match.js + Description: 'This tests the new String object method: match' + + Author: NickLerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String:match'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String:match'; - writeHeaderToLog('Executing script: match.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: match.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var aString = new String("this is a test string"); +new TestCase( SECTION, "aString.match(/is.*test/) ", String(["is is a test"]), String(aString.match(/is.*test/))); +new TestCase( SECTION, "aString.match(/s.*s/) ", String(["s is a test s"]), String(aString.match(/s.*s/))); - var aString = new String("this is a test string"); - - testcases[count++] = new TestCase( SECTION, "aString.match(/is.*test/) ", String(["is is a test"]), String(aString.match(/is.*test/))); - testcases[count++] = new TestCase( SECTION, "aString.match(/s.*s/) ", String(["s is a test s"]), String(aString.match(/s.*s/))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/String/shell.js b/mozilla/js/tests/js1_2/String/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/String/slice.js b/mozilla/js/tests/js1_2/String/slice.js index a1e20ae5d10..083bfe6d69f 100644 --- a/mozilla/js/tests/js1_2/String/slice.js +++ b/mozilla/js/tests/js1_2/String/slice.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,105 +35,88 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: slice.js - Description: 'This tests the String object method: slice' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: slice.js + Description: 'This tests the String object method: slice' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String.slice'; - - writeHeaderToLog('Executing script: slice.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String.slice'; +writeHeaderToLog('Executing script: slice.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - function myStringSlice(a, from, to) +var a = new String("abcdefghijklmnopqrstuvwxyz1234567890"); +var b = new String("this is a test string"); + +exhaustiveStringSliceTest("exhaustive String.slice test 1", a); +exhaustiveStringSliceTest("exhaustive String.slice test 2", b); + +test(); + + +function myStringSlice(a, from, to) +{ + var from2 = from; + var to2 = to; + var returnString = new String(""); + var i; + + if (from2 < 0) from2 = a.length + from; + if (to2 < 0) to2 = a.length + to; + + if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length)) + { + if (from2 < 0) from2 = 0; + if (to2 > a.length) to2 = a.length; + + for (i = from2; i < to2; ++i) returnString += a.charAt(i); + } + return returnString; +} + +// This function tests the slice command on a String +// passed in. The arguments passed into slice range in +// value from -5 to the length of the array + 4. Every +// combination of the two arguments is tested. The expected +// result of the slice(...) method is calculated and +// compared to the actual result from the slice(...) method. +// If the Strings are not similar false is returned. +function exhaustiveStringSliceTest(testname, a) +{ + var x = 0; + var y = 0; + var errorMessage; + var reason = ""; + var passed = true; + + for (x = -(2 + a.length); x <= (2 + a.length); x++) + for (y = (2 + a.length); y >= -(2 + a.length); y--) { - var from2 = from; - var to2 = to; - var returnString = new String(""); - var i; + var b = a.slice(x,y); + var c = myStringSlice(a,x,y); - if (from2 < 0) from2 = a.length + from; - if (to2 < 0) to2 = a.length + to; - - if ((to2 > from2)&&(to2 > 0)&&(from2 < a.length)) + if (String(b) != String(c)) { - if (from2 < 0) from2 = 0; - if (to2 > a.length) to2 = a.length; - - for (i = from2; i < to2; ++i) returnString += a.charAt(i); + errorMessage = + "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + + " test: " + "a.slice(" + x + "," + y + ")\n" + + " a: " + String(a) + "\n" + + " actual result: " + String(b) + "\n" + + " expected result: " + String(c) + "\n"; + writeHeaderToLog(errorMessage); + reason = reason + errorMessage; + passed = false; } - return returnString; } - - // This function tests the slice command on a String - // passed in. The arguments passed into slice range in - // value from -5 to the length of the array + 4. Every - // combination of the two arguments is tested. The expected - // result of the slice(...) method is calculated and - // compared to the actual result from the slice(...) method. - // If the Strings are not similar false is returned. - function exhaustiveStringSliceTest(testname, a) - { - var x = 0; - var y = 0; - var errorMessage; - var reason = ""; - var passed = true; - - for (x = -(2 + a.length); x <= (2 + a.length); x++) - for (y = (2 + a.length); y >= -(2 + a.length); y--) - { - var b = a.slice(x,y); - var c = myStringSlice(a,x,y); - - if (String(b) != String(c)) - { - errorMessage = - "ERROR: 'TEST FAILED' ERROR: 'TEST FAILED' ERROR: 'TEST FAILED'\n" + - " test: " + "a.slice(" + x + "," + y + ")\n" + - " a: " + String(a) + "\n" + - " actual result: " + String(b) + "\n" + - " expected result: " + String(c) + "\n"; - writeHeaderToLog(errorMessage); - reason = reason + errorMessage; - passed = false; - } - } - var testCase = new TestCase(SECTION, testname, true, passed); - if (passed == false) - testCase.reason = reason; - return testCase; - } - - var a = new String("abcdefghijklmnopqrstuvwxyz1234567890"); - var b = new String("this is a test string"); - - testcases[count++] = exhaustiveStringSliceTest("exhaustive String.slice test 1", a); - testcases[count++] = exhaustiveStringSliceTest("exhaustive String.slice test 2", b); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); - + var testCase = new TestCase(SECTION, testname, true, passed); + if (passed == false) + testCase.reason = reason; + return testCase; +} diff --git a/mozilla/js/tests/js1_2/browser.js b/mozilla/js/tests/js1_2/browser.js index eae43695877..5670a40c883 100644 --- a/mozilla/js/tests/js1_2/browser.js +++ b/mozilla/js/tests/js1_2/browser.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -49,50 +50,77 @@ * <script src="./mytest.js"></script> */ -onerror = err; - var GLOBAL = "[object Window]"; -function startTest() { - writeHeaderToLog( SECTION + " "+ TITLE); - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; -} - function writeLineToLog( string ) { - document.write( string + "<br>\n"); + document.write( string + "<br>\n"); } -function writeHeaderToLog( string ) { - document.write( "<h2>" + string + "</h2>" ); -} -function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } - document.write( "<hr>" ); -} -function writeFormattedResult( expect, actual, string, passed ) { - var s = "<tt>"+ string ; - s += "<b>" ; - s += ( passed ) ? "<font color=#009900>  " + PASSED - : "<font color=#aa0000> " + FAILED + expect + "</tt>"; - writeLineToLog( s + "</font></b></tt>" ); - return passed; -} -function err ( msg, page, line ) { - writeLineToLog( "Test " + page + " failed on line " + line +" with the message: " + msg ); - testcases[tc].actual = "error"; - testcases[tc].reason = msg; - writeTestCaseResult( testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual + - ": " + testcases[tc].reason ); - stopTest(); - return true; +function writeHeaderToLog( string ) { + document.write( "<h2>" + string + "</h2>" ); +} + +function writeFormattedResult( expect, actual, string, passed ) { + var s = "<tt>"+ string ; + s += "<b>" ; + s += ( passed ) ? "<font color=#009900>  " + PASSED + : "<font color=#aa0000> " + FAILED + expect + "</tt>"; + writeLineToLog( s + "</font></b></tt>" ); + return passed; +} + +/* + * The earlier versions of the test code used exceptions + * to terminate the test script in "negative" test cases + * before the failure reporting code could run. In order + * to be able to capture errors for the "negative" case + * where the exception is a sign the test actually passed, + * the err online handler will assume that any error is a + * failure unless gExceptionExpected is true. + */ +window.onerror = err; +var gExceptionExpected = false; + +function err( msg, page, line ) { + var testcase; + + if (typeof(EXPECTED) == "undefined" || EXPECTED != "error") { + /* + * an unexpected exception occured + */ + writeLineToLog( "Test failed with the message: " + msg ); + testcase = new TestCase(SECTION, "unknown", "unknown", "unknown"); + testcase.passed = false; + testcase.reason = "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + return; + } + + if (typeof SECTION == 'undefined') + { + SECTION = 'Unknown'; + } + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + + testcase = new TestCase(SECTION, DESCRIPTION, EXPECTED, "error"); + testcase.reason += "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + stopTest(); +} + +var gVersion = 0; + +function version(v) +{ + if (v) { + gVersion = v; + } + return gVersion; } diff --git a/mozilla/js/tests/js1_2/function/Function_object.js b/mozilla/js/tests/js1_2/function/Function_object.js index d7166dd9ab2..3ee8a1e3f5b 100644 --- a/mozilla/js/tests/js1_2/function/Function_object.js +++ b/mozilla/js/tests/js1_2/function/Function_object.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,67 +35,51 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: Function_object.js - Description: 'Testing Function objects' - Author: Nick Lerissa - Date: April 17, 1998 +/** + Filename: Function_object.js + Description: 'Testing Function objects' + + Author: Nick Lerissa + Date: April 17, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'functions: Function_object'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'functions: Function_object'; - writeHeaderToLog('Executing script: Function_object.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); +writeHeaderToLog('Executing script: Function_object.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - function a_test_function(a,b,c) - { - return a + b + c; - } +function a_test_function(a,b,c) +{ + return a + b + c; +} - f = a_test_function; +f = a_test_function; - testcases[count++] = new TestCase( SECTION, "f.name", - 'a_test_function', f.name); +new TestCase( SECTION, "f.name", + 'a_test_function', f.name); - testcases[count++] = new TestCase( SECTION, "f.length", - 3, f.length); +new TestCase( SECTION, "f.length", + 3, f.length); - testcases[count++] = new TestCase( SECTION, "f.arity", - 3, f.arity); +new TestCase( SECTION, "f.arity", + 3, f.arity); - testcases[count++] = new TestCase( SECTION, "f(2,3,4)", - 9, f(2,3,4)); +new TestCase( SECTION, "f(2,3,4)", + 9, f(2,3,4)); - var fnName = version() == 120 ? '' : 'anonymous'; +var fnName = (version() == 120) ? '' : 'anonymous'; - testcases[count++] = new TestCase( SECTION, "(new Function()).name", - fnName, (new Function()).name); +new TestCase( SECTION, "(new Function()).name", + fnName, (new Function()).name); - testcases[count++] = new TestCase( SECTION, "(new Function()).toString()", - '\nfunction ' + fnName + '() {\n}\n', (new Function()).toString()); +new TestCase( SECTION, "(new Function()).toString()", + '\nfunction ' + fnName + '() {\n}\n', (new Function()).toString()); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/function/Number.js b/mozilla/js/tests/js1_2/function/Number.js index 72904b6f278..c995d44c3a9 100644 --- a/mozilla/js/tests/js1_2/function/Number.js +++ b/mozilla/js/tests/js1_2/function/Number.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,49 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: Number.js - Description: 'This tests the function Number(Object)' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: Number.js + Description: 'This tests the function Number(Object)' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'functions: Number'; - var BUGNUMBER="123435"; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'functions: Number'; +var BUGNUMBER="123435"; - writeHeaderToLog('Executing script: Number.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: Number.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +date = new Date(2200); + +new TestCase( SECTION, "Number(new Date(2200)) ", + 2200, (Number(date))); +new TestCase( SECTION, "Number(true) ", + 1, (Number(true))); +new TestCase( SECTION, "Number(false) ", + 0, (Number(false))); +new TestCase( SECTION, "Number('124') ", + 124, (Number('124'))); +new TestCase( SECTION, "Number('1.23') ", + 1.23, (Number('1.23'))); +new TestCase( SECTION, "Number({p:1}) ", + NaN, (Number({p:1}))); +new TestCase( SECTION, "Number(null) ", + 0, (Number(null))); +new TestCase( SECTION, "Number(-45) ", + -45, (Number(-45))); + +// http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123435 +// under js1.2, Number([1,2,3]) should return 3. + +new TestCase( SECTION, "Number([1,2,3]) ", + 3, (Number([1,2,3]))); - date = new Date(2200); - - testcases[count++] = new TestCase( SECTION, "Number(new Date(2200)) ", - 2200, (Number(date))); - testcases[count++] = new TestCase( SECTION, "Number(true) ", - 1, (Number(true))); - testcases[count++] = new TestCase( SECTION, "Number(false) ", - 0, (Number(false))); - testcases[count++] = new TestCase( SECTION, "Number('124') ", - 124, (Number('124'))); - testcases[count++] = new TestCase( SECTION, "Number('1.23') ", - 1.23, (Number('1.23'))); - testcases[count++] = new TestCase( SECTION, "Number({p:1}) ", - NaN, (Number({p:1}))); - testcases[count++] = new TestCase( SECTION, "Number(null) ", - 0, (Number(null))); - testcases[count++] = new TestCase( SECTION, "Number(-45) ", - -45, (Number(-45))); - - // http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123435 - // under js1.2, Number([1,2,3]) should return 3. - - testcases[count++] = new TestCase( SECTION, "Number([1,2,3]) ", - 3, (Number([1,2,3]))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/function/String.js b/mozilla/js/tests/js1_2/function/String.js index 17a957fb43f..aa6913d4068 100644 --- a/mozilla/js/tests/js1_2/function/String.js +++ b/mozilla/js/tests/js1_2/function/String.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,55 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: String.js - Description: 'This tests the function String(Object)' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: String.js + Description: 'This tests the function String(Object)' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'functions: String'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'functions: String'; - writeHeaderToLog('Executing script: String.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: String.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +new TestCase( SECTION, "String(true) ", + 'true', (String(true))); +new TestCase( SECTION, "String(false) ", + 'false', (String(false))); +new TestCase( SECTION, "String(-124) ", + '-124', (String(-124))); +new TestCase( SECTION, "String(1.23) ", + '1.23', (String(1.23))); +new TestCase( SECTION, "String({p:1}) ", + '{p:1}', (String({p:1}))); +new TestCase( SECTION, "String(null) ", + 'null', (String(null))); +new TestCase( SECTION, "String([1,2,3]) ", + '[1, 2, 3]', (String([1,2,3]))); - - testcases[count++] = new TestCase( SECTION, "String(true) ", - 'true', (String(true))); - testcases[count++] = new TestCase( SECTION, "String(false) ", - 'false', (String(false))); - testcases[count++] = new TestCase( SECTION, "String(-124) ", - '-124', (String(-124))); - testcases[count++] = new TestCase( SECTION, "String(1.23) ", - '1.23', (String(1.23))); - testcases[count++] = new TestCase( SECTION, "String({p:1}) ", - '{p:1}', (String({p:1}))); - testcases[count++] = new TestCase( SECTION, "String(null) ", - 'null', (String(null))); - testcases[count++] = new TestCase( SECTION, "String([1,2,3]) ", - '[1, 2, 3]', (String([1,2,3]))); - - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/function/browser.js b/mozilla/js/tests/js1_2/function/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/function/definition-1.js b/mozilla/js/tests/js1_2/function/definition-1.js index b0aee3ac238..67ea072d620 100644 --- a/mozilla/js/tests/js1_2/function/definition-1.js +++ b/mozilla/js/tests/js1_2/function/definition-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,55 +35,41 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: definition-1.js - Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=111284 - Description: Regression test for declaring functions. - Author: christine@netscape.com - Date: 15 June 1998 +/** + File Name: definition-1.js + Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=111284 + Description: Regression test for declaring functions. + + Author: christine@netscape.com + Date: 15 June 1998 */ - var SECTION = "function/definition-1.js"; - var VERSION = "JS_12"; - startTest(); - var TITLE = "Regression test for 111284"; +var SECTION = "function/definition-1.js"; +var VERSION = "JS_12"; +startTest(); +var TITLE = "Regression test for 111284"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +f1 = function() { return "passed!" } - f1 = function() { return "passed!" } +function f2() { f3 = function() { return "passed!" }; return f3(); } - function f2() { f3 = function() { return "passed!" }; return f3(); } +new TestCase( SECTION, + 'f1 = function() { return "passed!" }; f1()', + "passed!", + f1() ); - testcases[tc++] = new TestCase( SECTION, - 'f1 = function() { return "passed!" }; f1()', - "passed!", - f1() ); +new TestCase( SECTION, + 'function f2() { f3 = function { return "passed!" }; return f3() }; f2()', + "passed!", + f2() ); - testcases[tc++] = new TestCase( SECTION, - 'function f2() { f3 = function { return "passed!" }; return f3() }; f2()', - "passed!", - f2() ); +new TestCase( SECTION, + 'f3()', + "passed!", + f3() ); - testcases[tc++] = new TestCase( SECTION, - 'f3()', - "passed!", - f3() ); +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_2/function/function-001-n.js b/mozilla/js/tests/js1_2/function/function-001-n.js index 4ef942ee5bb..2a959355647 100644 --- a/mozilla/js/tests/js1_2/function/function-001-n.js +++ b/mozilla/js/tests/js1_2/function/function-001-n.js @@ -63,9 +63,7 @@ writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - testcases[tc++] = new TestCase( + new TestCase( SECTION, "eval(\"function f(){}function g(){}\")", "error", @@ -73,17 +71,3 @@ test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_2/function/length.js b/mozilla/js/tests/js1_2/function/length.js index 9ffb5b81cf0..3df1fbcff9a 100644 --- a/mozilla/js/tests/js1_2/function/length.js +++ b/mozilla/js/tests/js1_2/function/length.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,75 +35,60 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: 15.3.5.1.js - ECMA Section: Function.length - Description: + File Name: 15.3.5.1.js + ECMA Section: Function.length + Description: - The value of the length property is usually an integer that indicates the - "typical" number of arguments expected by the function. However, the - language permits the function to be invoked with some other number of - arguments. The behavior of a function when invoked on a number of arguments - other than the number specified by its length property depends on the function. + The value of the length property is usually an integer that indicates the + "typical" number of arguments expected by the function. However, the + language permits the function to be invoked with some other number of + arguments. The behavior of a function when invoked on a number of arguments + other than the number specified by its length property depends on the function. - This checks the pre-ecma behavior Function.length. + This checks the pre-ecma behavior Function.length. - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=104204 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "function/length.js"; - var VERSION = "ECMA_1"; - startTest(); - var TITLE = "Function.length"; - var BUGNUMBER="104204"; +var SECTION = "function/length.js"; +var VERSION = "ECMA_1"; +startTest(); +var TITLE = "Function.length"; +var BUGNUMBER="104204"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var f = new Function( "a","b", "c", "return f.length"); - var f = new Function( "a","b", "c", "return f.length"); +if ( version() <= 120 ) { - if ( version() <= 120 ) { + new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 0, + f() ); - testcases[tc++] = new TestCase( SECTION, - 'var f = new Function( "a","b", "c", "return f.length"); f()', - 0, - f() ); + new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 5, + f(1,2,3,4,5) ); +} else { - testcases[tc++] = new TestCase( SECTION, - 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', - 5, - f(1,2,3,4,5) ); - } else { + new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f()', + 3, + f() ); - testcases[tc++] = new TestCase( SECTION, - 'var f = new Function( "a","b", "c", "return f.length"); f()', - 3, - f() ); - - testcases[tc++] = new TestCase( SECTION, - 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', - 3, - f(1,2,3,4,5) ); + new TestCase( SECTION, + 'var f = new Function( "a","b", "c", "return f.length"); f(1,2,3,4,5)', + 3, + f(1,2,3,4,5) ); - } - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); } +test(); diff --git a/mozilla/js/tests/js1_2/function/nesting-1.js b/mozilla/js/tests/js1_2/function/nesting-1.js index b0fda117c0a..da07759887e 100644 --- a/mozilla/js/tests/js1_2/function/nesting-1.js +++ b/mozilla/js/tests/js1_2/function/nesting-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,43 +35,29 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - File Name: nesting-1.js - Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122040 - Description: Regression test for a nested function - Author: christine@netscape.com - Date: 15 June 1998 +/** + File Name: nesting-1.js + Reference: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=122040 + Description: Regression test for a nested function + + Author: christine@netscape.com + Date: 15 June 1998 */ - var SECTION = "function/nesting-1.js"; - var VERSION = "JS_12"; - startTest(); - var TITLE = "Regression test for 122040"; +var SECTION = "function/nesting-1.js"; +var VERSION = "JS_12"; +startTest(); +var TITLE = "Regression test for 122040"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +function f(a) {function g(b) {return a+b;}; return g;}; f(7); - function f(a) {function g(b) {return a+b;}; return g;}; f(7) +new TestCase( SECTION, + 'function f(a) {function g(b) {return a+b;}; return g;}; typeof f(7)', + "function", + typeof f(7) ); - testcases[tc++] = new TestCase( SECTION, - 'function f(a) {function g(b) {return a+b;}; return g;}; typeof f(7)', - "function", - typeof f(7) ); +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_2/function/nesting.js b/mozilla/js/tests/js1_2/function/nesting.js index 35a6b870aad..3330822e9b6 100644 --- a/mozilla/js/tests/js1_2/function/nesting.js +++ b/mozilla/js/tests/js1_2/function/nesting.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,48 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: nesting.js - Description: 'This tests the nesting of functions' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: nesting.js + Description: 'This tests the nesting of functions' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'functions: nesting'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'functions: nesting'; - writeHeaderToLog('Executing script: nesting.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: nesting.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +function outer_func(x) +{ + var y = "outer"; + new TestCase( SECTION, "outer:x ", + 1111, x); + new TestCase( SECTION, "outer:y ", + 'outer', y); + function inner_func(x) + { + var y = "inner"; + new TestCase( SECTION, "inner:x ", + 2222, x); + new TestCase( SECTION, "inner:y ", + 'inner', y); + }; - function outer_func(x) - { - var y = "outer"; + inner_func(2222); + new TestCase( SECTION, "outer:x ", + 1111, x); + new TestCase( SECTION, "outer:y ", + 'outer', y); +} - testcases[count++] = new TestCase( SECTION, "outer:x ", - 1111, x); - testcases[count++] = new TestCase( SECTION, "outer:y ", - 'outer', y); - function inner_func(x) - { - var y = "inner"; - testcases[count++] = new TestCase( SECTION, "inner:x ", - 2222, x); - testcases[count++] = new TestCase( SECTION, "inner:y ", - 'inner', y); - }; +outer_func(1111); - inner_func(2222); - testcases[count++] = new TestCase( SECTION, "outer:x ", - 1111, x); - testcases[count++] = new TestCase( SECTION, "outer:y ", - 'outer', y); - } - - outer_func(1111); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/function/regexparg-1.js b/mozilla/js/tests/js1_2/function/regexparg-1.js index 49d16e6bcb5..88ab692c497 100644 --- a/mozilla/js/tests/js1_2/function/regexparg-1.js +++ b/mozilla/js/tests/js1_2/function/regexparg-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,80 +35,65 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: regexparg-1.js - Description: + File Name: regexparg-1.js + Description: - Regression test for - http://scopus/bugsplat/show_bug.cgi?id=122787 - Passing a regular expression as the first constructor argument fails + Regression test for + http://scopus/bugsplat/show_bug.cgi?id=122787 + Passing a regular expression as the first constructor argument fails - Author: christine@netscape.com - Date: 15 June 1998 + Author: christine@netscape.com + Date: 15 June 1998 */ - var SECTION = "JS_1.2"; - var VERSION = "JS_1.2"; - startTest(); - var TITLE = "The variable statment"; +var SECTION = "JS_1.2"; +var VERSION = "JS_1.2"; +startTest(); +var TITLE = "The variable statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +function f(x) {return x;} - function f(x) {return x;} +x = f(/abc/); - x = f(/abc/); +new TestCase( SECTION, + "function f(x) {return x;}; f()", + void 0, + f() ); - testcases[tc++] = new TestCase( SECTION, - "function f(x) {return x;}; f()", - void 0, - f() ); +new TestCase( SECTION, + "f(\"hi\")", + "hi", + f("hi") ); - testcases[tc++] = new TestCase( SECTION, - "f(\"hi\")", - "hi", - f("hi") ); +new TestCase( SECTION, + "new f(/abc/) +''", + "/abc/", + new f(/abc/) +"" ); - testcases[tc++] = new TestCase( SECTION, - "new f(/abc/) +''", - "/abc/", - new f(/abc/) +"" ); - - testcases[tc++] = new TestCase( SECTION, - "f(/abc/)+'')", - "/abc/", - f(/abc/) +''); +new TestCase( SECTION, + "f(/abc/)+'')", + "/abc/", + f(/abc/) +''); - testcases[tc++] = new TestCase( SECTION, - "typeof f(/abc/)", - "function", - typeof f(/abc/) ); +new TestCase( SECTION, + "typeof f(/abc/)", + "function", + typeof f(/abc/) ); - testcases[tc++] = new TestCase( SECTION, - "typeof new f(/abc/)", - "function", - typeof new f(/abc/) ); +new TestCase( SECTION, + "typeof new f(/abc/)", + "function", + typeof new f(/abc/) ); - testcases[tc++] = new TestCase( SECTION, - "x = new f(/abc/); x(\"hi\")", - null, - x("hi") ); +new TestCase( SECTION, + "x = new f(/abc/); x(\"hi\")", + null, + x("hi") ); - // js> x() - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +// js> x() +test(); diff --git a/mozilla/js/tests/js1_2/function/regexparg-2-n.js b/mozilla/js/tests/js1_2/function/regexparg-2-n.js index c659a1c35fd..d3c087da7fb 100644 --- a/mozilla/js/tests/js1_2/function/regexparg-2-n.js +++ b/mozilla/js/tests/js1_2/function/regexparg-2-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,37 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: regexparg-1.js - Description: + File Name: regexparg-1.js + Description: - Regression test for - http://scopus/bugsplat/show_bug.cgi?id=122787 - Passing a regular expression as the first constructor argument fails + Regression test for + http://scopus/bugsplat/show_bug.cgi?id=122787 + Passing a regular expression as the first constructor argument fails - Author: christine@netscape.com - Date: 15 June 1998 + Author: christine@netscape.com + Date: 15 June 1998 */ - var SECTION = "JS_1.2"; - var VERSION = "JS_1.2"; - startTest(); - var TITLE = "The variable statment"; +var SECTION = "JS_1.2"; +var VERSION = "JS_1.2"; +startTest(); +var TITLE = "The variable statement"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +function f(x) {return x;} - function f(x) {return x;} +x = f(/abc/); - x = f(/abc/); +DESCRIPTION = "function f(x) {return x;}; x = f(/abc/); x()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( SECTION, - "function f(x) {return x;}; x = f(/abc/); x()", - "error", - x() ); +new TestCase( SECTION, + "function f(x) {return x;}; x = f(/abc/); x()", + "error", + x() ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_2/function/shell.js b/mozilla/js/tests/js1_2/function/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/function/tostring-1.js b/mozilla/js/tests/js1_2/function/tostring-1.js index 974f64809bf..cc013aadbe3 100644 --- a/mozilla/js/tests/js1_2/function/tostring-1.js +++ b/mozilla/js/tests/js1_2/function/tostring-1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,70 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: tostring-1.js - Section: Function.toString - Description: + File Name: tostring-1.js + Section: Function.toString + Description: - Since the behavior of Function.toString() is implementation-dependent, - toString tests for function are not in the ECMA suite. + Since the behavior of Function.toString() is implementation-dependent, + toString tests for function are not in the ECMA suite. - Currently, an attempt to parse the toString output for some functions - and verify that the result is something reasonable. + Currently, an attempt to parse the toString output for some functions + and verify that the result is something reasonable. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "tostring-1"; - var VERSION = "JS1_2"; - startTest(); - var TITLE = "Function.toString()"; +var SECTION = "tostring-1"; +var VERSION = "JS1_2"; +startTest(); +var TITLE = "Function.toString()"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var tab = " "; - var tab = " "; +t1 = new TestFunction( "stub", "value", tab + "return value;" ); - t1 = new TestFunction( "stub", "value", tab + "return value;" ); +t2 = new TestFunction( "ToString", "object", tab+"return object + \"\";" ); - t2 = new TestFunction( "ToString", "object", tab+"return object + \"\";" ); +t3 = new TestFunction( "Add", "a, b, c, d, e", tab +"var s = a + b + c + d + e;\n" + + tab + "return s;" ); - t3 = new TestFunction( "Add", "a, b, c, d, e", tab +"var s = a + b + c + d + e;\n" + - tab + "return s;" ); +t4 = new TestFunction( "noop", "value" ); - t4 = new TestFunction( "noop", "value" ); +t5 = new TestFunction( "anonymous", "", tab+"return \"hello!\";" ); - t5 = new TestFunction( "anonymous", "", tab+"return \"hello!\";" ); +var f = new Function( "return \"hello!\""); - var f = new Function( "return \"hello!\""); +new TestCase( SECTION, + "stub.toString()", + t1.valueOf(), + stub.toString() ); - testcases[tc++] = new TestCase( SECTION, - "stub.toString()", - t1.valueOf(), - stub.toString() ); +new TestCase( SECTION, + "ToString.toString()", + t2.valueOf(), + ToString.toString() ); - testcases[tc++] = new TestCase( SECTION, - "ToString.toString()", - t2.valueOf(), - ToString.toString() ); +new TestCase( SECTION, + "Add.toString()", + t3.valueOf(), + Add.toString() ); - testcases[tc++] = new TestCase( SECTION, - "Add.toString()", - t3.valueOf(), - Add.toString() ); +new TestCase( SECTION, + "noop.toString()", + t4.toString(), + noop.toString() ); - testcases[tc++] = new TestCase( SECTION, - "noop.toString()", - t4.toString(), - noop.toString() ); - - testcases[tc++] = new TestCase( SECTION, - "f.toString()", - t5.toString(), - f.toString() ); - test(); +new TestCase( SECTION, + "f.toString()", + t5.toString(), + f.toString() ); +test(); function noop( value ) { } @@ -120,20 +120,6 @@ function ToBoolean( value ) { } } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - function TestFunction( name, args, body ) { if ( name == "anonymous" && version() == 120 ) { name = ""; @@ -144,13 +130,13 @@ function TestFunction( name, args, body ) { this.body = body; /* the format of Function.toString() in JavaScript 1.2 is: - /n - function name ( arguments ) { - body - } + /n + function name ( arguments ) { + body + } */ this.value = "\nfunction " + (name ? name : "" )+ - "("+args+") {\n"+ (( body ) ? body +"\n" : "") + "}\n"; + "("+args+") {\n"+ (( body ) ? body +"\n" : "") + "}\n"; this.toString = new Function( "return this.value" ); this.valueOf = new Function( "return this.value" ); diff --git a/mozilla/js/tests/js1_2/function/tostring-2.js b/mozilla/js/tests/js1_2/function/tostring-2.js index 2a559c0db68..884fd8d8be2 100644 --- a/mozilla/js/tests/js1_2/function/tostring-2.js +++ b/mozilla/js/tests/js1_2/function/tostring-2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,35 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: tostring-1.js - Section: Function.toString - Description: + File Name: tostring-1.js + Section: Function.toString + Description: - Since the behavior of Function.toString() is implementation-dependent, - toString tests for function are not in the ECMA suite. + Since the behavior of Function.toString() is implementation-dependent, + toString tests for function are not in the ECMA suite. - Currently, an attempt to parse the toString output for some functions - and verify that the result is something reasonable. + Currently, an attempt to parse the toString output for some functions + and verify that the result is something reasonable. - This verifies - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99212 + This verifies + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99212 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "tostring-2"; - var VERSION = "JS1_2"; - startTest(); - var TITLE = "Function.toString()"; - var BUGNUMBER="123444"; +var SECTION = "tostring-2"; +var VERSION = "JS1_2"; +startTest(); +var TITLE = "Function.toString()"; +var BUGNUMBER="123444"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - var tab = " "; +var tab = " "; var equals = new TestFunction( "Equals", "a, b", tab+ "return a == b;" ); @@ -71,7 +71,7 @@ function Equals (a, b) { } var reallyequals = new TestFunction( "ReallyEquals", "a, b", - ( version() <= 120 ) ? tab +"return a == b;" : tab +"return a === b;" ); + ( version() <= 120 ) ? tab +"return a == b;" : tab +"return a === b;" ); function ReallyEquals( a, b ) { return a === b; } @@ -82,27 +82,27 @@ function DoesntEqual( a, b ) { } var reallydoesntequal = new TestFunction( "ReallyDoesntEqual", "a, b", - ( version() <= 120 ) ? tab +"return a != b;" : tab +"return a !== b;" ); + ( version() <= 120 ) ? tab +"return a != b;" : tab +"return a !== b;" ); function ReallyDoesntEqual( a, b ) { return a !== b; } var testor = new TestFunction( "TestOr", "a", tab+"if (a == null || a == void 0) {\n"+ - tab +tab+"return 0;\n"+tab+"} else {\n"+tab+tab+"return a;\n"+tab+"}" ); + tab +tab+"return 0;\n"+tab+"} else {\n"+tab+tab+"return a;\n"+tab+"}" ); function TestOr( a ) { - if ( a == null || a == void 0 ) - return 0; - else - return a; + if ( a == null || a == void 0 ) + return 0; + else + return a; } var testand = new TestFunction( "TestAnd", "a", tab+"if (a != null && a != void 0) {\n"+ - tab+tab+"return a;\n" + tab+ "} else {\n"+tab+tab+"return 0;\n"+tab+"}" ); + tab+tab+"return a;\n" + tab+ "} else {\n"+tab+tab+"return 0;\n"+tab+"}" ); function TestAnd( a ) { - if ( a != null && a != void 0 ) - return a; - else - return 0; + if ( a != null && a != void 0 ) + return a; + else + return 0; } var or = new TestFunction( "Or", "a, b", tab + "return a | b;" ); @@ -120,79 +120,66 @@ function XOr( a, b ) { return a ^ b; } - testcases[testcases.length] = new TestCase( SECTION, - "Equals.toString()", - equals.valueOf(), - Equals.toString() ); +new TestCase( SECTION, + "Equals.toString()", + equals.valueOf(), + Equals.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "ReallyEquals.toString()", - reallyequals.valueOf(), - ReallyEquals.toString() ); +new TestCase( SECTION, + "ReallyEquals.toString()", + reallyequals.valueOf(), + ReallyEquals.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "DoesntEqual.toString()", - doesntequal.valueOf(), - DoesntEqual.toString() ); +new TestCase( SECTION, + "DoesntEqual.toString()", + doesntequal.valueOf(), + DoesntEqual.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "ReallyDoesntEqual.toString()", - reallydoesntequal.valueOf(), - ReallyDoesntEqual.toString() ); +new TestCase( SECTION, + "ReallyDoesntEqual.toString()", + reallydoesntequal.valueOf(), + ReallyDoesntEqual.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "TestOr.toString()", - testor.valueOf(), - TestOr.toString() ); +new TestCase( SECTION, + "TestOr.toString()", + testor.valueOf(), + TestOr.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "TestAnd.toString()", - testand.valueOf(), - TestAnd.toString() ); +new TestCase( SECTION, + "TestAnd.toString()", + testand.valueOf(), + TestAnd.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "Or.toString()", - or.valueOf(), - Or.toString() ); +new TestCase( SECTION, + "Or.toString()", + or.valueOf(), + Or.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "And.toString()", - and.valueOf(), - And.toString() ); +new TestCase( SECTION, + "And.toString()", + and.valueOf(), + And.toString() ); - testcases[testcases.length] = new TestCase( SECTION, - "XOr.toString()", - xor.valueOf(), - XOr.toString() ); +new TestCase( SECTION, + "XOr.toString()", + xor.valueOf(), + XOr.toString() ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} function TestFunction( name, args, body ) { this.name = name; this.arguments = args.toString(); this.body = body; /* the format of Function.toString() in JavaScript 1.2 is: - /n - function name ( arguments ) { - body - } + /n + function name ( arguments ) { + body + } */ this.value = "\nfunction " + (name ? name : "anonymous" )+ - "("+args+") {\n"+ (( body ) ? body +"\n" : "") + "}\n"; + "("+args+") {\n"+ (( body ) ? body +"\n" : "") + "}\n"; this.toString = new Function( "return this.value" ); this.valueOf = new Function( "return this.value" ); diff --git a/mozilla/js/tests/js1_2/operator/browser.js b/mozilla/js/tests/js1_2/operator/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/operator/equality.js b/mozilla/js/tests/js1_2/operator/equality.js index 98f3cae87b9..bb04d136348 100644 --- a/mozilla/js/tests/js1_2/operator/equality.js +++ b/mozilla/js/tests/js1_2/operator/equality.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,54 +35,40 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: equality.js - Description: 'This tests the operator ==' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: equality.js + Description: 'This tests the operator ==' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'operator "=="'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'operator "=="'; - writeHeaderToLog('Executing script: equality.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: equality.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var count = 0; +var testcases = new Array(); - // the following two tests are incorrect - //testcases[count++] = new TestCase( SECTION, "(new String('') == new String('')) ", - // true, (new String('') == new String(''))); +// the following two tests are incorrect +//new TestCase( SECTION, "(new String('') == new String('')) ", +// true, (new String('') == new String(''))); - //testcases[count++] = new TestCase( SECTION, "(new Boolean(true) == new Boolean(true)) ", - // true, (new Boolean(true) == new Boolean(true))); +//new TestCase( SECTION, "(new Boolean(true) == new Boolean(true)) ", +// true, (new Boolean(true) == new Boolean(true))); - testcases[count++] = new TestCase( SECTION, "(new String('x') == 'x') ", - false, (new String('x') == 'x')); +new TestCase( SECTION, "(new String('x') == 'x') ", + false, (new String('x') == 'x')); - testcases[count++] = new TestCase( SECTION, "('x' == new String('x')) ", - false, ('x' == new String('x'))); +new TestCase( SECTION, "('x' == new String('x')) ", + false, ('x' == new String('x'))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/operator/shell.js b/mozilla/js/tests/js1_2/operator/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/operator/strictEquality.js b/mozilla/js/tests/js1_2/operator/strictEquality.js index fdb0f5ed3c5..8ecb2cdf0b9 100644 --- a/mozilla/js/tests/js1_2/operator/strictEquality.js +++ b/mozilla/js/tests/js1_2/operator/strictEquality.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,74 +35,61 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: strictEquality.js - Description: 'This tests the operator ===' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: strictEquality.js + Description: 'This tests the operator ===' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'operator "==="'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'operator "==="'; - writeHeaderToLog('Executing script: strictEquality.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: strictEquality.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var count = 0; +var testcases = new Array(); - testcases[count++] = new TestCase( SECTION, "('8' === 8) ", - false, ('8' === 8)); +new TestCase( SECTION, "('8' === 8) ", + false, ('8' === 8)); - testcases[count++] = new TestCase( SECTION, "(8 === 8) ", - true, (8 === 8)); +new TestCase( SECTION, "(8 === 8) ", + true, (8 === 8)); - testcases[count++] = new TestCase( SECTION, "(8 === true) ", - false, (8 === true)); +new TestCase( SECTION, "(8 === true) ", + false, (8 === true)); - testcases[count++] = new TestCase( SECTION, "(new String('') === new String('')) ", - false, (new String('') === new String(''))); +new TestCase( SECTION, "(new String('') === new String('')) ", + false, (new String('') === new String(''))); - testcases[count++] = new TestCase( SECTION, "(new Boolean(true) === new Boolean(true))", - false, (new Boolean(true) === new Boolean(true))); +new TestCase( SECTION, "(new Boolean(true) === new Boolean(true))", + false, (new Boolean(true) === new Boolean(true))); - var anObject = { one:1 , two:2 }; +var anObject = { one:1 , two:2 }; - testcases[count++] = new TestCase( SECTION, "(anObject === anObject) ", - true, (anObject === anObject)); +new TestCase( SECTION, "(anObject === anObject) ", + true, (anObject === anObject)); - testcases[count++] = new TestCase( SECTION, "(anObject === { one:1 , two:2 }) ", - false, (anObject === { one:1 , two:2 })); +new TestCase( SECTION, "(anObject === { one:1 , two:2 }) ", + false, (anObject === { one:1 , two:2 })); - testcases[count++] = new TestCase( SECTION, "({ one:1 , two:2 } === anObject) ", - false, ({ one:1 , two:2 } === anObject)); +new TestCase( SECTION, "({ one:1 , two:2 } === anObject) ", + false, ({ one:1 , two:2 } === anObject)); - testcases[count++] = new TestCase( SECTION, "(null === null) ", - true, (null === null)); +new TestCase( SECTION, "(null === null) ", + true, (null === null)); - testcases[count++] = new TestCase( SECTION, "(null === 0) ", - false, (null === 0)); +new TestCase( SECTION, "(null === 0) ", + false, (null === 0)); - testcases[count++] = new TestCase( SECTION, "(true === !false) ", - true, (true === !false)); +new TestCase( SECTION, "(true === !false) ", + true, (true === !false)); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_dollar_number.js b/mozilla/js/tests/js1_2/regexp/RegExp_dollar_number.js index d934f1728e0..b2211907676 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_dollar_number.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_dollar_number.js @@ -51,32 +51,30 @@ writeHeaderToLog('Executing script: RegExp_dollar_number.js'); writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$1 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$1", + new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$1", 'abcdefghi', RegExp.$1); // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$2 - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$2", + new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$2", 'bcdefgh', RegExp.$2); // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$3 - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$3", + new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$3", 'cdefg', RegExp.$3); // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$4 - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$4", + new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$4", 'def', RegExp.$4); // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$5 - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$5", + new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$5", 'e', RegExp.$5); // 'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$6 - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$6", + new TestCase ( SECTION, "'abcdefghi'.match(/(a(b(c(d(e)f)g)h)i)/); RegExp.$6", '', RegExp.$6); var a_to_z = 'abcdefghijklmnopqrstuvwxyz'; @@ -84,40 +82,26 @@ // 'abcdefghijklmnopqrstuvwxyz'.match(/(a)b(c)d(e)f(g)h(i)j(k)l(m)n(o)p(q)r(s)t(u)v(w)x(y)z/); RegExp.$1 a_to_z.match(regexp1); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$1", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$1", 'a', RegExp.$1); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$2", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$2", 'c', RegExp.$2); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$3", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$3", 'e', RegExp.$3); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$4", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$4", 'g', RegExp.$4); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$5", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$5", 'i', RegExp.$5); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$6", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$6", 'k', RegExp.$6); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$7", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$7", 'm', RegExp.$7); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$8", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$8", 'o', RegExp.$8); - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$9", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$9", 'q', RegExp.$9); /* - testcases[count++] = new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$10", + new TestCase ( SECTION, "'" + a_to_z + "'.match((a)b(c)....(y)z); RegExp.$10", 's', RegExp.$10); */ - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_input.js b/mozilla/js/tests/js1_2/regexp/RegExp_input.js index 3be3d35a40a..44eddd194ed 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_input.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_input.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,68 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_input.js - Description: 'Tests RegExps input property' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: RegExp_input.js + Description: 'Tests RegExps input property' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: input'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: input'; - writeHeaderToLog('Executing script: RegExp_input.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_input.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +RegExp.input = "abcd12357efg"; - RegExp.input = "abcd12357efg"; +// RegExp.input = "abcd12357efg"; RegExp.input +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; RegExp.input", + "abcd12357efg", RegExp.input); - // RegExp.input = "abcd12357efg"; RegExp.input - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; RegExp.input", - "abcd12357efg", RegExp.input); +// RegExp.input = "abcd12357efg"; /\d+/.exec('2345') +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.exec('2345')", + String(["2345"]), String(/\d+/.exec('2345'))); - // RegExp.input = "abcd12357efg"; /\d+/.exec('2345') - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.exec('2345')", - String(["2345"]), String(/\d+/.exec('2345'))); +// RegExp.input = "abcd12357efg"; /\d+/.exec() +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.exec()", + String(["12357"]), String(/\d+/.exec())); - // RegExp.input = "abcd12357efg"; /\d+/.exec() - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.exec()", - String(["12357"]), String(/\d+/.exec())); +// RegExp.input = "abcd12357efg"; /[h-z]+/.exec() +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /[h-z]+/.exec()", + null, /[h-z]+/.exec()); - // RegExp.input = "abcd12357efg"; /[h-z]+/.exec() - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /[h-z]+/.exec()", - null, /[h-z]+/.exec()); +// RegExp.input = "abcd12357efg"; /\d+/.test('2345') +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.test('2345')", + true, /\d+/.test('2345')); - // RegExp.input = "abcd12357efg"; /\d+/.test('2345') - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.test('2345')", - true, /\d+/.test('2345')); +// RegExp.input = "abcd12357efg"; /\d+/.test() +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.test()", + true, /\d+/.test()); - // RegExp.input = "abcd12357efg"; /\d+/.test() - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /\\d+/.test()", - true, /\d+/.test()); +// RegExp.input = "abcd12357efg"; (new RegExp('d+')).test() +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; (new RegExp('d+')).test()", + true, (new RegExp('d+')).test()); - // RegExp.input = "abcd12357efg"; (new RegExp('d+')).test() - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; (new RegExp('d+')).test()", - true, (new RegExp('d+')).test()); +// RegExp.input = "abcd12357efg"; /[h-z]+/.test() +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /[h-z]+/.test()", + false, /[h-z]+/.test()); - // RegExp.input = "abcd12357efg"; /[h-z]+/.test() - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; /[h-z]+/.test()", - false, /[h-z]+/.test()); +// RegExp.input = "abcd12357efg"; (new RegExp('[h-z]+')).test() +RegExp.input = "abcd12357efg"; +new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; (new RegExp('[h-z]+')).test()", + false, (new RegExp('[h-z]+')).test()); - // RegExp.input = "abcd12357efg"; (new RegExp('[h-z]+')).test() - RegExp.input = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp.input = 'abcd12357efg'; (new RegExp('[h-z]+')).test()", - false, (new RegExp('[h-z]+')).test()); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_input_as_array.js b/mozilla/js/tests/js1_2/regexp/RegExp_input_as_array.js index d53be5a3e69..68115a594af 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_input_as_array.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_input_as_array.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,84 +35,71 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_input_as_array.js - Description: 'Tests RegExps $_ property (same tests as RegExp_input.js but using $_)' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: RegExp_input_as_array.js + Description: 'Tests RegExps $_ property (same tests as RegExp_input.js but using $_)' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: input'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: input'; - writeHeaderToLog('Executing script: RegExp_input.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_input.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var count = 0; +var testcases = new Array(); - RegExp['$_'] = "abcd12357efg"; +RegExp['$_'] = "abcd12357efg"; - // RegExp['$_'] = "abcd12357efg"; RegExp['$_'] - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; RegExp['$_']", - "abcd12357efg", RegExp['$_']); +// RegExp['$_'] = "abcd12357efg"; RegExp['$_'] +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; RegExp['$_']", + "abcd12357efg", RegExp['$_']); - // RegExp['$_'] = "abcd12357efg"; /\d+/.exec('2345') - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.exec('2345')", - String(["2345"]), String(/\d+/.exec('2345'))); +// RegExp['$_'] = "abcd12357efg"; /\d+/.exec('2345') +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.exec('2345')", + String(["2345"]), String(/\d+/.exec('2345'))); - // RegExp['$_'] = "abcd12357efg"; /\d+/.exec() - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.exec()", - String(["12357"]), String(/\d+/.exec())); +// RegExp['$_'] = "abcd12357efg"; /\d+/.exec() +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.exec()", + String(["12357"]), String(/\d+/.exec())); - // RegExp['$_'] = "abcd12357efg"; /[h-z]+/.exec() - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /[h-z]+/.exec()", - null, /[h-z]+/.exec()); +// RegExp['$_'] = "abcd12357efg"; /[h-z]+/.exec() +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /[h-z]+/.exec()", + null, /[h-z]+/.exec()); - // RegExp['$_'] = "abcd12357efg"; /\d+/.test('2345') - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.test('2345')", - true, /\d+/.test('2345')); +// RegExp['$_'] = "abcd12357efg"; /\d+/.test('2345') +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.test('2345')", + true, /\d+/.test('2345')); - // RegExp['$_'] = "abcd12357efg"; /\d+/.test() - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.test()", - true, /\d+/.test()); +// RegExp['$_'] = "abcd12357efg"; /\d+/.test() +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /\\d+/.test()", + true, /\d+/.test()); - // RegExp['$_'] = "abcd12357efg"; /[h-z]+/.test() - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /[h-z]+/.test()", - false, /[h-z]+/.test()); +// RegExp['$_'] = "abcd12357efg"; /[h-z]+/.test() +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; /[h-z]+/.test()", + false, /[h-z]+/.test()); - // RegExp['$_'] = "abcd12357efg"; (new RegExp('\d+')).test() - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; (new RegExp('\d+')).test()", - true, (new RegExp('\d+')).test()); +// RegExp['$_'] = "abcd12357efg"; (new RegExp('\d+')).test() +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; (new RegExp('\d+')).test()", + true, (new RegExp('\d+')).test()); - // RegExp['$_'] = "abcd12357efg"; (new RegExp('[h-z]+')).test() - RegExp['$_'] = "abcd12357efg"; - testcases[count++] = new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; (new RegExp('[h-z]+')).test()", - false, (new RegExp('[h-z]+')).test()); +// RegExp['$_'] = "abcd12357efg"; (new RegExp('[h-z]+')).test() +RegExp['$_'] = "abcd12357efg"; +new TestCase ( SECTION, "RegExp['$_'] = 'abcd12357efg'; (new RegExp('[h-z]+')).test()", + false, (new RegExp('[h-z]+')).test()); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_lastIndex.js b/mozilla/js/tests/js1_2/regexp/RegExp_lastIndex.js index 906fde38e5e..137ceb51d89 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_lastIndex.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_lastIndex.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,49 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_lastIndex.js - Description: 'Tests RegExps lastIndex property' - Author: Nick Lerissa - Date: March 17, 1998 +/** + Filename: RegExp_lastIndex.js + Description: 'Tests RegExps lastIndex property' + + Author: Nick Lerissa + Date: March 17, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: lastIndex'; - var BUGNUMBER="123802"; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: lastIndex'; +var BUGNUMBER="123802"; - writeHeaderToLog('Executing script: RegExp_lastIndex.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_lastIndex.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// re=/x./g; re.lastIndex=4; re.exec('xyabcdxa'); +re=/x./g; +re.lastIndex=4; +new TestCase ( SECTION, "re=/x./g; re.lastIndex=4; re.exec('xyabcdxa')", + '["xa"]', String(re.exec('xyabcdxa'))); - // re=/x./g; re.lastIndex=4; re.exec('xyabcdxa'); - re=/x./g; - re.lastIndex=4; - testcases[count++] = new TestCase ( SECTION, "re=/x./g; re.lastIndex=4; re.exec('xyabcdxa')", - '["xa"]', String(re.exec('xyabcdxa'))); +// re.lastIndex +new TestCase ( SECTION, "re.lastIndex", + 8, re.lastIndex); - // re.lastIndex - testcases[count++] = new TestCase ( SECTION, "re.lastIndex", - 8, re.lastIndex); +// re.exec('xyabcdef'); +new TestCase ( SECTION, "re.exec('xyabcdef')", + null, re.exec('xyabcdef')); - // re.exec('xyabcdef'); - testcases[count++] = new TestCase ( SECTION, "re.exec('xyabcdef')", - null, re.exec('xyabcdef')); +// re.lastIndex +new TestCase ( SECTION, "re.lastIndex", + 0, re.lastIndex); - // re.lastIndex - testcases[count++] = new TestCase ( SECTION, "re.lastIndex", - 0, re.lastIndex); +// re.exec('xyabcdef'); +new TestCase ( SECTION, "re.exec('xyabcdef')", + '["xy"]', String(re.exec('xyabcdef'))); - // re.exec('xyabcdef'); - testcases[count++] = new TestCase ( SECTION, "re.exec('xyabcdef')", - '["xy"]', String(re.exec('xyabcdef'))); +// re.lastIndex=30; re.exec('123xaxbxc456'); +re.lastIndex=30; +new TestCase ( SECTION, "re.lastIndex=30; re.exec('123xaxbxc456')", + null, re.exec('123xaxbxc456')); - // re.lastIndex=30; re.exec('123xaxbxc456'); - re.lastIndex=30; - testcases[count++] = new TestCase ( SECTION, "re.lastIndex=30; re.exec('123xaxbxc456')", - null, re.exec('123xaxbxc456')); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_lastMatch.js b/mozilla/js/tests/js1_2/regexp/RegExp_lastMatch.js index a3cd71cec0b..44636d50225 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_lastMatch.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_lastMatch.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,67 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_lastMatch.js - Description: 'Tests RegExps lastMatch property' - Author: Nick Lerissa - Date: March 12, 1998 +/** + Filename: RegExp_lastMatch.js + Description: 'Tests RegExps lastMatch property' + + Author: Nick Lerissa + Date: March 12, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: lastMatch'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: lastMatch'; - writeHeaderToLog('Executing script: RegExp_lastMatch.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_lastMatch.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'foo'.match(/foo/); RegExp.lastMatch - 'foo'.match(/foo/); - testcases[count++] = new TestCase ( SECTION, "'foo'.match(/foo/); RegExp.lastMatch", - 'foo', RegExp.lastMatch); +// 'foo'.match(/foo/); RegExp.lastMatch +'foo'.match(/foo/); +new TestCase ( SECTION, "'foo'.match(/foo/); RegExp.lastMatch", + 'foo', RegExp.lastMatch); - // 'foo'.match(new RegExp('foo')); RegExp.lastMatch - 'foo'.match(new RegExp('foo')); - testcases[count++] = new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp.lastMatch", - 'foo', RegExp.lastMatch); +// 'foo'.match(new RegExp('foo')); RegExp.lastMatch +'foo'.match(new RegExp('foo')); +new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp.lastMatch", + 'foo', RegExp.lastMatch); - // 'xxx'.match(/bar/); RegExp.lastMatch - 'xxx'.match(/bar/); - testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp.lastMatch", - 'foo', RegExp.lastMatch); +// 'xxx'.match(/bar/); RegExp.lastMatch +'xxx'.match(/bar/); +new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp.lastMatch", + 'foo', RegExp.lastMatch); - // 'xxx'.match(/$/); RegExp.lastMatch - 'xxx'.match(/$/); - testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/$/); RegExp.lastMatch", - '', RegExp.lastMatch); +// 'xxx'.match(/$/); RegExp.lastMatch +'xxx'.match(/$/); +new TestCase ( SECTION, "'xxx'.match(/$/); RegExp.lastMatch", + '', RegExp.lastMatch); - // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch - 'abcdefg'.match(/^..(cd)[a-z]+/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch", - 'abcdefg', RegExp.lastMatch); +// 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch +'abcdefg'.match(/^..(cd)[a-z]+/); +new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp.lastMatch", + 'abcdefg', RegExp.lastMatch); - // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp.lastMatch - 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); - testcases[count++] = new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp.lastMatch", - 'abcdefgabcdefg', RegExp.lastMatch); +// 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp.lastMatch +'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); +new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp.lastMatch", + 'abcdefgabcdefg', RegExp.lastMatch); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_lastMatch_as_array.js b/mozilla/js/tests/js1_2/regexp/RegExp_lastMatch_as_array.js index 46d8f36eb11..c408ea97c6b 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_lastMatch_as_array.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_lastMatch_as_array.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,67 +35,52 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_lastMatch_as_array.js - Description: 'Tests RegExps $& property (same tests as RegExp_lastMatch.js but using $&)' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: RegExp_lastMatch_as_array.js + Description: 'Tests RegExps $& property (same tests as RegExp_lastMatch.js but using $&)' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: $&'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: $&'; - writeHeaderToLog('Executing script: RegExp_lastMatch_as_array.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_lastMatch_as_array.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'foo'.match(/foo/); RegExp['$&'] - 'foo'.match(/foo/); - testcases[count++] = new TestCase ( SECTION, "'foo'.match(/foo/); RegExp['$&']", - 'foo', RegExp['$&']); +// 'foo'.match(/foo/); RegExp['$&'] +'foo'.match(/foo/); +new TestCase ( SECTION, "'foo'.match(/foo/); RegExp['$&']", + 'foo', RegExp['$&']); - // 'foo'.match(new RegExp('foo')); RegExp['$&'] - 'foo'.match(new RegExp('foo')); - testcases[count++] = new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp['$&']", - 'foo', RegExp['$&']); +// 'foo'.match(new RegExp('foo')); RegExp['$&'] +'foo'.match(new RegExp('foo')); +new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp['$&']", + 'foo', RegExp['$&']); - // 'xxx'.match(/bar/); RegExp['$&'] - 'xxx'.match(/bar/); - testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp['$&']", - 'foo', RegExp['$&']); +// 'xxx'.match(/bar/); RegExp['$&'] +'xxx'.match(/bar/); +new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp['$&']", + 'foo', RegExp['$&']); - // 'xxx'.match(/$/); RegExp['$&'] - 'xxx'.match(/$/); - testcases[count++] = new TestCase ( SECTION, "'xxx'.match(/$/); RegExp['$&']", - '', RegExp['$&']); +// 'xxx'.match(/$/); RegExp['$&'] +'xxx'.match(/$/); +new TestCase ( SECTION, "'xxx'.match(/$/); RegExp['$&']", + '', RegExp['$&']); - // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&'] - 'abcdefg'.match(/^..(cd)[a-z]+/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']", - 'abcdefg', RegExp['$&']); +// 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&'] +'abcdefg'.match(/^..(cd)[a-z]+/); +new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']", + 'abcdefg', RegExp['$&']); - // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp['$&'] - 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); - testcases[count++] = new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp['$&']", - 'abcdefgabcdefg', RegExp['$&']); +// 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp['$&'] +'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); +new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp['$&']", + 'abcdefgabcdefg', RegExp['$&']); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_lastParen.js b/mozilla/js/tests/js1_2/regexp/RegExp_lastParen.js index 1edaf16a799..312f5b88d92 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_lastParen.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_lastParen.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,82 +35,66 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_lastParen.js - Description: 'Tests RegExps lastParen property' - Author: Nick Lerissa - Date: March 12, 1998 +/** + Filename: RegExp_lastParen.js + Description: 'Tests RegExps lastParen property' + + Author: Nick Lerissa + Date: March 12, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: lastParen'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: lastParen'; - writeHeaderToLog('Executing script: RegExp_lastParen.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_lastParen.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abcd'.match(/(abc)d/); RegExp.lastParen +'abcd'.match(/(abc)d/); +new TestCase ( SECTION, "'abcd'.match(/(abc)d/); RegExp.lastParen", + 'abc', RegExp.lastParen); - // 'abcd'.match(/(abc)d/); RegExp.lastParen - 'abcd'.match(/(abc)d/); - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(abc)d/); RegExp.lastParen", - 'abc', RegExp.lastParen); +// 'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen +'abcd'.match(new RegExp('(abc)d')); +new TestCase ( SECTION, "'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen", + 'abc', RegExp.lastParen); - // 'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen - 'abcd'.match(new RegExp('(abc)d')); - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('(abc)d')); RegExp.lastParen", - 'abc', RegExp.lastParen); +// 'abcd'.match(/(bcd)e/); RegExp.lastParen +'abcd'.match(/(bcd)e/); +new TestCase ( SECTION, "'abcd'.match(/(bcd)e/); RegExp.lastParen", + 'abc', RegExp.lastParen); - // 'abcd'.match(/(bcd)e/); RegExp.lastParen - 'abcd'.match(/(bcd)e/); - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(bcd)e/); RegExp.lastParen", - 'abc', RegExp.lastParen); +// 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen +'abcdefg'.match(/(a(b(c(d)e)f)g)/); +new TestCase ( SECTION, "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen", + 'd', RegExp.lastParen); - // 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen - 'abcdefg'.match(/(a(b(c(d)e)f)g)/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp.lastParen", - 'd', RegExp.lastParen); +// 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen +'abcdefg'.match(/(a(b)c)(d(e)f)/); +new TestCase ( SECTION, "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen", + 'e', RegExp.lastParen); - // 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen - 'abcdefg'.match(/(a(b)c)(d(e)f)/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp.lastParen", - 'e', RegExp.lastParen); +// 'abcdefg'.match(/(^)abc/); RegExp.lastParen +'abcdefg'.match(/(^)abc/); +new TestCase ( SECTION, "'abcdefg'.match(/(^)abc/); RegExp.lastParen", + '', RegExp.lastParen); - // 'abcdefg'.match(/(^)abc/); RegExp.lastParen - 'abcdefg'.match(/(^)abc/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^)abc/); RegExp.lastParen", - '', RegExp.lastParen); +// 'abcdefg'.match(/(^a)bc/); RegExp.lastParen +'abcdefg'.match(/(^a)bc/); +new TestCase ( SECTION, "'abcdefg'.match(/(^a)bc/); RegExp.lastParen", + 'a', RegExp.lastParen); - // 'abcdefg'.match(/(^a)bc/); RegExp.lastParen - 'abcdefg'.match(/(^a)bc/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^a)bc/); RegExp.lastParen", - 'a', RegExp.lastParen); +// 'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen +'abcdefg'.match(new RegExp('(^a)bc')); +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen", + 'a', RegExp.lastParen); - // 'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen - 'abcdefg'.match(new RegExp('(^a)bc')); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(^a)bc')); RegExp.lastParen", - 'a', RegExp.lastParen); +// 'abcdefg'.match(/bc/); RegExp.lastParen +'abcdefg'.match(/bc/); +new TestCase ( SECTION, "'abcdefg'.match(/bc/); RegExp.lastParen", + '', RegExp.lastParen); - // 'abcdefg'.match(/bc/); RegExp.lastParen - 'abcdefg'.match(/bc/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/bc/); RegExp.lastParen", - '', RegExp.lastParen); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_lastParen_as_array.js b/mozilla/js/tests/js1_2/regexp/RegExp_lastParen_as_array.js index 7a9ffdbf0ee..36938682990 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_lastParen_as_array.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_lastParen_as_array.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,82 +35,66 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_lastParen_as_array.js - Description: 'Tests RegExps $+ property (same tests as RegExp_lastParen.js but using $+)' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: RegExp_lastParen_as_array.js + Description: 'Tests RegExps $+ property (same tests as RegExp_lastParen.js but using $+)' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: $+'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: $+'; - writeHeaderToLog('Executing script: RegExp_lastParen_as_array.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_lastParen_as_array.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abcd'.match(/(abc)d/); RegExp['$+'] +'abcd'.match(/(abc)d/); +new TestCase ( SECTION, "'abcd'.match(/(abc)d/); RegExp['$+']", + 'abc', RegExp['$+']); - // 'abcd'.match(/(abc)d/); RegExp['$+'] - 'abcd'.match(/(abc)d/); - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(abc)d/); RegExp['$+']", - 'abc', RegExp['$+']); +// 'abcd'.match(/(bcd)e/); RegExp['$+'] +'abcd'.match(/(bcd)e/); +new TestCase ( SECTION, "'abcd'.match(/(bcd)e/); RegExp['$+']", + 'abc', RegExp['$+']); - // 'abcd'.match(/(bcd)e/); RegExp['$+'] - 'abcd'.match(/(bcd)e/); - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/(bcd)e/); RegExp['$+']", - 'abc', RegExp['$+']); +// 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp['$+'] +'abcdefg'.match(/(a(b(c(d)e)f)g)/); +new TestCase ( SECTION, "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp['$+']", + 'd', RegExp['$+']); - // 'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp['$+'] - 'abcdefg'.match(/(a(b(c(d)e)f)g)/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b(c(d)e)f)g)/); RegExp['$+']", - 'd', RegExp['$+']); +// 'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); RegExp['$+'] +'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); RegExp['$+']", + 'd', RegExp['$+']); - // 'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); RegExp['$+'] - 'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(a(b(c(d)e)f)g)')); RegExp['$+']", - 'd', RegExp['$+']); +// 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp['$+'] +'abcdefg'.match(/(a(b)c)(d(e)f)/); +new TestCase ( SECTION, "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp['$+']", + 'e', RegExp['$+']); - // 'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp['$+'] - 'abcdefg'.match(/(a(b)c)(d(e)f)/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(a(b)c)(d(e)f)/); RegExp['$+']", - 'e', RegExp['$+']); +// 'abcdefg'.match(/(^)abc/); RegExp['$+'] +'abcdefg'.match(/(^)abc/); +new TestCase ( SECTION, "'abcdefg'.match(/(^)abc/); RegExp['$+']", + '', RegExp['$+']); - // 'abcdefg'.match(/(^)abc/); RegExp['$+'] - 'abcdefg'.match(/(^)abc/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^)abc/); RegExp['$+']", - '', RegExp['$+']); +// 'abcdefg'.match(/(^a)bc/); RegExp['$+'] +'abcdefg'.match(/(^a)bc/); +new TestCase ( SECTION, "'abcdefg'.match(/(^a)bc/); RegExp['$+']", + 'a', RegExp['$+']); - // 'abcdefg'.match(/(^a)bc/); RegExp['$+'] - 'abcdefg'.match(/(^a)bc/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/(^a)bc/); RegExp['$+']", - 'a', RegExp['$+']); +// 'abcdefg'.match(new RegExp('(^a)bc')); RegExp['$+'] +'abcdefg'.match(new RegExp('(^a)bc')); +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(^a)bc')); RegExp['$+']", + 'a', RegExp['$+']); - // 'abcdefg'.match(new RegExp('(^a)bc')); RegExp['$+'] - 'abcdefg'.match(new RegExp('(^a)bc')); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(^a)bc')); RegExp['$+']", - 'a', RegExp['$+']); +// 'abcdefg'.match(/bc/); RegExp['$+'] +'abcdefg'.match(/bc/); +new TestCase ( SECTION, "'abcdefg'.match(/bc/); RegExp['$+']", + '', RegExp['$+']); - // 'abcdefg'.match(/bc/); RegExp['$+'] - 'abcdefg'.match(/bc/); - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/bc/); RegExp['$+']", - '', RegExp['$+']); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_leftContext.js b/mozilla/js/tests/js1_2/regexp/RegExp_leftContext.js index 2047f4e0f2a..18879abaf1c 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_leftContext.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_leftContext.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_leftContext.js - Description: 'Tests RegExps leftContext property' - Author: Nick Lerissa - Date: March 12, 1998 +/** + Filename: RegExp_leftContext.js + Description: 'Tests RegExps leftContext property' + + Author: Nick Lerissa + Date: March 12, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: leftContext'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: leftContext'; - writeHeaderToLog('Executing script: RegExp_leftContext.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_leftContext.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abc123xyz'.match(/123/); RegExp.leftContext +'abc123xyz'.match(/123/); +new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp.leftContext", + 'abc', RegExp.leftContext); - // 'abc123xyz'.match(/123/); RegExp.leftContext - 'abc123xyz'.match(/123/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp.leftContext", - 'abc', RegExp.leftContext); +// 'abc123xyz'.match(/456/); RegExp.leftContext +'abc123xyz'.match(/456/); +new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp.leftContext", + 'abc', RegExp.leftContext); - // 'abc123xyz'.match(/456/); RegExp.leftContext - 'abc123xyz'.match(/456/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp.leftContext", - 'abc', RegExp.leftContext); +// 'abc123xyz'.match(/abc123xyz/); RegExp.leftContext +'abc123xyz'.match(/abc123xyz/); +new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp.leftContext", + '', RegExp.leftContext); - // 'abc123xyz'.match(/abc123xyz/); RegExp.leftContext - 'abc123xyz'.match(/abc123xyz/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp.leftContext", - '', RegExp.leftContext); +// 'xxxx'.match(/$/); RegExp.leftContext +'xxxx'.match(/$/); +new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp.leftContext", + 'xxxx', RegExp.leftContext); - // 'xxxx'.match(/$/); RegExp.leftContext - 'xxxx'.match(/$/); - testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp.leftContext", - 'xxxx', RegExp.leftContext); +// 'test'.match(/^/); RegExp.leftContext +'test'.match(/^/); +new TestCase ( SECTION, "'test'.match(/^/); RegExp.leftContext", + '', RegExp.leftContext); - // 'test'.match(/^/); RegExp.leftContext - 'test'.match(/^/); - testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp.leftContext", - '', RegExp.leftContext); +// 'xxxx'.match(new RegExp('$')); RegExp.leftContext +'xxxx'.match(new RegExp('$')); +new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp.leftContext", + 'xxxx', RegExp.leftContext); - // 'xxxx'.match(new RegExp('$')); RegExp.leftContext - 'xxxx'.match(new RegExp('$')); - testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp.leftContext", - 'xxxx', RegExp.leftContext); +// 'test'.match(new RegExp('^')); RegExp.leftContext +'test'.match(new RegExp('^')); +new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp.leftContext", + '', RegExp.leftContext); - // 'test'.match(new RegExp('^')); RegExp.leftContext - 'test'.match(new RegExp('^')); - testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp.leftContext", - '', RegExp.leftContext); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_leftContext_as_array.js b/mozilla/js/tests/js1_2/regexp/RegExp_leftContext_as_array.js index 11e8e56cd03..0b017d1a2d6 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_leftContext_as_array.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_leftContext_as_array.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_leftContext_as_array.js - Description: 'Tests RegExps leftContext property (same tests as RegExp_leftContext.js but using $`)' - Author: Nick Lerissa - Date: March 12, 1998 +/** + Filename: RegExp_leftContext_as_array.js + Description: 'Tests RegExps leftContext property (same tests as RegExp_leftContext.js but using $`)' + + Author: Nick Lerissa + Date: March 12, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: $`'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: $`'; - writeHeaderToLog('Executing script: RegExp_leftContext_as_array.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_leftContext_as_array.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abc123xyz'.match(/123/); RegExp['$`'] +'abc123xyz'.match(/123/); +new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp['$`']", + 'abc', RegExp['$`']); - // 'abc123xyz'.match(/123/); RegExp['$`'] - 'abc123xyz'.match(/123/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp['$`']", - 'abc', RegExp['$`']); +// 'abc123xyz'.match(/456/); RegExp['$`'] +'abc123xyz'.match(/456/); +new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp['$`']", + 'abc', RegExp['$`']); - // 'abc123xyz'.match(/456/); RegExp['$`'] - 'abc123xyz'.match(/456/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp['$`']", - 'abc', RegExp['$`']); +// 'abc123xyz'.match(/abc123xyz/); RegExp['$`'] +'abc123xyz'.match(/abc123xyz/); +new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp['$`']", + '', RegExp['$`']); - // 'abc123xyz'.match(/abc123xyz/); RegExp['$`'] - 'abc123xyz'.match(/abc123xyz/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp['$`']", - '', RegExp['$`']); +// 'xxxx'.match(/$/); RegExp['$`'] +'xxxx'.match(/$/); +new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp['$`']", + 'xxxx', RegExp['$`']); - // 'xxxx'.match(/$/); RegExp['$`'] - 'xxxx'.match(/$/); - testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp['$`']", - 'xxxx', RegExp['$`']); +// 'test'.match(/^/); RegExp['$`'] +'test'.match(/^/); +new TestCase ( SECTION, "'test'.match(/^/); RegExp['$`']", + '', RegExp['$`']); - // 'test'.match(/^/); RegExp['$`'] - 'test'.match(/^/); - testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp['$`']", - '', RegExp['$`']); +// 'xxxx'.match(new RegExp('$')); RegExp['$`'] +'xxxx'.match(new RegExp('$')); +new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp['$`']", + 'xxxx', RegExp['$`']); - // 'xxxx'.match(new RegExp('$')); RegExp['$`'] - 'xxxx'.match(new RegExp('$')); - testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp['$`']", - 'xxxx', RegExp['$`']); +// 'test'.match(new RegExp('^')); RegExp['$`'] +'test'.match(new RegExp('^')); +new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp['$`']", + '', RegExp['$`']); - // 'test'.match(new RegExp('^')); RegExp['$`'] - 'test'.match(new RegExp('^')); - testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp['$`']", - '', RegExp['$`']); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_multiline.js b/mozilla/js/tests/js1_2/regexp/RegExp_multiline.js index 519da21443b..7ebd8a91c4d 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_multiline.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_multiline.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,111 +35,95 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_multiline.js - Description: 'Tests RegExps multiline property' - Author: Nick Lerissa - Date: March 12, 1998 +/** + Filename: RegExp_multiline.js + Description: 'Tests RegExps multiline property' + + Author: Nick Lerissa + Date: March 12, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: multiline'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: multiline'; - writeHeaderToLog('Executing script: RegExp_multiline.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_multiline.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// First we do a series of tests with RegExp.multiline set to false (default value) +// Following this we do the same tests with RegExp.multiline set true(**). +// RegExp.multiline +new TestCase ( SECTION, "RegExp.multiline", + false, RegExp.multiline); - // First we do a series of tests with RegExp.multiline set to false (default value) - // Following this we do the same tests with RegExp.multiline set true(**). - // RegExp.multiline - testcases[count++] = new TestCase ( SECTION, "RegExp.multiline", - false, RegExp.multiline); +// (multiline == false) '123\n456'.match(/^4../) +new TestCase ( SECTION, "(multiline == false) '123\\n456'.match(/^4../)", + null, '123\n456'.match(/^4../)); - // (multiline == false) '123\n456'.match(/^4../) - testcases[count++] = new TestCase ( SECTION, "(multiline == false) '123\\n456'.match(/^4../)", - null, '123\n456'.match(/^4../)); +// (multiline == false) 'a11\na22\na23\na24'.match(/^a../g) +new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(/^a../g)", + String(['a11']), String('a11\na22\na23\na24'.match(/^a../g))); - // (multiline == false) 'a11\na22\na23\na24'.match(/^a../g) - testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(/^a../g)", - String(['a11']), String('a11\na22\na23\na24'.match(/^a../g))); +// (multiline == false) 'a11\na22'.match(/^.+^./) +new TestCase ( SECTION, "(multiline == false) 'a11\na22'.match(/^.+^./)", + null, 'a11\na22'.match(/^.+^./)); - // (multiline == false) 'a11\na22'.match(/^.+^./) - testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\na22'.match(/^.+^./)", - null, 'a11\na22'.match(/^.+^./)); +// (multiline == false) '123\n456'.match(/.3$/) +new TestCase ( SECTION, "(multiline == false) '123\\n456'.match(/.3$/)", + null, '123\n456'.match(/.3$/)); - // (multiline == false) '123\n456'.match(/.3$/) - testcases[count++] = new TestCase ( SECTION, "(multiline == false) '123\\n456'.match(/.3$/)", - null, '123\n456'.match(/.3$/)); +// (multiline == false) 'a11\na22\na23\na24'.match(/a..$/g) +new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)", + String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g))); - // (multiline == false) 'a11\na22\na23\na24'.match(/a..$/g) - testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)", - String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g))); +// (multiline == false) 'abc\ndef'.match(/c$...$/) +new TestCase ( SECTION, "(multiline == false) 'abc\ndef'.match(/c$...$/)", + null, 'abc\ndef'.match(/c$...$/)); - // (multiline == false) 'abc\ndef'.match(/c$...$/) - testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'abc\ndef'.match(/c$...$/)", - null, 'abc\ndef'.match(/c$...$/)); +// (multiline == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) +new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", + String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); - // (multiline == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) - testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", - String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); +// (multiline == false) 'abc\ndef'.match(new RegExp('c$...$')) +new TestCase ( SECTION, "(multiline == false) 'abc\ndef'.match(new RegExp('c$...$'))", + null, 'abc\ndef'.match(new RegExp('c$...$'))); - // (multiline == false) 'abc\ndef'.match(new RegExp('c$...$')) - testcases[count++] = new TestCase ( SECTION, "(multiline == false) 'abc\ndef'.match(new RegExp('c$...$'))", - null, 'abc\ndef'.match(new RegExp('c$...$'))); +// **Now we do the tests with RegExp.multiline set to true +// RegExp.multiline = true; RegExp.multiline +RegExp.multiline = true; +new TestCase ( SECTION, "RegExp.multiline = true; RegExp.multiline", + true, RegExp.multiline); - // **Now we do the tests with RegExp.multiline set to true - // RegExp.multiline = true; RegExp.multiline - RegExp.multiline = true; - testcases[count++] = new TestCase ( SECTION, "RegExp.multiline = true; RegExp.multiline", - true, RegExp.multiline); +// (multiline == true) '123\n456'.match(/^4../) +new TestCase ( SECTION, "(multiline == true) '123\\n456'.match(/^4../)", + String(['456']), String('123\n456'.match(/^4../))); - // (multiline == true) '123\n456'.match(/^4../) - testcases[count++] = new TestCase ( SECTION, "(multiline == true) '123\\n456'.match(/^4../)", - String(['456']), String('123\n456'.match(/^4../))); +// (multiline == true) 'a11\na22\na23\na24'.match(/^a../g) +new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(/^a../g)", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g))); - // (multiline == true) 'a11\na22\na23\na24'.match(/^a../g) - testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(/^a../g)", - String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g))); +// (multiline == true) 'a11\na22'.match(/^.+^./) +//new TestCase ( SECTION, "(multiline == true) 'a11\na22'.match(/^.+^./)", +// String(['a11\na']), String('a11\na22'.match(/^.+^./))); - // (multiline == true) 'a11\na22'.match(/^.+^./) - //testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\na22'.match(/^.+^./)", - // String(['a11\na']), String('a11\na22'.match(/^.+^./))); +// (multiline == true) '123\n456'.match(/.3$/) +new TestCase ( SECTION, "(multiline == true) '123\\n456'.match(/.3$/)", + String(['23']), String('123\n456'.match(/.3$/))); - // (multiline == true) '123\n456'.match(/.3$/) - testcases[count++] = new TestCase ( SECTION, "(multiline == true) '123\\n456'.match(/.3$/)", - String(['23']), String('123\n456'.match(/.3$/))); +// (multiline == true) 'a11\na22\na23\na24'.match(/a..$/g) +new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g))); - // (multiline == true) 'a11\na22\na23\na24'.match(/a..$/g) - testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)", - String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g))); +// (multiline == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) +new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); - // (multiline == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) - testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", - String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); +// (multiline == true) 'abc\ndef'.match(/c$....$/) +//new TestCase ( SECTION, "(multiline == true) 'abc\ndef'.match(/c$.+$/)", +// 'c\ndef', String('abc\ndef'.match(/c$.+$/))); - // (multiline == true) 'abc\ndef'.match(/c$....$/) - //testcases[count++] = new TestCase ( SECTION, "(multiline == true) 'abc\ndef'.match(/c$.+$/)", - // 'c\ndef', String('abc\ndef'.match(/c$.+$/))); +RegExp.multiline = false; - RegExp.multiline = false; - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_multiline_as_array.js b/mozilla/js/tests/js1_2/regexp/RegExp_multiline_as_array.js index 04ce6a5b480..4eb31fc1f77 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_multiline_as_array.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_multiline_as_array.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,111 +35,96 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_multiline_as_array.js - Description: 'Tests RegExps $* property (same tests as RegExp_multiline.js but using $*)' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: RegExp_multiline_as_array.js + Description: 'Tests RegExps $* property (same tests as RegExp_multiline.js but using $*)' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: $*'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: $*'; - writeHeaderToLog('Executing script: RegExp_multiline_as_array.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_multiline_as_array.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // First we do a series of tests with RegExp['$*'] set to false (default value) - // Following this we do the same tests with RegExp['$*'] set true(**). - // RegExp['$*'] - testcases[count++] = new TestCase ( SECTION, "RegExp['$*']", - false, RegExp['$*']); +// First we do a series of tests with RegExp['$*'] set to false (default value) +// Following this we do the same tests with RegExp['$*'] set true(**). +// RegExp['$*'] +new TestCase ( SECTION, "RegExp['$*']", + false, RegExp['$*']); - // (['$*'] == false) '123\n456'.match(/^4../) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/^4../)", - null, '123\n456'.match(/^4../)); +// (['$*'] == false) '123\n456'.match(/^4../) +new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/^4../)", + null, '123\n456'.match(/^4../)); - // (['$*'] == false) 'a11\na22\na23\na24'.match(/^a../g) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/^a../g)", - String(['a11']), String('a11\na22\na23\na24'.match(/^a../g))); +// (['$*'] == false) 'a11\na22\na23\na24'.match(/^a../g) +new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/^a../g)", + String(['a11']), String('a11\na22\na23\na24'.match(/^a../g))); - // (['$*'] == false) 'a11\na22'.match(/^.+^./) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\na22'.match(/^.+^./)", - null, 'a11\na22'.match(/^.+^./)); +// (['$*'] == false) 'a11\na22'.match(/^.+^./) +new TestCase ( SECTION, "(['$*'] == false) 'a11\na22'.match(/^.+^./)", + null, 'a11\na22'.match(/^.+^./)); - // (['$*'] == false) '123\n456'.match(/.3$/) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/.3$/)", - null, '123\n456'.match(/.3$/)); +// (['$*'] == false) '123\n456'.match(/.3$/) +new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/.3$/)", + null, '123\n456'.match(/.3$/)); - // (['$*'] == false) 'a11\na22\na23\na24'.match(/a..$/g) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)", - String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g))); +// (['$*'] == false) 'a11\na22\na23\na24'.match(/a..$/g) +new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)", + String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g))); - // (['$*'] == false) 'abc\ndef'.match(/c$...$/) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(/c$...$/)", - null, 'abc\ndef'.match(/c$...$/)); +// (['$*'] == false) 'abc\ndef'.match(/c$...$/) +new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(/c$...$/)", + null, 'abc\ndef'.match(/c$...$/)); - // (['$*'] == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", - String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); +// (['$*'] == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) +new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", + String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); - // (['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$')) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$'))", - null, 'abc\ndef'.match(new RegExp('c$...$'))); +// (['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$')) +new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$'))", + null, 'abc\ndef'.match(new RegExp('c$...$'))); - // **Now we do the tests with RegExp['$*'] set to true - // RegExp['$*'] = true; RegExp['$*'] - RegExp['$*'] = true; - testcases[count++] = new TestCase ( SECTION, "RegExp['$*'] = true; RegExp['$*']", - true, RegExp['$*']); +// **Now we do the tests with RegExp['$*'] set to true +// RegExp['$*'] = true; RegExp['$*'] +RegExp['$*'] = true; +new TestCase ( SECTION, "RegExp['$*'] = true; RegExp['$*']", + true, RegExp['$*']); - // (['$*'] == true) '123\n456'.match(/^4../) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/^4../)", - String(['456']), String('123\n456'.match(/^4../))); +// (['$*'] == true) '123\n456'.match(/^4../) +new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/^4../)", + String(['456']), String('123\n456'.match(/^4../))); - // (['$*'] == true) 'a11\na22\na23\na24'.match(/^a../g) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/^a../g)", - String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g))); +// (['$*'] == true) 'a11\na22\na23\na24'.match(/^a../g) +new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/^a../g)", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g))); - // (['$*'] == true) 'a11\na22'.match(/^.+^./) - //testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\na22'.match(/^.+^./)", - // String(['a11\na']), String('a11\na22'.match(/^.+^./))); +// (['$*'] == true) 'a11\na22'.match(/^.+^./) +//new TestCase ( SECTION, "(['$*'] == true) 'a11\na22'.match(/^.+^./)", +// String(['a11\na']), String('a11\na22'.match(/^.+^./))); - // (['$*'] == true) '123\n456'.match(/.3$/) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/.3$/)", - String(['23']), String('123\n456'.match(/.3$/))); +// (['$*'] == true) '123\n456'.match(/.3$/) +new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/.3$/)", + String(['23']), String('123\n456'.match(/.3$/))); - // (['$*'] == true) 'a11\na22\na23\na24'.match(/a..$/g) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)", - String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g))); +// (['$*'] == true) 'a11\na22\na23\na24'.match(/a..$/g) +new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g))); - // (['$*'] == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) - testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", - String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); +// (['$*'] == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) +new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", + String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); - // (['$*'] == true) 'abc\ndef'.match(/c$....$/) - //testcases[count++] = new TestCase ( SECTION, "(['$*'] == true) 'abc\ndef'.match(/c$.+$/)", - // 'c\ndef', String('abc\ndef'.match(/c$.+$/))); +// (['$*'] == true) 'abc\ndef'.match(/c$....$/) +//new TestCase ( SECTION, "(['$*'] == true) 'abc\ndef'.match(/c$.+$/)", +// 'c\ndef', String('abc\ndef'.match(/c$.+$/))); - RegExp['$*'] = false; +RegExp['$*'] = false; - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_object.js b/mozilla/js/tests/js1_2/regexp/RegExp_object.js index 0736f7cf197..10242cfbe05 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_object.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_object.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,70 +35,54 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_object.js - Description: 'Tests regular expressions creating RexExp Objects' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: RegExp_object.js + Description: 'Tests regular expressions creating RexExp Objects' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: object'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: object'; - writeHeaderToLog('Executing script: RegExp_object.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_object.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var SSN_pattern = new RegExp("\\d{3}-\\d{2}-\\d{4}"); - var SSN_pattern = new RegExp("\\d{3}-\\d{2}-\\d{4}"); +// testing SSN pattern +new TestCase ( SECTION, "'Test SSN is 123-34-4567'.match(SSN_pattern))", + String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern))); - // testing SSN pattern - testcases[count++] = new TestCase ( SECTION, "'Test SSN is 123-34-4567'.match(SSN_pattern))", - String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern))); +// testing SSN pattern +new TestCase ( SECTION, "'Test SSN is 123-34-4567'.match(SSN_pattern))", + String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern))); - // testing SSN pattern - testcases[count++] = new TestCase ( SECTION, "'Test SSN is 123-34-4567'.match(SSN_pattern))", - String(["123-34-4567"]), String('Test SSN is 123-34-4567'.match(SSN_pattern))); +var PHONE_pattern = new RegExp("\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})"); +// testing PHONE pattern +new TestCase ( SECTION, "'Our phone number is (408)345-2345.'.match(PHONE_pattern))", + String(["(408)345-2345","408","345","2345"]), String('Our phone number is (408)345-2345.'.match(PHONE_pattern))); - var PHONE_pattern = new RegExp("\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})"); - // testing PHONE pattern - testcases[count++] = new TestCase ( SECTION, "'Our phone number is (408)345-2345.'.match(PHONE_pattern))", - String(["(408)345-2345","408","345","2345"]), String('Our phone number is (408)345-2345.'.match(PHONE_pattern))); +// testing PHONE pattern +new TestCase ( SECTION, "'The phone number is 408-345-2345!'.match(PHONE_pattern))", + String(["408-345-2345","408","345","2345"]), String('The phone number is 408-345-2345!'.match(PHONE_pattern))); - // testing PHONE pattern - testcases[count++] = new TestCase ( SECTION, "'The phone number is 408-345-2345!'.match(PHONE_pattern))", - String(["408-345-2345","408","345","2345"]), String('The phone number is 408-345-2345!'.match(PHONE_pattern))); +// testing PHONE pattern +new TestCase ( SECTION, "String(PHONE_pattern.toString())", + "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/", String(PHONE_pattern.toString())); - // testing PHONE pattern - testcases[count++] = new TestCase ( SECTION, "String(PHONE_pattern.toString())", - "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/", String(PHONE_pattern.toString())); +// testing conversion to String +new TestCase ( SECTION, "PHONE_pattern + ' is the string'", + "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/ is the string",PHONE_pattern + ' is the string'); - // testing conversion to String - testcases[count++] = new TestCase ( SECTION, "PHONE_pattern + ' is the string'", - "/\\(?(\\d{3})\\)?-?(\\d{3})-(\\d{4})/ is the string",PHONE_pattern + ' is the string'); +// testing conversion to int +new TestCase ( SECTION, "SSN_pattern - 8", + NaN,SSN_pattern - 8); - // testing conversion to int - testcases[count++] = new TestCase ( SECTION, "SSN_pattern - 8", - NaN,SSN_pattern - 8); +var testPattern = new RegExp("(\\d+)45(\\d+)90"); - var testPattern = new RegExp("(\\d+)45(\\d+)90"); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_rightContext.js b/mozilla/js/tests/js1_2/regexp/RegExp_rightContext.js index d38f2cf72fd..2be8d5b5d32 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_rightContext.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_rightContext.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_rightContext.js - Description: 'Tests RegExps rightContext property' - Author: Nick Lerissa - Date: March 12, 1998 +/** + Filename: RegExp_rightContext.js + Description: 'Tests RegExps rightContext property' + + Author: Nick Lerissa + Date: March 12, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: rightContext'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: rightContext'; - writeHeaderToLog('Executing script: RegExp_rightContext.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_rightContext.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abc123xyz'.match(/123/); RegExp.rightContext +'abc123xyz'.match(/123/); +new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp.rightContext", + 'xyz', RegExp.rightContext); - // 'abc123xyz'.match(/123/); RegExp.rightContext - 'abc123xyz'.match(/123/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp.rightContext", - 'xyz', RegExp.rightContext); +// 'abc123xyz'.match(/456/); RegExp.rightContext +'abc123xyz'.match(/456/); +new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp.rightContext", + 'xyz', RegExp.rightContext); - // 'abc123xyz'.match(/456/); RegExp.rightContext - 'abc123xyz'.match(/456/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp.rightContext", - 'xyz', RegExp.rightContext); +// 'abc123xyz'.match(/abc123xyz/); RegExp.rightContext +'abc123xyz'.match(/abc123xyz/); +new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp.rightContext", + '', RegExp.rightContext); - // 'abc123xyz'.match(/abc123xyz/); RegExp.rightContext - 'abc123xyz'.match(/abc123xyz/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp.rightContext", - '', RegExp.rightContext); +// 'xxxx'.match(/$/); RegExp.rightContext +'xxxx'.match(/$/); +new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp.rightContext", + '', RegExp.rightContext); - // 'xxxx'.match(/$/); RegExp.rightContext - 'xxxx'.match(/$/); - testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp.rightContext", - '', RegExp.rightContext); +// 'test'.match(/^/); RegExp.rightContext +'test'.match(/^/); +new TestCase ( SECTION, "'test'.match(/^/); RegExp.rightContext", + 'test', RegExp.rightContext); - // 'test'.match(/^/); RegExp.rightContext - 'test'.match(/^/); - testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp.rightContext", - 'test', RegExp.rightContext); +// 'xxxx'.match(new RegExp('$')); RegExp.rightContext +'xxxx'.match(new RegExp('$')); +new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp.rightContext", + '', RegExp.rightContext); - // 'xxxx'.match(new RegExp('$')); RegExp.rightContext - 'xxxx'.match(new RegExp('$')); - testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp.rightContext", - '', RegExp.rightContext); +// 'test'.match(new RegExp('^')); RegExp.rightContext +'test'.match(new RegExp('^')); +new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp.rightContext", + 'test', RegExp.rightContext); - // 'test'.match(new RegExp('^')); RegExp.rightContext - 'test'.match(new RegExp('^')); - testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp.rightContext", - 'test', RegExp.rightContext); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/RegExp_rightContext_as_array.js b/mozilla/js/tests/js1_2/regexp/RegExp_rightContext_as_array.js index 42d7fb3bd34..c8d18c2ef83 100644 --- a/mozilla/js/tests/js1_2/regexp/RegExp_rightContext_as_array.js +++ b/mozilla/js/tests/js1_2/regexp/RegExp_rightContext_as_array.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: RegExp_rightContext_as_array.js - Description: 'Tests RegExps $\' property (same tests as RegExp_rightContext.js but using $\)' - Author: Nick Lerissa - Date: March 12, 1998 +/** + Filename: RegExp_rightContext_as_array.js + Description: 'Tests RegExps $\' property (same tests as RegExp_rightContext.js but using $\)' + + Author: Nick Lerissa + Date: March 12, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: $\''; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: $\''; - writeHeaderToLog('Executing script: RegExp_rightContext.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: RegExp_rightContext.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abc123xyz'.match(/123/); RegExp['$\''] +'abc123xyz'.match(/123/); +new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp['$\'']", + 'xyz', RegExp['$\'']); - // 'abc123xyz'.match(/123/); RegExp['$\''] - 'abc123xyz'.match(/123/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/123/); RegExp['$\'']", - 'xyz', RegExp['$\'']); +// 'abc123xyz'.match(/456/); RegExp['$\''] +'abc123xyz'.match(/456/); +new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp['$\'']", + 'xyz', RegExp['$\'']); - // 'abc123xyz'.match(/456/); RegExp['$\''] - 'abc123xyz'.match(/456/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/456/); RegExp['$\'']", - 'xyz', RegExp['$\'']); +// 'abc123xyz'.match(/abc123xyz/); RegExp['$\''] +'abc123xyz'.match(/abc123xyz/); +new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp['$\'']", + '', RegExp['$\'']); - // 'abc123xyz'.match(/abc123xyz/); RegExp['$\''] - 'abc123xyz'.match(/abc123xyz/); - testcases[count++] = new TestCase ( SECTION, "'abc123xyz'.match(/abc123xyz/); RegExp['$\'']", - '', RegExp['$\'']); +// 'xxxx'.match(/$/); RegExp['$\''] +'xxxx'.match(/$/); +new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp['$\'']", + '', RegExp['$\'']); - // 'xxxx'.match(/$/); RegExp['$\''] - 'xxxx'.match(/$/); - testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(/$/); RegExp['$\'']", - '', RegExp['$\'']); +// 'test'.match(/^/); RegExp['$\''] +'test'.match(/^/); +new TestCase ( SECTION, "'test'.match(/^/); RegExp['$\'']", + 'test', RegExp['$\'']); - // 'test'.match(/^/); RegExp['$\''] - 'test'.match(/^/); - testcases[count++] = new TestCase ( SECTION, "'test'.match(/^/); RegExp['$\'']", - 'test', RegExp['$\'']); +// 'xxxx'.match(new RegExp('$')); RegExp['$\''] +'xxxx'.match(new RegExp('$')); +new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp['$\'']", + '', RegExp['$\'']); - // 'xxxx'.match(new RegExp('$')); RegExp['$\''] - 'xxxx'.match(new RegExp('$')); - testcases[count++] = new TestCase ( SECTION, "'xxxx'.match(new RegExp('$')); RegExp['$\'']", - '', RegExp['$\'']); +// 'test'.match(new RegExp('^')); RegExp['$\''] +'test'.match(new RegExp('^')); +new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp['$\'']", + 'test', RegExp['$\'']); - // 'test'.match(new RegExp('^')); RegExp['$\''] - 'test'.match(new RegExp('^')); - testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('^')); RegExp['$\'']", - 'test', RegExp['$\'']); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/alphanumeric.js b/mozilla/js/tests/js1_2/regexp/alphanumeric.js index 9f42f1cde10..8d8c110bf0c 100644 --- a/mozilla/js/tests/js1_2/regexp/alphanumeric.js +++ b/mozilla/js/tests/js1_2/regexp/alphanumeric.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,111 +35,95 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: alphanumeric.js - Description: 'Tests regular expressions with \w and \W special characters' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: alphanumeric.js + Description: 'Tests regular expressions with \w and \W special characters' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: \\w and \\W'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: \\w and \\W'; - writeHeaderToLog('Executing script: alphanumeric.js'); - writeHeaderToLog( SECTION + " " + TITLE); +writeHeaderToLog('Executing script: alphanumeric.js'); +writeHeaderToLog( SECTION + " " + TITLE); - var count = 0; - var testcases = new Array(); +var non_alphanumeric = "~`!@#$%^&*()-+={[}]|\\:;'<,>./?\f\n\r\t\v " + '"'; +var alphanumeric = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - var non_alphanumeric = "~`!@#$%^&*()-+={[}]|\\:;'<,>./?\f\n\r\t\v " + '"'; - var alphanumeric = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; +// be sure all alphanumerics are matched by \w +new TestCase ( SECTION, + "'" + alphanumeric + "'.match(new RegExp('\\w+'))", + String([alphanumeric]), String(alphanumeric.match(new RegExp('\\w+')))); - // be sure all alphanumerics are matched by \w - testcases[count++] = new TestCase ( SECTION, - "'" + alphanumeric + "'.match(new RegExp('\\w+'))", - String([alphanumeric]), String(alphanumeric.match(new RegExp('\\w+')))); +// be sure all non-alphanumerics are matched by \W +new TestCase ( SECTION, + "'" + non_alphanumeric + "'.match(new RegExp('\\W+'))", + String([non_alphanumeric]), String(non_alphanumeric.match(new RegExp('\\W+')))); - // be sure all non-alphanumerics are matched by \W - testcases[count++] = new TestCase ( SECTION, - "'" + non_alphanumeric + "'.match(new RegExp('\\W+'))", - String([non_alphanumeric]), String(non_alphanumeric.match(new RegExp('\\W+')))); +// be sure all non-alphanumerics are not matched by \w +new TestCase ( SECTION, + "'" + non_alphanumeric + "'.match(new RegExp('\\w'))", + null, non_alphanumeric.match(new RegExp('\\w'))); - // be sure all non-alphanumerics are not matched by \w - testcases[count++] = new TestCase ( SECTION, - "'" + non_alphanumeric + "'.match(new RegExp('\\w'))", - null, non_alphanumeric.match(new RegExp('\\w'))); +// be sure all alphanumerics are not matched by \W +new TestCase ( SECTION, + "'" + alphanumeric + "'.match(new RegExp('\\W'))", + null, alphanumeric.match(new RegExp('\\W'))); - // be sure all alphanumerics are not matched by \W - testcases[count++] = new TestCase ( SECTION, - "'" + alphanumeric + "'.match(new RegExp('\\W'))", - null, alphanumeric.match(new RegExp('\\W'))); +var s = non_alphanumeric + alphanumeric; - var s = non_alphanumeric + alphanumeric; +// be sure all alphanumerics are matched by \w +new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\w+'))", + String([alphanumeric]), String(s.match(new RegExp('\\w+')))); - // be sure all alphanumerics are matched by \w - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\w+'))", - String([alphanumeric]), String(s.match(new RegExp('\\w+')))); +s = alphanumeric + non_alphanumeric; - s = alphanumeric + non_alphanumeric; +// be sure all non-alphanumerics are matched by \W +new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\W+'))", + String([non_alphanumeric]), String(s.match(new RegExp('\\W+')))); - // be sure all non-alphanumerics are matched by \W - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\W+'))", - String([non_alphanumeric]), String(s.match(new RegExp('\\W+')))); +// be sure all alphanumerics are matched by \w (using literals) +new TestCase ( SECTION, + "'" + s + "'.match(/\w+/)", + String([alphanumeric]), String(s.match(/\w+/))); - // be sure all alphanumerics are matched by \w (using literals) - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/\w+/)", - String([alphanumeric]), String(s.match(/\w+/))); +s = alphanumeric + non_alphanumeric; - s = alphanumeric + non_alphanumeric; +// be sure all non-alphanumerics are matched by \W (using literals) +new TestCase ( SECTION, + "'" + s + "'.match(/\W+/)", + String([non_alphanumeric]), String(s.match(/\W+/))); - // be sure all non-alphanumerics are matched by \W (using literals) - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/\W+/)", - String([non_alphanumeric]), String(s.match(/\W+/))); +s = 'abcd*&^%$$'; +// be sure the following test behaves consistently +new TestCase ( SECTION, + "'" + s + "'.match(/(\w+)...(\W+)/)", + String([s , 'abcd' , '%$$']), String(s.match(/(\w+)...(\W+)/))); - s = 'abcd*&^%$$'; - // be sure the following test behaves consistently - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/(\w+)...(\W+)/)", - String([s , 'abcd' , '%$$']), String(s.match(/(\w+)...(\W+)/))); +var i; - var i; +// be sure all alphanumeric characters match individually +for (i = 0; i < alphanumeric.length; ++i) +{ + s = '#$' + alphanumeric[i] + '%^'; + new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\w'))", + String([alphanumeric[i]]), String(s.match(new RegExp('\\w')))); +} +// be sure all non_alphanumeric characters match individually +for (i = 0; i < non_alphanumeric.length; ++i) +{ + s = 'sd' + non_alphanumeric[i] + String((i+10) * (i+10) - 2 * (i+10)); + new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\W'))", + String([non_alphanumeric[i]]), String(s.match(new RegExp('\\W')))); +} - // be sure all alphanumeric characters match individually - for (i = 0; i < alphanumeric.length; ++i) - { - s = '#$' + alphanumeric[i] + '%^'; - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\w'))", - String([alphanumeric[i]]), String(s.match(new RegExp('\\w')))); - } - // be sure all non_alphanumeric characters match individually - for (i = 0; i < non_alphanumeric.length; ++i) - { - s = 'sd' + non_alphanumeric[i] + String((i+10) * (i+10) - 2 * (i+10)); - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\W'))", - String([non_alphanumeric[i]]), String(s.match(new RegExp('\\W')))); - } - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/asterisk.js b/mozilla/js/tests/js1_2/regexp/asterisk.js index 9a1bf09e40e..64d57c57933 100644 --- a/mozilla/js/tests/js1_2/regexp/asterisk.js +++ b/mozilla/js/tests/js1_2/regexp/asterisk.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,87 +35,71 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: asterisk.js - Description: 'Tests regular expressions containing *' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: asterisk.js + Description: 'Tests regular expressions containing *' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: *'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: *'; - writeHeaderToLog('Executing script: aterisk.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: aterisk.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abcddddefg'.match(new RegExp('d*')) +new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('d*'))", + String([""]), String('abcddddefg'.match(new RegExp('d*')))); - // 'abcddddefg'.match(new RegExp('d*')) - testcases[count++] = new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('d*'))", - String([""]), String('abcddddefg'.match(new RegExp('d*')))); +// 'abcddddefg'.match(new RegExp('cd*')) +new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('cd*'))", + String(["cdddd"]), String('abcddddefg'.match(new RegExp('cd*')))); - // 'abcddddefg'.match(new RegExp('cd*')) - testcases[count++] = new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('cd*'))", - String(["cdddd"]), String('abcddddefg'.match(new RegExp('cd*')))); +// 'abcdefg'.match(new RegExp('cx*d')) +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('cx*d'))", + String(["cd"]), String('abcdefg'.match(new RegExp('cx*d')))); - // 'abcdefg'.match(new RegExp('cx*d')) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('cx*d'))", - String(["cd"]), String('abcdefg'.match(new RegExp('cx*d')))); +// 'xxxxxxx'.match(new RegExp('(x*)(x+)')) +new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x*)(x+)'))", + String(["xxxxxxx","xxxxxx","x"]), String('xxxxxxx'.match(new RegExp('(x*)(x+)')))); - // 'xxxxxxx'.match(new RegExp('(x*)(x+)')) - testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x*)(x+)'))", - String(["xxxxxxx","xxxxxx","x"]), String('xxxxxxx'.match(new RegExp('(x*)(x+)')))); +// '1234567890'.match(new RegExp('(\\d*)(\\d+)')) +new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)(\\d+)'))", + String(["1234567890","123456789","0"]), + String('1234567890'.match(new RegExp('(\\d*)(\\d+)')))); - // '1234567890'.match(new RegExp('(\\d*)(\\d+)')) - testcases[count++] = new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)(\\d+)'))", - String(["1234567890","123456789","0"]), - String('1234567890'.match(new RegExp('(\\d*)(\\d+)')))); +// '1234567890'.match(new RegExp('(\\d*)\\d(\\d+)')) +new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))", + String(["1234567890","12345678","0"]), + String('1234567890'.match(new RegExp('(\\d*)\\d(\\d+)')))); - // '1234567890'.match(new RegExp('(\\d*)\\d(\\d+)')) - testcases[count++] = new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))", - String(["1234567890","12345678","0"]), - String('1234567890'.match(new RegExp('(\\d*)\\d(\\d+)')))); +// 'xxxxxxx'.match(new RegExp('(x+)(x*)')) +new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x+)(x*)'))", + String(["xxxxxxx","xxxxxxx",""]), String('xxxxxxx'.match(new RegExp('(x+)(x*)')))); - // 'xxxxxxx'.match(new RegExp('(x+)(x*)')) - testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x+)(x*)'))", - String(["xxxxxxx","xxxxxxx",""]), String('xxxxxxx'.match(new RegExp('(x+)(x*)')))); +// 'xxxxxxyyyyyy'.match(new RegExp('x*y+$')) +new TestCase ( SECTION, "'xxxxxxyyyyyy'.match(new RegExp('x*y+$'))", + String(["xxxxxxyyyyyy"]), String('xxxxxxyyyyyy'.match(new RegExp('x*y+$')))); - // 'xxxxxxyyyyyy'.match(new RegExp('x*y+$')) - testcases[count++] = new TestCase ( SECTION, "'xxxxxxyyyyyy'.match(new RegExp('x*y+$'))", - String(["xxxxxxyyyyyy"]), String('xxxxxxyyyyyy'.match(new RegExp('x*y+$')))); +// 'abcdef'.match(/[\d]*[\s]*bc./) +new TestCase ( SECTION, "'abcdef'.match(/[\\d]*[\\s]*bc./)", + String(["bcd"]), String('abcdef'.match(/[\d]*[\s]*bc./))); - // 'abcdef'.match(/[\d]*[\s]*bc./) - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/[\\d]*[\\s]*bc./)", - String(["bcd"]), String('abcdef'.match(/[\d]*[\s]*bc./))); +// 'abcdef'.match(/bc..[\d]*[\s]*/) +new TestCase ( SECTION, "'abcdef'.match(/bc..[\\d]*[\\s]*/)", + String(["bcde"]), String('abcdef'.match(/bc..[\d]*[\s]*/))); - // 'abcdef'.match(/bc..[\d]*[\s]*/) - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/bc..[\\d]*[\\s]*/)", - String(["bcde"]), String('abcdef'.match(/bc..[\d]*[\s]*/))); +// 'a1b2c3'.match(/.*/) +new TestCase ( SECTION, "'a1b2c3'.match(/.*/)", + String(["a1b2c3"]), String('a1b2c3'.match(/.*/))); - // 'a1b2c3'.match(/.*/) - testcases[count++] = new TestCase ( SECTION, "'a1b2c3'.match(/.*/)", - String(["a1b2c3"]), String('a1b2c3'.match(/.*/))); +// 'a0.b2.c3'.match(/[xyz]*1/) +new TestCase ( SECTION, "'a0.b2.c3'.match(/[xyz]*1/)", + null, 'a0.b2.c3'.match(/[xyz]*1/)); - // 'a0.b2.c3'.match(/[xyz]*1/) - testcases[count++] = new TestCase ( SECTION, "'a0.b2.c3'.match(/[xyz]*1/)", - null, 'a0.b2.c3'.match(/[xyz]*1/)); - -function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/backslash.js b/mozilla/js/tests/js1_2/regexp/backslash.js index 155efe52ca5..a1406428ae4 100644 --- a/mozilla/js/tests/js1_2/regexp/backslash.js +++ b/mozilla/js/tests/js1_2/regexp/backslash.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,45 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: backslash.js - Description: 'Tests regular expressions containing \' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: backslash.js + Description: 'Tests regular expressions containing \' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: \\'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: \\'; - writeHeaderToLog('Executing script: backslash.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: backslash.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abcde'.match(new RegExp('\e')) +new TestCase ( SECTION, "'abcde'.match(new RegExp('\e'))", + String(["e"]), String('abcde'.match(new RegExp('\e')))); - // 'abcde'.match(new RegExp('\e')) - testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('\e'))", - String(["e"]), String('abcde'.match(new RegExp('\e')))); +// 'ab\\cde'.match(new RegExp('\\\\')) +new TestCase ( SECTION, "'ab\\cde'.match(new RegExp('\\\\'))", + String(["\\"]), String('ab\\cde'.match(new RegExp('\\\\')))); - // 'ab\\cde'.match(new RegExp('\\\\')) - testcases[count++] = new TestCase ( SECTION, "'ab\\cde'.match(new RegExp('\\\\'))", - String(["\\"]), String('ab\\cde'.match(new RegExp('\\\\')))); +// 'ab\\cde'.match(/\\/) (using literal) +new TestCase ( SECTION, "'ab\\cde'.match(/\\\\/)", + String(["\\"]), String('ab\\cde'.match(/\\/))); - // 'ab\\cde'.match(/\\/) (using literal) - testcases[count++] = new TestCase ( SECTION, "'ab\\cde'.match(/\\\\/)", - String(["\\"]), String('ab\\cde'.match(/\\/))); +// 'before ^$*+?.()|{}[] after'.match(new RegExp('\^\$\*\+\?\.\(\)\|\{\}\[\]')) +new TestCase ( SECTION, + "'before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]'))", + String(["^$*+?.()|{}[]"]), + String('before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]')))); - // 'before ^$*+?.()|{}[] after'.match(new RegExp('\^\$\*\+\?\.\(\)\|\{\}\[\]')) - testcases[count++] = new TestCase ( SECTION, - "'before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]'))", - String(["^$*+?.()|{}[]"]), - String('before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]')))); +// 'before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/) (using literal) +new TestCase ( SECTION, + "'before ^$*+?.()|{}[] after'.match(/\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]/)", + String(["^$*+?.()|{}[]"]), + String('before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/))); - // 'before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/) (using literal) - testcases[count++] = new TestCase ( SECTION, - "'before ^$*+?.()|{}[] after'.match(/\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]/)", - String(["^$*+?.()|{}[]"]), - String('before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/backspace.js b/mozilla/js/tests/js1_2/regexp/backspace.js index aef8b61783a..ea614a0edf1 100644 --- a/mozilla/js/tests/js1_2/regexp/backspace.js +++ b/mozilla/js/tests/js1_2/regexp/backspace.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,45 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: backspace.js - Description: 'Tests regular expressions containing [\b]' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: backspace.js + Description: 'Tests regular expressions containing [\b]' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: [\b]'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: [\b]'; - writeHeaderToLog('Executing script: backspace.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: backspace.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abc\bdef'.match(new RegExp('.[\b].')) +new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('.[\\b].'))", + String(["c\bd"]), String('abc\bdef'.match(new RegExp('.[\\b].')))); - // 'abc\bdef'.match(new RegExp('.[\b].')) - testcases[count++] = new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('.[\\b].'))", - String(["c\bd"]), String('abc\bdef'.match(new RegExp('.[\\b].')))); +// 'abc\\bdef'.match(new RegExp('.[\b].')) +new TestCase ( SECTION, "'abc\\bdef'.match(new RegExp('.[\\b].'))", + null, 'abc\\bdef'.match(new RegExp('.[\\b].'))); - // 'abc\\bdef'.match(new RegExp('.[\b].')) - testcases[count++] = new TestCase ( SECTION, "'abc\\bdef'.match(new RegExp('.[\\b].'))", - null, 'abc\\bdef'.match(new RegExp('.[\\b].'))); +// 'abc\b\b\bdef'.match(new RegExp('c[\b]{3}d')) +new TestCase ( SECTION, "'abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d'))", + String(["c\b\b\bd"]), String('abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d')))); - // 'abc\b\b\bdef'.match(new RegExp('c[\b]{3}d')) - testcases[count++] = new TestCase ( SECTION, "'abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d'))", - String(["c\b\b\bd"]), String('abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d')))); +// 'abc\bdef'.match(new RegExp('[^\\[\b\\]]+')) +new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('[^\\[\\b\\]]+'))", + String(["abc"]), String('abc\bdef'.match(new RegExp('[^\\[\\b\\]]+')))); - // 'abc\bdef'.match(new RegExp('[^\\[\b\\]]+')) - testcases[count++] = new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('[^\\[\\b\\]]+'))", - String(["abc"]), String('abc\bdef'.match(new RegExp('[^\\[\\b\\]]+')))); +// 'abcdef'.match(new RegExp('[^\\[\b\\]]+')) +new TestCase ( SECTION, "'abcdef'.match(new RegExp('[^\\[\\b\\]]+'))", + String(["abcdef"]), String('abcdef'.match(new RegExp('[^\\[\\b\\]]+')))); - // 'abcdef'.match(new RegExp('[^\\[\b\\]]+')) - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('[^\\[\\b\\]]+'))", - String(["abcdef"]), String('abcdef'.match(new RegExp('[^\\[\\b\\]]+')))); +// 'abcdef'.match(/[^\[\b\]]+/) +new TestCase ( SECTION, "'abcdef'.match(/[^\\[\\b\\]]+/)", + String(["abcdef"]), String('abcdef'.match(/[^\[\b\]]+/))); - // 'abcdef'.match(/[^\[\b\]]+/) - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/[^\\[\\b\\]]+/)", - String(["abcdef"]), String('abcdef'.match(/[^\[\b\]]+/))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/beginLine.js b/mozilla/js/tests/js1_2/regexp/beginLine.js index 3d02be7f754..d6bdebc8f26 100644 --- a/mozilla/js/tests/js1_2/regexp/beginLine.js +++ b/mozilla/js/tests/js1_2/regexp/beginLine.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: beginLine.js - Description: 'Tests regular expressions containing ^' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: beginLine.js + Description: 'Tests regular expressions containing ^' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: ^'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: ^'; - writeHeaderToLog('Executing script: beginLine.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: beginLine.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'abcde'.match(new RegExp('^ab')) - testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('^ab'))", - String(["ab"]), String('abcde'.match(new RegExp('^ab')))); +// 'abcde'.match(new RegExp('^ab')) +new TestCase ( SECTION, "'abcde'.match(new RegExp('^ab'))", + String(["ab"]), String('abcde'.match(new RegExp('^ab')))); - // 'ab\ncde'.match(new RegExp('^..^e')) - testcases[count++] = new TestCase ( SECTION, "'ab\ncde'.match(new RegExp('^..^e'))", - null, 'ab\ncde'.match(new RegExp('^..^e'))); +// 'ab\ncde'.match(new RegExp('^..^e')) +new TestCase ( SECTION, "'ab\ncde'.match(new RegExp('^..^e'))", + null, 'ab\ncde'.match(new RegExp('^..^e'))); - // 'yyyyy'.match(new RegExp('^xxx')) - testcases[count++] = new TestCase ( SECTION, "'yyyyy'.match(new RegExp('^xxx'))", - null, 'yyyyy'.match(new RegExp('^xxx'))); +// 'yyyyy'.match(new RegExp('^xxx')) +new TestCase ( SECTION, "'yyyyy'.match(new RegExp('^xxx'))", + null, 'yyyyy'.match(new RegExp('^xxx'))); - // '^^^x'.match(new RegExp('^\\^+')) - testcases[count++] = new TestCase ( SECTION, "'^^^x'.match(new RegExp('^\\^+'))", - String(['^^^']), String('^^^x'.match(new RegExp('^\\^+')))); +// '^^^x'.match(new RegExp('^\\^+')) +new TestCase ( SECTION, "'^^^x'.match(new RegExp('^\\^+'))", + String(['^^^']), String('^^^x'.match(new RegExp('^\\^+')))); - // '^^^x'.match(/^\^+/) - testcases[count++] = new TestCase ( SECTION, "'^^^x'.match(/^\\^+/)", - String(['^^^']), String('^^^x'.match(/^\^+/))); +// '^^^x'.match(/^\^+/) +new TestCase ( SECTION, "'^^^x'.match(/^\\^+/)", + String(['^^^']), String('^^^x'.match(/^\^+/))); - RegExp.multiline = true; - // 'abc\n123xyz'.match(new RegExp('^\d+')) <multiline==true> - testcases[count++] = new TestCase ( SECTION, "'abc\n123xyz'.match(new RegExp('^\\d+'))", - String(['123']), String('abc\n123xyz'.match(new RegExp('^\\d+')))); +RegExp.multiline = true; +// 'abc\n123xyz'.match(new RegExp('^\d+')) <multiline==true> +new TestCase ( SECTION, "'abc\n123xyz'.match(new RegExp('^\\d+'))", + String(['123']), String('abc\n123xyz'.match(new RegExp('^\\d+')))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/browser.js b/mozilla/js/tests/js1_2/regexp/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/regexp/character_class.js b/mozilla/js/tests/js1_2/regexp/character_class.js index 6efabe9c6bb..5be5beefff2 100644 --- a/mozilla/js/tests/js1_2/regexp/character_class.js +++ b/mozilla/js/tests/js1_2/regexp/character_class.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,89 +35,74 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: character_class.js - Description: 'Tests regular expressions containing []' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: character_class.js + Description: 'Tests regular expressions containing []' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: []'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: []'; - writeHeaderToLog('Executing script: character_class.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: character_class.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'abcde'.match(new RegExp('ab[ercst]de')) - testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab[ercst]de'))", - String(["abcde"]), String('abcde'.match(new RegExp('ab[ercst]de')))); +// 'abcde'.match(new RegExp('ab[ercst]de')) +new TestCase ( SECTION, "'abcde'.match(new RegExp('ab[ercst]de'))", + String(["abcde"]), String('abcde'.match(new RegExp('ab[ercst]de')))); - // 'abcde'.match(new RegExp('ab[erst]de')) - testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab[erst]de'))", - null, 'abcde'.match(new RegExp('ab[erst]de'))); +// 'abcde'.match(new RegExp('ab[erst]de')) +new TestCase ( SECTION, "'abcde'.match(new RegExp('ab[erst]de'))", + null, 'abcde'.match(new RegExp('ab[erst]de'))); - // 'abcdefghijkl'.match(new RegExp('[d-h]+')) - testcases[count++] = new TestCase ( SECTION, "'abcdefghijkl'.match(new RegExp('[d-h]+'))", - String(["defgh"]), String('abcdefghijkl'.match(new RegExp('[d-h]+')))); +// 'abcdefghijkl'.match(new RegExp('[d-h]+')) +new TestCase ( SECTION, "'abcdefghijkl'.match(new RegExp('[d-h]+'))", + String(["defgh"]), String('abcdefghijkl'.match(new RegExp('[d-h]+')))); - // 'abc6defghijkl'.match(new RegExp('[1234567].{2}')) - testcases[count++] = new TestCase ( SECTION, "'abc6defghijkl'.match(new RegExp('[1234567].{2}'))", - String(["6de"]), String('abc6defghijkl'.match(new RegExp('[1234567].{2}')))); +// 'abc6defghijkl'.match(new RegExp('[1234567].{2}')) +new TestCase ( SECTION, "'abc6defghijkl'.match(new RegExp('[1234567].{2}'))", + String(["6de"]), String('abc6defghijkl'.match(new RegExp('[1234567].{2}')))); - // '\n\n\abc324234\n'.match(new RegExp('[a-c\d]+')) - testcases[count++] = new TestCase ( SECTION, "'\n\n\abc324234\n'.match(new RegExp('[a-c\\d]+'))", - String(["abc324234"]), String('\n\n\abc324234\n'.match(new RegExp('[a-c\\d]+')))); +// '\n\n\abc324234\n'.match(new RegExp('[a-c\d]+')) +new TestCase ( SECTION, "'\n\n\abc324234\n'.match(new RegExp('[a-c\\d]+'))", + String(["abc324234"]), String('\n\n\abc324234\n'.match(new RegExp('[a-c\\d]+')))); - // 'abc'.match(new RegExp('ab[.]?c')) - testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('ab[.]?c'))", - String(["abc"]), String('abc'.match(new RegExp('ab[.]?c')))); +// 'abc'.match(new RegExp('ab[.]?c')) +new TestCase ( SECTION, "'abc'.match(new RegExp('ab[.]?c'))", + String(["abc"]), String('abc'.match(new RegExp('ab[.]?c')))); - // 'abc'.match(new RegExp('a[b]c')) - testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[b]c'))", - String(["abc"]), String('abc'.match(new RegExp('a[b]c')))); +// 'abc'.match(new RegExp('a[b]c')) +new TestCase ( SECTION, "'abc'.match(new RegExp('a[b]c'))", + String(["abc"]), String('abc'.match(new RegExp('a[b]c')))); - // 'a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]')) - testcases[count++] = new TestCase ( SECTION, "'a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]'))", - String(["def"]), String('a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]')))); +// 'a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]')) +new TestCase ( SECTION, "'a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]'))", + String(["def"]), String('a1b b2c c3d def f4g'.match(new RegExp('[a-z][^1-9][a-z]')))); - // '123*&$abc'.match(new RegExp('[*&$]{3}')) - testcases[count++] = new TestCase ( SECTION, "'123*&$abc'.match(new RegExp('[*&$]{3}'))", - String(["*&$"]), String('123*&$abc'.match(new RegExp('[*&$]{3}')))); +// '123*&$abc'.match(new RegExp('[*&$]{3}')) +new TestCase ( SECTION, "'123*&$abc'.match(new RegExp('[*&$]{3}'))", + String(["*&$"]), String('123*&$abc'.match(new RegExp('[*&$]{3}')))); - // 'abc'.match(new RegExp('a[^1-9]c')) - testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[^1-9]c'))", - String(["abc"]), String('abc'.match(new RegExp('a[^1-9]c')))); +// 'abc'.match(new RegExp('a[^1-9]c')) +new TestCase ( SECTION, "'abc'.match(new RegExp('a[^1-9]c'))", + String(["abc"]), String('abc'.match(new RegExp('a[^1-9]c')))); - // 'abc'.match(new RegExp('a[^b]c')) - testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('a[^b]c'))", - null, 'abc'.match(new RegExp('a[^b]c'))); +// 'abc'.match(new RegExp('a[^b]c')) +new TestCase ( SECTION, "'abc'.match(new RegExp('a[^b]c'))", + null, 'abc'.match(new RegExp('a[^b]c'))); - // 'abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}')) - testcases[count++] = new TestCase ( SECTION, "'abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}'))", - String(["%&*@"]), String('abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}')))); +// 'abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}')) +new TestCase ( SECTION, "'abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}'))", + String(["%&*@"]), String('abc#$%def%&*@ghi)(*&'.match(new RegExp('[^a-z]{4}')))); - // 'abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/) - testcases[count++] = new TestCase ( SECTION, "'abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/)", - String(["%&*@"]), String('abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/))); +// 'abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/) +new TestCase ( SECTION, "'abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/)", + String(["%&*@"]), String('abc#$%def%&*@ghi)(*&'.match(/[^a-z]{4}/))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/compile.js b/mozilla/js/tests/js1_2/regexp/compile.js index 31c9d165340..ef4f5b821f2 100644 --- a/mozilla/js/tests/js1_2/regexp/compile.js +++ b/mozilla/js/tests/js1_2/regexp/compile.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,76 +35,60 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: compile.js - Description: 'Tests regular expressions method compile' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: compile.js + Description: 'Tests regular expressions method compile' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: compile'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: compile'; - writeHeaderToLog('Executing script: compile.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: compile.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var regularExpression = new RegExp(); - var regularExpression = new RegExp(); +regularExpression.compile("[0-9]{3}x[0-9]{4}","i"); - regularExpression.compile("[0-9]{3}x[0-9]{4}","i"); +new TestCase ( SECTION, + "(compile '[0-9]{3}x[0-9]{4}','i')", + String(["456X7890"]), String('234X456X7890'.match(regularExpression))); - testcases[count++] = new TestCase ( SECTION, - "(compile '[0-9]{3}x[0-9]{4}','i')", - String(["456X7890"]), String('234X456X7890'.match(regularExpression))); +new TestCase ( SECTION, + "source of (compile '[0-9]{3}x[0-9]{4}','i')", + "[0-9]{3}x[0-9]{4}", regularExpression.source); - testcases[count++] = new TestCase ( SECTION, - "source of (compile '[0-9]{3}x[0-9]{4}','i')", - "[0-9]{3}x[0-9]{4}", regularExpression.source); +new TestCase ( SECTION, + "global of (compile '[0-9]{3}x[0-9]{4}','i')", + false, regularExpression.global); - testcases[count++] = new TestCase ( SECTION, - "global of (compile '[0-9]{3}x[0-9]{4}','i')", - false, regularExpression.global); +new TestCase ( SECTION, + "ignoreCase of (compile '[0-9]{3}x[0-9]{4}','i')", + true, regularExpression.ignoreCase); - testcases[count++] = new TestCase ( SECTION, - "ignoreCase of (compile '[0-9]{3}x[0-9]{4}','i')", - true, regularExpression.ignoreCase); +regularExpression.compile("[0-9]{3}X[0-9]{3}","g"); - regularExpression.compile("[0-9]{3}X[0-9]{3}","g"); +new TestCase ( SECTION, + "(compile '[0-9]{3}X[0-9]{3}','g')", + String(["234X456"]), String('234X456X7890'.match(regularExpression))); - testcases[count++] = new TestCase ( SECTION, - "(compile '[0-9]{3}X[0-9]{3}','g')", - String(["234X456"]), String('234X456X7890'.match(regularExpression))); +new TestCase ( SECTION, + "source of (compile '[0-9]{3}X[0-9]{3}','g')", + "[0-9]{3}X[0-9]{3}", regularExpression.source); - testcases[count++] = new TestCase ( SECTION, - "source of (compile '[0-9]{3}X[0-9]{3}','g')", - "[0-9]{3}X[0-9]{3}", regularExpression.source); +new TestCase ( SECTION, + "global of (compile '[0-9]{3}X[0-9]{3}','g')", + true, regularExpression.global); - testcases[count++] = new TestCase ( SECTION, - "global of (compile '[0-9]{3}X[0-9]{3}','g')", - true, regularExpression.global); - - testcases[count++] = new TestCase ( SECTION, - "ignoreCase of (compile '[0-9]{3}X[0-9]{3}','g')", - false, regularExpression.ignoreCase); +new TestCase ( SECTION, + "ignoreCase of (compile '[0-9]{3}X[0-9]{3}','g')", + false, regularExpression.ignoreCase); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/control_characters.js b/mozilla/js/tests/js1_2/regexp/control_characters.js index f39684a1614..28a299cf59d 100644 --- a/mozilla/js/tests/js1_2/regexp/control_characters.js +++ b/mozilla/js/tests/js1_2/regexp/control_characters.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,53 +35,38 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: control_characters.js - Description: 'Tests regular expressions containing .' - Author: Nick Lerissa - Date: April 8, 1998 +/** + Filename: control_characters.js + Description: 'Tests regular expressions containing .' + + Author: Nick Lerissa + Date: April 8, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: .'; - var BUGNUMBER="123802"; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: .'; +var BUGNUMBER="123802"; - writeHeaderToLog('Executing script: control_characters.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: control_characters.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'àOÐ ê:i¢Ø'.match(new RegExp('.+')) - testcases[count++] = new TestCase ( SECTION, "'àOÐ ê:i¢Ø'.match(new RegExp('.+'))", - String(['àOÐ ê:i¢Ø']), String('àOÐ ê:i¢Ø'.match(new RegExp('.+')))); +// 'àOÐ ê:i¢Ø'.match(new RegExp('.+')) +new TestCase ( SECTION, "'àOÐ ê:i¢Ø'.match(new RegExp('.+'))", + String(['àOÐ ê:i¢Ø']), String('àOÐ ê:i¢Ø'.match(new RegExp('.+')))); - // string1.match(new RegExp(string1)) - var string1 = 'àOÐ ê:i¢Ø'; - testcases[count++] = new TestCase ( SECTION, "string1 = " + string1 + " string1.match(string1)", - String([string1]), String(string1.match(string1))); +// string1.match(new RegExp(string1)) +var string1 = 'àOÐ ê:i¢Ø'; +new TestCase ( SECTION, "string1 = " + string1 + " string1.match(string1)", + String([string1]), String(string1.match(string1))); - string1 = ""; - for (var i = 0; i < 32; i++) - string1 += String.fromCharCode(i); - testcases[count++] = new TestCase ( SECTION, "string1 = " + string1 + " string1.match(string1)", - String([string1]), String(string1.match(string1))); +string1 = ""; +for (var i = 0; i < 32; i++) + string1 += String.fromCharCode(i); +new TestCase ( SECTION, "string1 = " + string1 + " string1.match(string1)", + String([string1]), String(string1.match(string1))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/digit.js b/mozilla/js/tests/js1_2/regexp/digit.js index 9883fc5bfff..8f748eaf745 100644 --- a/mozilla/js/tests/js1_2/regexp/digit.js +++ b/mozilla/js/tests/js1_2/regexp/digit.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,101 +35,84 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: digit.js - Description: 'Tests regular expressions containing \d' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: digit.js + Description: 'Tests regular expressions containing \d' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: \\d'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: \\d'; - writeHeaderToLog('Executing script: digit.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: digit.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var non_digits = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\f\n\r\t\v~`!@#$%^&*()-+={[}]|\\:;'<,>./? " + '"'; - var non_digits = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\f\n\r\t\v~`!@#$%^&*()-+={[}]|\\:;'<,>./? " + '"'; +var digits = "1234567890"; - var digits = "1234567890"; +// be sure all digits are matched by \d +new TestCase ( SECTION, + "'" + digits + "'.match(new RegExp('\\d+'))", + String([digits]), String(digits.match(new RegExp('\\d+')))); - // be sure all digits are matched by \d - testcases[count++] = new TestCase ( SECTION, - "'" + digits + "'.match(new RegExp('\\d+'))", - String([digits]), String(digits.match(new RegExp('\\d+')))); +// be sure all non-digits are matched by \D +new TestCase ( SECTION, + "'" + non_digits + "'.match(new RegExp('\\D+'))", + String([non_digits]), String(non_digits.match(new RegExp('\\D+')))); - // be sure all non-digits are matched by \D - testcases[count++] = new TestCase ( SECTION, - "'" + non_digits + "'.match(new RegExp('\\D+'))", - String([non_digits]), String(non_digits.match(new RegExp('\\D+')))); +// be sure all non-digits are not matched by \d +new TestCase ( SECTION, + "'" + non_digits + "'.match(new RegExp('\\d'))", + null, non_digits.match(new RegExp('\\d'))); - // be sure all non-digits are not matched by \d - testcases[count++] = new TestCase ( SECTION, - "'" + non_digits + "'.match(new RegExp('\\d'))", - null, non_digits.match(new RegExp('\\d'))); +// be sure all digits are not matched by \D +new TestCase ( SECTION, + "'" + digits + "'.match(new RegExp('\\D'))", + null, digits.match(new RegExp('\\D'))); - // be sure all digits are not matched by \D - testcases[count++] = new TestCase ( SECTION, - "'" + digits + "'.match(new RegExp('\\D'))", - null, digits.match(new RegExp('\\D'))); +var s = non_digits + digits; - var s = non_digits + digits; +// be sure all digits are matched by \d +new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\d+'))", + String([digits]), String(s.match(new RegExp('\\d+')))); - // be sure all digits are matched by \d - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\d+'))", - String([digits]), String(s.match(new RegExp('\\d+')))); +var s = digits + non_digits; - var s = digits + non_digits; +// be sure all non-digits are matched by \D +new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\D+'))", + String([non_digits]), String(s.match(new RegExp('\\D+')))); - // be sure all non-digits are matched by \D - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\D+'))", - String([non_digits]), String(s.match(new RegExp('\\D+')))); +var i; - var i; +// be sure all digits match individually +for (i = 0; i < digits.length; ++i) +{ + s = 'ab' + digits[i] + 'cd'; + new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\d'))", + String([digits[i]]), String(s.match(new RegExp('\\d')))); + new TestCase ( SECTION, + "'" + s + "'.match(/\\d/)", + String([digits[i]]), String(s.match(/\d/))); +} +// be sure all non_digits match individually +for (i = 0; i < non_digits.length; ++i) +{ + s = '12' + non_digits[i] + '34'; + new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\D'))", + String([non_digits[i]]), String(s.match(new RegExp('\\D')))); + new TestCase ( SECTION, + "'" + s + "'.match(/\\D/)", + String([non_digits[i]]), String(s.match(/\D/))); +} - // be sure all digits match individually - for (i = 0; i < digits.length; ++i) - { - s = 'ab' + digits[i] + 'cd'; - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\d'))", - String([digits[i]]), String(s.match(new RegExp('\\d')))); - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/\\d/)", - String([digits[i]]), String(s.match(/\d/))); - } - // be sure all non_digits match individually - for (i = 0; i < non_digits.length; ++i) - { - s = '12' + non_digits[i] + '34'; - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\D'))", - String([non_digits[i]]), String(s.match(new RegExp('\\D')))); - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/\\D/)", - String([non_digits[i]]), String(s.match(/\D/))); - } - - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/dot.js b/mozilla/js/tests/js1_2/regexp/dot.js index dbae1b9f2b3..342b480261a 100644 --- a/mozilla/js/tests/js1_2/regexp/dot.js +++ b/mozilla/js/tests/js1_2/regexp/dot.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,77 +35,62 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: dot.js - Description: 'Tests regular expressions containing .' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: dot.js + Description: 'Tests regular expressions containing .' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: .'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: .'; - writeHeaderToLog('Executing script: dot.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: dot.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'abcde'.match(new RegExp('ab.de')) - testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('ab.de'))", - String(["abcde"]), String('abcde'.match(new RegExp('ab.de')))); +// 'abcde'.match(new RegExp('ab.de')) +new TestCase ( SECTION, "'abcde'.match(new RegExp('ab.de'))", + String(["abcde"]), String('abcde'.match(new RegExp('ab.de')))); - // 'line 1\nline 2'.match(new RegExp('.+')) - testcases[count++] = new TestCase ( SECTION, "'line 1\nline 2'.match(new RegExp('.+'))", - String(["line 1"]), String('line 1\nline 2'.match(new RegExp('.+')))); +// 'line 1\nline 2'.match(new RegExp('.+')) +new TestCase ( SECTION, "'line 1\nline 2'.match(new RegExp('.+'))", + String(["line 1"]), String('line 1\nline 2'.match(new RegExp('.+')))); - // 'this is a test'.match(new RegExp('.*a.*')) - testcases[count++] = new TestCase ( SECTION, "'this is a test'.match(new RegExp('.*a.*'))", - String(["this is a test"]), String('this is a test'.match(new RegExp('.*a.*')))); +// 'this is a test'.match(new RegExp('.*a.*')) +new TestCase ( SECTION, "'this is a test'.match(new RegExp('.*a.*'))", + String(["this is a test"]), String('this is a test'.match(new RegExp('.*a.*')))); - // 'this is a *&^%$# test'.match(new RegExp('.+')) - testcases[count++] = new TestCase ( SECTION, "'this is a *&^%$# test'.match(new RegExp('.+'))", - String(["this is a *&^%$# test"]), String('this is a *&^%$# test'.match(new RegExp('.+')))); +// 'this is a *&^%$# test'.match(new RegExp('.+')) +new TestCase ( SECTION, "'this is a *&^%$# test'.match(new RegExp('.+'))", + String(["this is a *&^%$# test"]), String('this is a *&^%$# test'.match(new RegExp('.+')))); - // '....'.match(new RegExp('.+')) - testcases[count++] = new TestCase ( SECTION, "'....'.match(new RegExp('.+'))", - String(["...."]), String('....'.match(new RegExp('.+')))); +// '....'.match(new RegExp('.+')) +new TestCase ( SECTION, "'....'.match(new RegExp('.+'))", + String(["...."]), String('....'.match(new RegExp('.+')))); - // 'abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+')) - testcases[count++] = new TestCase ( SECTION, "'abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+'))", - String(["abcdefghijklmnopqrstuvwxyz"]), String('abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+')))); +// 'abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+')) +new TestCase ( SECTION, "'abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+'))", + String(["abcdefghijklmnopqrstuvwxyz"]), String('abcdefghijklmnopqrstuvwxyz'.match(new RegExp('.+')))); - // 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+')) - testcases[count++] = new TestCase ( SECTION, "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+'))", - String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+')))); +// 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+')) +new TestCase ( SECTION, "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+'))", + String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.match(new RegExp('.+')))); - // '`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+')) - testcases[count++] = new TestCase ( SECTION, "'`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+'))", - String(["`1234567890-=~!@#$%^&*()_+"]), String('`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+')))); +// '`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+')) +new TestCase ( SECTION, "'`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+'))", + String(["`1234567890-=~!@#$%^&*()_+"]), String('`1234567890-=~!@#$%^&*()_+'.match(new RegExp('.+')))); - // '|\\[{]};:"\',<>.?/'.match(new RegExp('.+')) - testcases[count++] = new TestCase ( SECTION, "'|\\[{]};:\"\',<>.?/'.match(new RegExp('.+'))", - String(["|\\[{]};:\"\',<>.?/"]), String('|\\[{]};:\"\',<>.?/'.match(new RegExp('.+')))); +// '|\\[{]};:"\',<>.?/'.match(new RegExp('.+')) +new TestCase ( SECTION, "'|\\[{]};:\"\',<>.?/'.match(new RegExp('.+'))", + String(["|\\[{]};:\"\',<>.?/"]), String('|\\[{]};:\"\',<>.?/'.match(new RegExp('.+')))); - // '|\\[{]};:"\',<>.?/'.match(/.+/) - testcases[count++] = new TestCase ( SECTION, "'|\\[{]};:\"\',<>.?/'.match(/.+/)", - String(["|\\[{]};:\"\',<>.?/"]), String('|\\[{]};:\"\',<>.?/'.match(/.+/))); +// '|\\[{]};:"\',<>.?/'.match(/.+/) +new TestCase ( SECTION, "'|\\[{]};:\"\',<>.?/'.match(/.+/)", + String(["|\\[{]};:\"\',<>.?/"]), String('|\\[{]};:\"\',<>.?/'.match(/.+/))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/endLine.js b/mozilla/js/tests/js1_2/regexp/endLine.js index 2b849c6e740..7a13fee32f5 100644 --- a/mozilla/js/tests/js1_2/regexp/endLine.js +++ b/mozilla/js/tests/js1_2/regexp/endLine.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: endLine.js - Description: 'Tests regular expressions containing $' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: endLine.js + Description: 'Tests regular expressions containing $' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: $'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: $'; - writeHeaderToLog('Executing script: endLine.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: endLine.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'abcde'.match(new RegExp('de$')) - testcases[count++] = new TestCase ( SECTION, "'abcde'.match(new RegExp('de$'))", - String(["de"]), String('abcde'.match(new RegExp('de$')))); +// 'abcde'.match(new RegExp('de$')) +new TestCase ( SECTION, "'abcde'.match(new RegExp('de$'))", + String(["de"]), String('abcde'.match(new RegExp('de$')))); - // 'ab\ncde'.match(new RegExp('..$e$')) - testcases[count++] = new TestCase ( SECTION, "'ab\ncde'.match(new RegExp('..$e$'))", - null, 'ab\ncde'.match(new RegExp('..$e$'))); +// 'ab\ncde'.match(new RegExp('..$e$')) +new TestCase ( SECTION, "'ab\ncde'.match(new RegExp('..$e$'))", + null, 'ab\ncde'.match(new RegExp('..$e$'))); - // 'yyyyy'.match(new RegExp('xxx$')) - testcases[count++] = new TestCase ( SECTION, "'yyyyy'.match(new RegExp('xxx$'))", - null, 'yyyyy'.match(new RegExp('xxx$'))); +// 'yyyyy'.match(new RegExp('xxx$')) +new TestCase ( SECTION, "'yyyyy'.match(new RegExp('xxx$'))", + null, 'yyyyy'.match(new RegExp('xxx$'))); - // 'a$$$'.match(new RegExp('\\$+$')) - testcases[count++] = new TestCase ( SECTION, "'a$$$'.match(new RegExp('\\$+$'))", - String(['$$$']), String('a$$$'.match(new RegExp('\\$+$')))); +// 'a$$$'.match(new RegExp('\\$+$')) +new TestCase ( SECTION, "'a$$$'.match(new RegExp('\\$+$'))", + String(['$$$']), String('a$$$'.match(new RegExp('\\$+$')))); - // 'a$$$'.match(/\$+$/) - testcases[count++] = new TestCase ( SECTION, "'a$$$'.match(/\\$+$/)", - String(['$$$']), String('a$$$'.match(/\$+$/))); +// 'a$$$'.match(/\$+$/) +new TestCase ( SECTION, "'a$$$'.match(/\\$+$/)", + String(['$$$']), String('a$$$'.match(/\$+$/))); - RegExp.multiline = true; - // 'abc\n123xyz890\nxyz'.match(new RegExp('\d+$')) <multiline==true> - testcases[count++] = new TestCase ( SECTION, "'abc\n123xyz890\nxyz'.match(new RegExp('\\d+$'))", - String(['890']), String('abc\n123xyz890\nxyz'.match(new RegExp('\\d+$')))); +RegExp.multiline = true; +// 'abc\n123xyz890\nxyz'.match(new RegExp('\d+$')) <multiline==true> +new TestCase ( SECTION, "'abc\n123xyz890\nxyz'.match(new RegExp('\\d+$'))", + String(['890']), String('abc\n123xyz890\nxyz'.match(new RegExp('\\d+$')))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/everything.js b/mozilla/js/tests/js1_2/regexp/everything.js index 60aacc3e1f6..dc474234380 100644 --- a/mozilla/js/tests/js1_2/regexp/everything.js +++ b/mozilla/js/tests/js1_2/regexp/everything.js @@ -35,61 +35,45 @@ * * ***** END LICENSE BLOCK ***** */ /** - Filename: everything.js - Description: 'Tests regular expressions' + Filename: everything.js + Description: 'Tests regular expressions' - Author: Nick Lerissa - Date: March 24, 1998 + Author: Nick Lerissa + Date: March 24, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp'; - writeHeaderToLog('Executing script: everything.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: everything.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'Sally and Fred are sure to come.'.match(/^[a-z\s]*/i) - testcases[count++] = new TestCase ( SECTION, "'Sally and Fred are sure to come'.match(/^[a-z\\s]*/i)", - String(["Sally and Fred are sure to come"]), String('Sally and Fred are sure to come'.match(/^[a-z\s]*/i))); +// 'Sally and Fred are sure to come.'.match(/^[a-z\s]*/i) +new TestCase ( SECTION, "'Sally and Fred are sure to come'.match(/^[a-z\\s]*/i)", + String(["Sally and Fred are sure to come"]), String('Sally and Fred are sure to come'.match(/^[a-z\s]*/i))); - // 'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')) - testcases[count++] = new TestCase ( SECTION, "'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))", - String(["test123W+xyz","xyz"]), String('test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')))); +// 'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')) +new TestCase ( SECTION, "'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))", + String(["test123W+xyz","xyz"]), String('test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')))); - // 'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/) - testcases[count++] = new TestCase ( SECTION, "'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)", - String(["12365 number two 9898","12365","9898"]), String('number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/))); +// 'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/) +new TestCase ( SECTION, "'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)", + String(["12365 number two 9898","12365","9898"]), String('number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/))); - var simpleSentence = /(\s?[^\!\?\.]+[\!\?\.])+/; - // 'See Spot run.'.match(simpleSentence) - testcases[count++] = new TestCase ( SECTION, "'See Spot run.'.match(simpleSentence)", - String(["See Spot run.","See Spot run."]), String('See Spot run.'.match(simpleSentence))); +var simpleSentence = /(\s?[^\!\?\.]+[\!\?\.])+/; +// 'See Spot run.'.match(simpleSentence) +new TestCase ( SECTION, "'See Spot run.'.match(simpleSentence)", + String(["See Spot run.","See Spot run."]), String('See Spot run.'.match(simpleSentence))); - // 'I like it. What's up? I said NO!'.match(simpleSentence) - testcases[count++] = new TestCase ( SECTION, "'I like it. What's up? I said NO!'.match(simpleSentence)", - String(["I like it. What's up? I said NO!",' I said NO!']), String('I like it. What\'s up? I said NO!'.match(simpleSentence))); +// 'I like it. What's up? I said NO!'.match(simpleSentence) +new TestCase ( SECTION, "'I like it. What's up? I said NO!'.match(simpleSentence)", + String(["I like it. What's up? I said NO!",' I said NO!']), String('I like it. What\'s up? I said NO!'.match(simpleSentence))); - // 'the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/) - testcases[count++] = new TestCase ( SECTION, "'the quick brown fox jumped over the lazy dogs'.match(/((\\w+)\\s*)+/)", - String(['the quick brown fox jumped over the lazy dogs','dogs','dogs']),String('the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/))); +// 'the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/) +new TestCase ( SECTION, "'the quick brown fox jumped over the lazy dogs'.match(/((\\w+)\\s*)+/)", + String(['the quick brown fox jumped over the lazy dogs','dogs','dogs']),String('the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/exec.js b/mozilla/js/tests/js1_2/regexp/exec.js index 478b77ce483..9a78a2bae4b 100644 --- a/mozilla/js/tests/js1_2/regexp/exec.js +++ b/mozilla/js/tests/js1_2/regexp/exec.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,59 +35,43 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: exec.js - Description: 'Tests regular expressions exec compile' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: exec.js + Description: 'Tests regular expressions exec compile' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: exec'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: exec'; - writeHeaderToLog('Executing script: exec.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: exec.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +new TestCase ( SECTION, + "/[0-9]{3}/.exec('23 2 34 678 9 09')", + String(["678"]), String(/[0-9]{3}/.exec('23 2 34 678 9 09'))); - testcases[count++] = new TestCase ( SECTION, - "/[0-9]{3}/.exec('23 2 34 678 9 09')", - String(["678"]), String(/[0-9]{3}/.exec('23 2 34 678 9 09'))); +new TestCase ( SECTION, + "/3.{4}8/.exec('23 2 34 678 9 09')", + String(["34 678"]), String(/3.{4}8/.exec('23 2 34 678 9 09'))); - testcases[count++] = new TestCase ( SECTION, - "/3.{4}8/.exec('23 2 34 678 9 09')", - String(["34 678"]), String(/3.{4}8/.exec('23 2 34 678 9 09'))); +var re = new RegExp('3.{4}8'); +new TestCase ( SECTION, + "re.exec('23 2 34 678 9 09')", + String(["34 678"]), String(re.exec('23 2 34 678 9 09'))); - var re = new RegExp('3.{4}8'); - testcases[count++] = new TestCase ( SECTION, - "re.exec('23 2 34 678 9 09')", - String(["34 678"]), String(re.exec('23 2 34 678 9 09'))); +new TestCase ( SECTION, + "(/3.{4}8/.exec('23 2 34 678 9 09').length", + 1, (/3.{4}8/.exec('23 2 34 678 9 09')).length); - testcases[count++] = new TestCase ( SECTION, - "(/3.{4}8/.exec('23 2 34 678 9 09').length", - 1, (/3.{4}8/.exec('23 2 34 678 9 09')).length); +re = new RegExp('3.{4}8'); +new TestCase ( SECTION, + "(re.exec('23 2 34 678 9 09').length", + 1, (re.exec('23 2 34 678 9 09')).length); - re = new RegExp('3.{4}8'); - testcases[count++] = new TestCase ( SECTION, - "(re.exec('23 2 34 678 9 09').length", - 1, (re.exec('23 2 34 678 9 09')).length); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/flags.js b/mozilla/js/tests/js1_2/regexp/flags.js index fe6c3746544..3c781a30d87 100644 --- a/mozilla/js/tests/js1_2/regexp/flags.js +++ b/mozilla/js/tests/js1_2/regexp/flags.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,66 +35,51 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: regexp.js - Description: 'Tests regular expressions using flags "i" and "g"' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: regexp.js + Description: 'Tests regular expressions using flags "i" and "g"' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'regular expression flags with flags "i" and "g"'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'regular expression flags with flags "i" and "g"'; - writeHeaderToLog('Executing script: flags.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); - - // testing optional flag 'i' - testcases[count++] = new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(/fghijk/i)", - String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(/fghijk/i))); - - testcases[count++] = new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(new RegExp('fghijk','i'))", - String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(new RegExp("fghijk","i")))); - - // testing optional flag 'g' - testcases[count++] = new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(/x./g)", - String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(/x./g))); - - testcases[count++] = new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(new RegExp('x.','g'))", - String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(new RegExp('x.','g')))); - - // testing optional flags 'g' and 'i' - testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./gi)", - String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./gi))); - - testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','gi'))", - String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','gi')))); - - testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./ig)", - String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./ig))); - - testcases[count++] = new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','ig'))", - String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','ig')))); +writeHeaderToLog('Executing script: flags.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } +// testing optional flag 'i' +new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(/fghijk/i)", + String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(/fghijk/i))); - test(); +new TestCase ( SECTION, "'aBCdEfGHijKLmno'.match(new RegExp('fghijk','i'))", + String(["fGHijK"]), String('aBCdEfGHijKLmno'.match(new RegExp("fghijk","i")))); + +// testing optional flag 'g' +new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(/x./g)", + String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(/x./g))); + +new TestCase ( SECTION, "'xa xb xc xd xe xf'.match(new RegExp('x.','g'))", + String(["xa","xb","xc","xd","xe","xf"]), String('xa xb xc xd xe xf'.match(new RegExp('x.','g')))); + +// testing optional flags 'g' and 'i' +new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./gi)", + String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./gi))); + +new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','gi'))", + String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','gi')))); + +new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(/x./ig)", + String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(/x./ig))); + +new TestCase ( SECTION, "'xa Xb xc xd Xe xf'.match(new RegExp('x.','ig'))", + String(["xa","Xb","xc","xd","Xe","xf"]), String('xa Xb xc xd Xe xf'.match(new RegExp('x.','ig')))); + + +test(); diff --git a/mozilla/js/tests/js1_2/regexp/global.js b/mozilla/js/tests/js1_2/regexp/global.js index b8e433b8f86..c826dd69723 100644 --- a/mozilla/js/tests/js1_2/regexp/global.js +++ b/mozilla/js/tests/js1_2/regexp/global.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,77 +35,61 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: global.js - Description: 'Tests RegExp attribute global' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: global.js + Description: 'Tests RegExp attribute global' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: global'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: global'; - writeHeaderToLog('Executing script: global.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: global.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// /xyz/g.global +new TestCase ( SECTION, "/xyz/g.global", + true, /xyz/g.global); - // /xyz/g.global - testcases[count++] = new TestCase ( SECTION, "/xyz/g.global", - true, /xyz/g.global); +// /xyz/.global +new TestCase ( SECTION, "/xyz/.global", + false, /xyz/.global); - // /xyz/.global - testcases[count++] = new TestCase ( SECTION, "/xyz/.global", - false, /xyz/.global); +// '123 456 789'.match(/\d+/g) +new TestCase ( SECTION, "'123 456 789'.match(/\\d+/g)", + String(["123","456","789"]), String('123 456 789'.match(/\d+/g))); - // '123 456 789'.match(/\d+/g) - testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/\\d+/g)", - String(["123","456","789"]), String('123 456 789'.match(/\d+/g))); +// '123 456 789'.match(/(\d+)/g) +new TestCase ( SECTION, "'123 456 789'.match(/(\\d+)/g)", + String(["123","456","789"]), String('123 456 789'.match(/(\d+)/g))); - // '123 456 789'.match(/(\d+)/g) - testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/(\\d+)/g)", - String(["123","456","789"]), String('123 456 789'.match(/(\d+)/g))); +// '123 456 789'.match(/\d+/) +new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)", + String(["123"]), String('123 456 789'.match(/\d+/))); - // '123 456 789'.match(/\d+/) - testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(/\\d+/)", - String(["123"]), String('123 456 789'.match(/\d+/))); +// (new RegExp('[a-z]','g')).global +new TestCase ( SECTION, "(new RegExp('[a-z]','g')).global", + true, (new RegExp('[a-z]','g')).global); - // (new RegExp('[a-z]','g')).global - testcases[count++] = new TestCase ( SECTION, "(new RegExp('[a-z]','g')).global", - true, (new RegExp('[a-z]','g')).global); +// (new RegExp('[a-z]','i')).global +new TestCase ( SECTION, "(new RegExp('[a-z]','i')).global", + false, (new RegExp('[a-z]','i')).global); - // (new RegExp('[a-z]','i')).global - testcases[count++] = new TestCase ( SECTION, "(new RegExp('[a-z]','i')).global", - false, (new RegExp('[a-z]','i')).global); +// '123 456 789'.match(new RegExp('\\d+','g')) +new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','g'))", + String(["123","456","789"]), String('123 456 789'.match(new RegExp('\\d+','g')))); - // '123 456 789'.match(new RegExp('\\d+','g')) - testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','g'))", - String(["123","456","789"]), String('123 456 789'.match(new RegExp('\\d+','g')))); +// '123 456 789'.match(new RegExp('(\\d+)','g')) +new TestCase ( SECTION, "'123 456 789'.match(new RegExp('(\\\\d+)','g'))", + String(["123","456","789"]), String('123 456 789'.match(new RegExp('(\\d+)','g')))); - // '123 456 789'.match(new RegExp('(\\d+)','g')) - testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('(\\\\d+)','g'))", - String(["123","456","789"]), String('123 456 789'.match(new RegExp('(\\d+)','g')))); +// '123 456 789'.match(new RegExp('\\d+','i')) +new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','i'))", + String(["123"]), String('123 456 789'.match(new RegExp('\\d+','i')))); - // '123 456 789'.match(new RegExp('\\d+','i')) - testcases[count++] = new TestCase ( SECTION, "'123 456 789'.match(new RegExp('\\\\d+','i'))", - String(["123"]), String('123 456 789'.match(new RegExp('\\d+','i')))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/hexadecimal.js b/mozilla/js/tests/js1_2/regexp/hexadecimal.js index e78d52670a0..13e88176a97 100644 --- a/mozilla/js/tests/js1_2/regexp/hexadecimal.js +++ b/mozilla/js/tests/js1_2/regexp/hexadecimal.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,90 +35,73 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: hexadecimal.js - Description: 'Tests regular expressions containing \<number> ' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: hexadecimal.js + Description: 'Tests regular expressions containing \<number> ' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: \x# (hex) '; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: \x# (hex) '; - writeHeaderToLog('Executing script: hexadecimal.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: hexadecimal.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var testPattern = '\\x41\\x42\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x4B\\x4C\\x4D\\x4E\\x4F\\x50\\x51\\x52\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A'; +var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; - var testPattern = '\\x41\\x42\\x43\\x44\\x45\\x46\\x47\\x48\\x49\\x4A\\x4B\\x4C\\x4D\\x4E\\x4F\\x50\\x51\\x52\\x53\\x54\\x55\\x56\\x57\\x58\\x59\\x5A'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); - var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; +testPattern = '\\x61\\x62\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x6B\\x6C\\x6D\\x6E\\x6F\\x70\\x71\\x72\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7A'; - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); +testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; - testPattern = '\\x61\\x62\\x63\\x64\\x65\\x66\\x67\\x68\\x69\\x6A\\x6B\\x6C\\x6D\\x6E\\x6F\\x70\\x71\\x72\\x73\\x74\\x75\\x76\\x77\\x78\\x79\\x7A'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); - testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; +testPattern = '\\x20\\x21\\x22\\x23\\x24\\x25\\x26\\x27\\x28\\x29\\x2A\\x2B\\x2C\\x2D\\x2E\\x2F\\x30\\x31\\x32\\x33'; - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); +testString = "abc !\"#$%&'()*+,-./0123ZBC"; - testPattern = '\\x20\\x21\\x22\\x23\\x24\\x25\\x26\\x27\\x28\\x29\\x2A\\x2B\\x2C\\x2D\\x2E\\x2F\\x30\\x31\\x32\\x33'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); - testString = "abc !\"#$%&'()*+,-./0123ZBC"; +testPattern = '\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x3B\\x3C\\x3D\\x3E\\x3F\\x40'; - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); +testString = "123456789:;<=>?@ABC"; - testPattern = '\\x34\\x35\\x36\\x37\\x38\\x39\\x3A\\x3B\\x3C\\x3D\\x3E\\x3F\\x40'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); - testString = "123456789:;<=>?@ABC"; +testPattern = '\\x7B\\x7C\\x7D\\x7E'; - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); +testString = "1234{|}~ABC"; - testPattern = '\\x7B\\x7C\\x7D\\x7E'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); - testString = "1234{|}~ABC"; +new TestCase ( SECTION, + "'canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))", + String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\x5A]+')))); - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); +new TestCase ( SECTION, + "'canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))", + String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+')))); - testcases[count++] = new TestCase ( SECTION, - "'canthisbeFOUND'.match(new RegExp('[A-\\x5A]+'))", - String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\x5A]+')))); +new TestCase ( SECTION, + "'canthisbeFOUND'.match(/[\\x61-\\x7A]+/)", + String(["canthisbe"]), String('canthisbeFOUND'.match(/[\x61-\x7A]+/))); - testcases[count++] = new TestCase ( SECTION, - "'canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+'))", - String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\x61-\\x7A]+')))); - - testcases[count++] = new TestCase ( SECTION, - "'canthisbeFOUND'.match(/[\\x61-\\x7A]+/)", - String(["canthisbe"]), String('canthisbeFOUND'.match(/[\x61-\x7A]+/))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/ignoreCase.js b/mozilla/js/tests/js1_2/regexp/ignoreCase.js index 4162d9ea809..0baabbb85a7 100644 --- a/mozilla/js/tests/js1_2/regexp/ignoreCase.js +++ b/mozilla/js/tests/js1_2/regexp/ignoreCase.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,93 +35,78 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: ignoreCase.js - Description: 'Tests RegExp attribute ignoreCase' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: ignoreCase.js + Description: 'Tests RegExp attribute ignoreCase' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: ignoreCase'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: ignoreCase'; - writeHeaderToLog('Executing script: ignoreCase.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: ignoreCase.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // /xyz/i.ignoreCase - testcases[count++] = new TestCase ( SECTION, "/xyz/i.ignoreCase", - true, /xyz/i.ignoreCase); +// /xyz/i.ignoreCase +new TestCase ( SECTION, "/xyz/i.ignoreCase", + true, /xyz/i.ignoreCase); - // /xyz/.ignoreCase - testcases[count++] = new TestCase ( SECTION, "/xyz/.ignoreCase", - false, /xyz/.ignoreCase); +// /xyz/.ignoreCase +new TestCase ( SECTION, "/xyz/.ignoreCase", + false, /xyz/.ignoreCase); - // 'ABC def ghi'.match(/[a-z]+/ig) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/ig)", - String(["ABC","def","ghi"]), String('ABC def ghi'.match(/[a-z]+/ig))); +// 'ABC def ghi'.match(/[a-z]+/ig) +new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/ig)", + String(["ABC","def","ghi"]), String('ABC def ghi'.match(/[a-z]+/ig))); - // 'ABC def ghi'.match(/[a-z]+/i) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/i)", - String(["ABC"]), String('ABC def ghi'.match(/[a-z]+/i))); +// 'ABC def ghi'.match(/[a-z]+/i) +new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/i)", + String(["ABC"]), String('ABC def ghi'.match(/[a-z]+/i))); - // 'ABC def ghi'.match(/([a-z]+)/ig) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/([a-z]+)/ig)", - String(["ABC","def","ghi"]), String('ABC def ghi'.match(/([a-z]+)/ig))); +// 'ABC def ghi'.match(/([a-z]+)/ig) +new TestCase ( SECTION, "'ABC def ghi'.match(/([a-z]+)/ig)", + String(["ABC","def","ghi"]), String('ABC def ghi'.match(/([a-z]+)/ig))); - // 'ABC def ghi'.match(/([a-z]+)/i) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/([a-z]+)/i)", - String(["ABC","ABC"]), String('ABC def ghi'.match(/([a-z]+)/i))); +// 'ABC def ghi'.match(/([a-z]+)/i) +new TestCase ( SECTION, "'ABC def ghi'.match(/([a-z]+)/i)", + String(["ABC","ABC"]), String('ABC def ghi'.match(/([a-z]+)/i))); - // 'ABC def ghi'.match(/[a-z]+/) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/)", - String(["def"]), String('ABC def ghi'.match(/[a-z]+/))); +// 'ABC def ghi'.match(/[a-z]+/) +new TestCase ( SECTION, "'ABC def ghi'.match(/[a-z]+/)", + String(["def"]), String('ABC def ghi'.match(/[a-z]+/))); - // (new RegExp('xyz','i')).ignoreCase - testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz','i')).ignoreCase", - true, (new RegExp('xyz','i')).ignoreCase); +// (new RegExp('xyz','i')).ignoreCase +new TestCase ( SECTION, "(new RegExp('xyz','i')).ignoreCase", + true, (new RegExp('xyz','i')).ignoreCase); - // (new RegExp('xyz')).ignoreCase - testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz')).ignoreCase", - false, (new RegExp('xyz')).ignoreCase); +// (new RegExp('xyz')).ignoreCase +new TestCase ( SECTION, "(new RegExp('xyz')).ignoreCase", + false, (new RegExp('xyz')).ignoreCase); - // 'ABC def ghi'.match(new RegExp('[a-z]+','ig')) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+','ig'))", - String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('[a-z]+','ig')))); +// 'ABC def ghi'.match(new RegExp('[a-z]+','ig')) +new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+','ig'))", + String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('[a-z]+','ig')))); - // 'ABC def ghi'.match(new RegExp('[a-z]+','i')) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+','i'))", - String(["ABC"]), String('ABC def ghi'.match(new RegExp('[a-z]+','i')))); +// 'ABC def ghi'.match(new RegExp('[a-z]+','i')) +new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+','i'))", + String(["ABC"]), String('ABC def ghi'.match(new RegExp('[a-z]+','i')))); - // 'ABC def ghi'.match(new RegExp('([a-z]+)','ig')) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('([a-z]+)','ig'))", - String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','ig')))); +// 'ABC def ghi'.match(new RegExp('([a-z]+)','ig')) +new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('([a-z]+)','ig'))", + String(["ABC","def","ghi"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','ig')))); - // 'ABC def ghi'.match(new RegExp('([a-z]+)','i')) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('([a-z]+)','i'))", - String(["ABC","ABC"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','i')))); +// 'ABC def ghi'.match(new RegExp('([a-z]+)','i')) +new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('([a-z]+)','i'))", + String(["ABC","ABC"]), String('ABC def ghi'.match(new RegExp('([a-z]+)','i')))); - // 'ABC def ghi'.match(new RegExp('[a-z]+')) - testcases[count++] = new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+'))", - String(["def"]), String('ABC def ghi'.match(new RegExp('[a-z]+')))); +// 'ABC def ghi'.match(new RegExp('[a-z]+')) +new TestCase ( SECTION, "'ABC def ghi'.match(new RegExp('[a-z]+'))", + String(["def"]), String('ABC def ghi'.match(new RegExp('[a-z]+')))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/interval.js b/mozilla/js/tests/js1_2/regexp/interval.js index 0504bae2ccd..c8242c9830e 100644 --- a/mozilla/js/tests/js1_2/regexp/interval.js +++ b/mozilla/js/tests/js1_2/regexp/interval.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,97 +35,81 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: interval.js - Description: 'Tests regular expressions containing {}' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: interval.js + Description: 'Tests regular expressions containing {}' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: {}'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: {}'; - writeHeaderToLog('Executing script: interval.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: interval.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c')) +new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c'))", + String(["bbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c')))); - // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c')) - testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c'))", - String(["bbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2}c')))); +// 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}')) +new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}'))", + null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}'))); - // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}')) - testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}'))", - null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8}'))); +// 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c')) +new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c'))", + String(["bbbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c')))); - // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c')) - testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c'))", - String(["bbbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2,}c')))); +// 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c')) +new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c'))", + null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c'))); - // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c')) - testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c'))", - null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{8,}c'))); +// 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c')) +new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c'))", + String(["bbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c')))); - // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c')) - testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c'))", - String(["bbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{2,3}c')))); +// 'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c')) +new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c'))", + null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c'))); - // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c')) - testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c'))", - null, 'aaabbbbcccddeeeefffff'.match(new RegExp('b{42,93}c'))); +// 'aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c')) +new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c'))", + String(["bbbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c')))); - // 'aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c')) - testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c'))", - String(["bbbbc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('b{0,93}c')))); +// 'aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c')) +new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c'))", + String(["bc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c')))); - // 'aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c')) - testcases[count++] = new TestCase ( SECTION, "'aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c'))", - String(["bc"]), String('aaabbbbcccddeeeefffff'.match(new RegExp('bx{0,93}c')))); +// 'weirwerdf'.match(new RegExp('.{0,93}')) +new TestCase ( SECTION, "'weirwerdf'.match(new RegExp('.{0,93}'))", + String(["weirwerdf"]), String('weirwerdf'.match(new RegExp('.{0,93}')))); - // 'weirwerdf'.match(new RegExp('.{0,93}')) - testcases[count++] = new TestCase ( SECTION, "'weirwerdf'.match(new RegExp('.{0,93}'))", - String(["weirwerdf"]), String('weirwerdf'.match(new RegExp('.{0,93}')))); +// 'wqe456646dsff'.match(new RegExp('\d{1,}')) +new TestCase ( SECTION, "'wqe456646dsff'.match(new RegExp('\\d{1,}'))", + String(["456646"]), String('wqe456646dsff'.match(new RegExp('\\d{1,}')))); - // 'wqe456646dsff'.match(new RegExp('\d{1,}')) - testcases[count++] = new TestCase ( SECTION, "'wqe456646dsff'.match(new RegExp('\\d{1,}'))", - String(["456646"]), String('wqe456646dsff'.match(new RegExp('\\d{1,}')))); +// '123123'.match(new RegExp('(123){1,}')) +new TestCase ( SECTION, "'123123'.match(new RegExp('(123){1,}'))", + String(["123123","123"]), String('123123'.match(new RegExp('(123){1,}')))); - // '123123'.match(new RegExp('(123){1,}')) - testcases[count++] = new TestCase ( SECTION, "'123123'.match(new RegExp('(123){1,}'))", - String(["123123","123"]), String('123123'.match(new RegExp('(123){1,}')))); +// '123123x123'.match(new RegExp('(123){1,}x\1')) +new TestCase ( SECTION, "'123123x123'.match(new RegExp('(123){1,}x\\1'))", + String(["123123x123","123"]), String('123123x123'.match(new RegExp('(123){1,}x\\1')))); - // '123123x123'.match(new RegExp('(123){1,}x\1')) - testcases[count++] = new TestCase ( SECTION, "'123123x123'.match(new RegExp('(123){1,}x\\1'))", - String(["123123x123","123"]), String('123123x123'.match(new RegExp('(123){1,}x\\1')))); +// '123123x123'.match(/(123){1,}x\1/) +new TestCase ( SECTION, "'123123x123'.match(/(123){1,}x\\1/)", + String(["123123x123","123"]), String('123123x123'.match(/(123){1,}x\1/))); - // '123123x123'.match(/(123){1,}x\1/) - testcases[count++] = new TestCase ( SECTION, "'123123x123'.match(/(123){1,}x\\1/)", - String(["123123x123","123"]), String('123123x123'.match(/(123){1,}x\1/))); +// 'xxxxxxx'.match(new RegExp('x{1,2}x{1,}')) +new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('x{1,2}x{1,}'))", + String(["xxxxxxx"]), String('xxxxxxx'.match(new RegExp('x{1,2}x{1,}')))); - // 'xxxxxxx'.match(new RegExp('x{1,2}x{1,}')) - testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('x{1,2}x{1,}'))", - String(["xxxxxxx"]), String('xxxxxxx'.match(new RegExp('x{1,2}x{1,}')))); +// 'xxxxxxx'.match(/x{1,2}x{1,}/) +new TestCase ( SECTION, "'xxxxxxx'.match(/x{1,2}x{1,}/)", + String(["xxxxxxx"]), String('xxxxxxx'.match(/x{1,2}x{1,}/))); - // 'xxxxxxx'.match(/x{1,2}x{1,}/) - testcases[count++] = new TestCase ( SECTION, "'xxxxxxx'.match(/x{1,2}x{1,}/)", - String(["xxxxxxx"]), String('xxxxxxx'.match(/x{1,2}x{1,}/))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/octal.js b/mozilla/js/tests/js1_2/regexp/octal.js index a35f78b77c8..518bffb6922 100644 --- a/mozilla/js/tests/js1_2/regexp/octal.js +++ b/mozilla/js/tests/js1_2/regexp/octal.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,90 +35,73 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: octal.js - Description: 'Tests regular expressions containing \<number> ' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: octal.js + Description: 'Tests regular expressions containing \<number> ' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: \# (octal) '; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: \# (octal) '; - writeHeaderToLog('Executing script: octal.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: octal.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var testPattern = '\\101\\102\\103\\104\\105\\106\\107\\110\\111\\112\\113\\114\\115\\116\\117\\120\\121\\122\\123\\124\\125\\126\\127\\130\\131\\132'; +var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; - var testPattern = '\\101\\102\\103\\104\\105\\106\\107\\110\\111\\112\\113\\114\\115\\116\\117\\120\\121\\122\\123\\124\\125\\126\\127\\130\\131\\132'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); - var testString = "12345ABCDEFGHIJKLMNOPQRSTUVWXYZ67890"; +testPattern = '\\141\\142\\143\\144\\145\\146\\147\\150\\151\\152\\153\\154\\155\\156\\157\\160\\161\\162\\163\\164\\165\\166\\167\\170\\171\\172'; - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String(["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]), String(testString.match(new RegExp(testPattern)))); +testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; - testPattern = '\\141\\142\\143\\144\\145\\146\\147\\150\\151\\152\\153\\154\\155\\156\\157\\160\\161\\162\\163\\164\\165\\166\\167\\170\\171\\172'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); - testString = "12345AabcdefghijklmnopqrstuvwxyzZ67890"; +testPattern = '\\40\\41\\42\\43\\44\\45\\46\\47\\50\\51\\52\\53\\54\\55\\56\\57\\60\\61\\62\\63'; - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String(["abcdefghijklmnopqrstuvwxyz"]), String(testString.match(new RegExp(testPattern)))); +testString = "abc !\"#$%&'()*+,-./0123ZBC"; - testPattern = '\\40\\41\\42\\43\\44\\45\\46\\47\\50\\51\\52\\53\\54\\55\\56\\57\\60\\61\\62\\63'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); - testString = "abc !\"#$%&'()*+,-./0123ZBC"; +testPattern = '\\64\\65\\66\\67\\70\\71\\72\\73\\74\\75\\76\\77\\100'; - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String([" !\"#$%&'()*+,-./0123"]), String(testString.match(new RegExp(testPattern)))); +testString = "123456789:;<=>?@ABC"; - testPattern = '\\64\\65\\66\\67\\70\\71\\72\\73\\74\\75\\76\\77\\100'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); - testString = "123456789:;<=>?@ABC"; +testPattern = '\\173\\174\\175\\176'; - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String(["456789:;<=>?@"]), String(testString.match(new RegExp(testPattern)))); +testString = "1234{|}~ABC"; - testPattern = '\\173\\174\\175\\176'; +new TestCase ( SECTION, + "'" + testString + "'.match(new RegExp('" + testPattern + "'))", + String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); - testString = "1234{|}~ABC"; +new TestCase ( SECTION, + "'canthisbeFOUND'.match(new RegExp('[A-\\132]+'))", + String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\132]+')))); - testcases[count++] = new TestCase ( SECTION, - "'" + testString + "'.match(new RegExp('" + testPattern + "'))", - String(["{|}~"]), String(testString.match(new RegExp(testPattern)))); +new TestCase ( SECTION, + "'canthisbeFOUND'.match(new RegExp('[\\141-\\172]+'))", + String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\141-\\172]+')))); - testcases[count++] = new TestCase ( SECTION, - "'canthisbeFOUND'.match(new RegExp('[A-\\132]+'))", - String(["FOUND"]), String('canthisbeFOUND'.match(new RegExp('[A-\\132]+')))); +new TestCase ( SECTION, + "'canthisbeFOUND'.match(/[\\141-\\172]+/)", + String(["canthisbe"]), String('canthisbeFOUND'.match(/[\141-\172]+/))); - testcases[count++] = new TestCase ( SECTION, - "'canthisbeFOUND'.match(new RegExp('[\\141-\\172]+'))", - String(["canthisbe"]), String('canthisbeFOUND'.match(new RegExp('[\\141-\\172]+')))); - - testcases[count++] = new TestCase ( SECTION, - "'canthisbeFOUND'.match(/[\\141-\\172]+/)", - String(["canthisbe"]), String('canthisbeFOUND'.match(/[\141-\172]+/))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/parentheses.js b/mozilla/js/tests/js1_2/regexp/parentheses.js index 44c74182234..66559ef0927 100644 --- a/mozilla/js/tests/js1_2/regexp/parentheses.js +++ b/mozilla/js/tests/js1_2/regexp/parentheses.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,89 +35,73 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: parentheses.js - Description: 'Tests regular expressions containing ()' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: parentheses.js + Description: 'Tests regular expressions containing ()' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: ()'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: ()'; - writeHeaderToLog('Executing script: parentheses.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: parentheses.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abc'.match(new RegExp('(abc)')) +new TestCase ( SECTION, "'abc'.match(new RegExp('(abc)'))", + String(["abc","abc"]), String('abc'.match(new RegExp('(abc)')))); - // 'abc'.match(new RegExp('(abc)')) - testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('(abc)'))", - String(["abc","abc"]), String('abc'.match(new RegExp('(abc)')))); +// 'abcdefg'.match(new RegExp('a(bc)d(ef)g')) +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('a(bc)d(ef)g'))", + String(["abcdefg","bc","ef"]), String('abcdefg'.match(new RegExp('a(bc)d(ef)g')))); - // 'abcdefg'.match(new RegExp('a(bc)d(ef)g')) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('a(bc)d(ef)g'))", - String(["abcdefg","bc","ef"]), String('abcdefg'.match(new RegExp('a(bc)d(ef)g')))); +// 'abcdefg'.match(new RegExp('(.{3})(.{4})')) +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(.{3})(.{4})'))", + String(["abcdefg","abc","defg"]), String('abcdefg'.match(new RegExp('(.{3})(.{4})')))); - // 'abcdefg'.match(new RegExp('(.{3})(.{4})')) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('(.{3})(.{4})'))", - String(["abcdefg","abc","defg"]), String('abcdefg'.match(new RegExp('(.{3})(.{4})')))); +// 'aabcdaabcd'.match(new RegExp('(aa)bcd\1')) +new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(aa)bcd\\1'))", + String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(aa)bcd\\1')))); - // 'aabcdaabcd'.match(new RegExp('(aa)bcd\1')) - testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(aa)bcd\\1'))", - String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(aa)bcd\\1')))); +// 'aabcdaabcd'.match(new RegExp('(aa).+\1')) +new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(aa).+\\1'))", + String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(aa).+\\1')))); - // 'aabcdaabcd'.match(new RegExp('(aa).+\1')) - testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(aa).+\\1'))", - String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(aa).+\\1')))); +// 'aabcdaabcd'.match(new RegExp('(.{2}).+\1')) +new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(.{2}).+\\1'))", + String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(.{2}).+\\1')))); - // 'aabcdaabcd'.match(new RegExp('(.{2}).+\1')) - testcases[count++] = new TestCase ( SECTION, "'aabcdaabcd'.match(new RegExp('(.{2}).+\\1'))", - String(["aabcdaa","aa"]), String('aabcdaabcd'.match(new RegExp('(.{2}).+\\1')))); +// '123456123456'.match(new RegExp('(\d{3})(\d{3})\1\2')) +new TestCase ( SECTION, "'123456123456'.match(new RegExp('(\\d{3})(\\d{3})\\1\\2'))", + String(["123456123456","123","456"]), String('123456123456'.match(new RegExp('(\\d{3})(\\d{3})\\1\\2')))); - // '123456123456'.match(new RegExp('(\d{3})(\d{3})\1\2')) - testcases[count++] = new TestCase ( SECTION, "'123456123456'.match(new RegExp('(\\d{3})(\\d{3})\\1\\2'))", - String(["123456123456","123","456"]), String('123456123456'.match(new RegExp('(\\d{3})(\\d{3})\\1\\2')))); +// 'abcdefg'.match(new RegExp('a(..(..)..)')) +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('a(..(..)..)'))", + String(["abcdefg","bcdefg","de"]), String('abcdefg'.match(new RegExp('a(..(..)..)')))); - // 'abcdefg'.match(new RegExp('a(..(..)..)')) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('a(..(..)..)'))", - String(["abcdefg","bcdefg","de"]), String('abcdefg'.match(new RegExp('a(..(..)..)')))); +// 'abcdefg'.match(/a(..(..)..)/) +new TestCase ( SECTION, "'abcdefg'.match(/a(..(..)..)/)", + String(["abcdefg","bcdefg","de"]), String('abcdefg'.match(/a(..(..)..)/))); - // 'abcdefg'.match(/a(..(..)..)/) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(/a(..(..)..)/)", - String(["abcdefg","bcdefg","de"]), String('abcdefg'.match(/a(..(..)..)/))); +// 'xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))')) +new TestCase ( SECTION, "'xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))'))", + String(["abcdef","abc","bc","c","def","ef","f"]), String('xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))')))); - // 'xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))')) - testcases[count++] = new TestCase ( SECTION, "'xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))'))", - String(["abcdef","abc","bc","c","def","ef","f"]), String('xabcdefg'.match(new RegExp('(a(b(c)))(d(e(f)))')))); +// 'xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\2\5')) +new TestCase ( SECTION, "'xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\\2\\5'))", + String(["abcdefbcef","abc","bc","c","def","ef","f"]), String('xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\\2\\5')))); - // 'xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\2\5')) - testcases[count++] = new TestCase ( SECTION, "'xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\\2\\5'))", - String(["abcdefbcef","abc","bc","c","def","ef","f"]), String('xabcdefbcefg'.match(new RegExp('(a(b(c)))(d(e(f)))\\2\\5')))); +// 'abcd'.match(new RegExp('a(.?)b\1c\1d\1')) +new TestCase ( SECTION, "'abcd'.match(new RegExp('a(.?)b\\1c\\1d\\1'))", + String(["abcd",""]), String('abcd'.match(new RegExp('a(.?)b\\1c\\1d\\1')))); - // 'abcd'.match(new RegExp('a(.?)b\1c\1d\1')) - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('a(.?)b\\1c\\1d\\1'))", - String(["abcd",""]), String('abcd'.match(new RegExp('a(.?)b\\1c\\1d\\1')))); +// 'abcd'.match(/a(.?)b\1c\1d\1/) +new TestCase ( SECTION, "'abcd'.match(/a(.?)b\\1c\\1d\\1/)", + String(["abcd",""]), String('abcd'.match(/a(.?)b\1c\1d\1/))); - // 'abcd'.match(/a(.?)b\1c\1d\1/) - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/a(.?)b\\1c\\1d\\1/)", - String(["abcd",""]), String('abcd'.match(/a(.?)b\1c\1d\1/))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/plus.js b/mozilla/js/tests/js1_2/regexp/plus.js index 0a59be75674..08d2e8dafa5 100644 --- a/mozilla/js/tests/js1_2/regexp/plus.js +++ b/mozilla/js/tests/js1_2/regexp/plus.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,69 +35,53 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: plus.js - Description: 'Tests regular expressions containing +' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: plus.js + Description: 'Tests regular expressions containing +' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: +'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: +'; - writeHeaderToLog('Executing script: plus.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: plus.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abcdddddefg'.match(new RegExp('d+')) +new TestCase ( SECTION, "'abcdddddefg'.match(new RegExp('d+'))", + String(["ddddd"]), String('abcdddddefg'.match(new RegExp('d+')))); - // 'abcdddddefg'.match(new RegExp('d+')) - testcases[count++] = new TestCase ( SECTION, "'abcdddddefg'.match(new RegExp('d+'))", - String(["ddddd"]), String('abcdddddefg'.match(new RegExp('d+')))); +// 'abcdefg'.match(new RegExp('o+')) +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('o+'))", + null, 'abcdefg'.match(new RegExp('o+'))); - // 'abcdefg'.match(new RegExp('o+')) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('o+'))", - null, 'abcdefg'.match(new RegExp('o+'))); +// 'abcdefg'.match(new RegExp('d+')) +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('d+'))", + String(['d']), String('abcdefg'.match(new RegExp('d+')))); - // 'abcdefg'.match(new RegExp('d+')) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.match(new RegExp('d+'))", - String(['d']), String('abcdefg'.match(new RegExp('d+')))); +// 'abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)')) +new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)'))", + String(["bbbbbbb","bbbbb","b","b"]), String('abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)')))); - // 'abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)')) - testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)'))", - String(["bbbbbbb","bbbbb","b","b"]), String('abbbbbbbc'.match(new RegExp('(b+)(b+)(b+)')))); +// 'abbbbbbbc'.match(new RegExp('(b+)(b*)')) +new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('(b+)(b*)'))", + String(["bbbbbbb","bbbbbbb",""]), String('abbbbbbbc'.match(new RegExp('(b+)(b*)')))); - // 'abbbbbbbc'.match(new RegExp('(b+)(b*)')) - testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('(b+)(b*)'))", - String(["bbbbbbb","bbbbbbb",""]), String('abbbbbbbc'.match(new RegExp('(b+)(b*)')))); +// 'abbbbbbbc'.match(new RegExp('b*b+')) +new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('b*b+'))", + String(['bbbbbbb']), String('abbbbbbbc'.match(new RegExp('b*b+')))); - // 'abbbbbbbc'.match(new RegExp('b*b+')) - testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(new RegExp('b*b+'))", - String(['bbbbbbb']), String('abbbbbbbc'.match(new RegExp('b*b+')))); +// 'abbbbbbbc'.match(/(b+)(b*)/) +new TestCase ( SECTION, "'abbbbbbbc'.match(/(b+)(b*)/)", + String(["bbbbbbb","bbbbbbb",""]), String('abbbbbbbc'.match(/(b+)(b*)/))); - // 'abbbbbbbc'.match(/(b+)(b*)/) - testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(/(b+)(b*)/)", - String(["bbbbbbb","bbbbbbb",""]), String('abbbbbbbc'.match(/(b+)(b*)/))); +// 'abbbbbbbc'.match(new RegExp('b*b+')) +new TestCase ( SECTION, "'abbbbbbbc'.match(/b*b+/)", + String(['bbbbbbb']), String('abbbbbbbc'.match(/b*b+/))); - // 'abbbbbbbc'.match(new RegExp('b*b+')) - testcases[count++] = new TestCase ( SECTION, "'abbbbbbbc'.match(/b*b+/)", - String(['bbbbbbb']), String('abbbbbbbc'.match(/b*b+/))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/question_mark.js b/mozilla/js/tests/js1_2/regexp/question_mark.js index 7bff0838722..b1ee21710f2 100644 --- a/mozilla/js/tests/js1_2/regexp/question_mark.js +++ b/mozilla/js/tests/js1_2/regexp/question_mark.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,81 +35,65 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: question_mark.js - Description: 'Tests regular expressions containing ?' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: question_mark.js + Description: 'Tests regular expressions containing ?' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: ?'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: ?'; - writeHeaderToLog('Executing script: question_mark.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: question_mark.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abcdef'.match(new RegExp('cd?e')) +new TestCase ( SECTION, "'abcdef'.match(new RegExp('cd?e'))", + String(["cde"]), String('abcdef'.match(new RegExp('cd?e')))); - // 'abcdef'.match(new RegExp('cd?e')) - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('cd?e'))", - String(["cde"]), String('abcdef'.match(new RegExp('cd?e')))); +// 'abcdef'.match(new RegExp('cdx?e')) +new TestCase ( SECTION, "'abcdef'.match(new RegExp('cdx?e'))", + String(["cde"]), String('abcdef'.match(new RegExp('cdx?e')))); - // 'abcdef'.match(new RegExp('cdx?e')) - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('cdx?e'))", - String(["cde"]), String('abcdef'.match(new RegExp('cdx?e')))); +// 'pqrstuvw'.match(new RegExp('o?pqrst')) +new TestCase ( SECTION, "'pqrstuvw'.match(new RegExp('o?pqrst'))", + String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst')))); - // 'pqrstuvw'.match(new RegExp('o?pqrst')) - testcases[count++] = new TestCase ( SECTION, "'pqrstuvw'.match(new RegExp('o?pqrst'))", - String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst')))); +// 'abcd'.match(new RegExp('x?y?z?')) +new TestCase ( SECTION, "'abcd'.match(new RegExp('x?y?z?'))", + String([""]), String('abcd'.match(new RegExp('x?y?z?')))); - // 'abcd'.match(new RegExp('x?y?z?')) - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('x?y?z?'))", - String([""]), String('abcd'.match(new RegExp('x?y?z?')))); +// 'abcd'.match(new RegExp('x?ay?bz?c')) +new TestCase ( SECTION, "'abcd'.match(new RegExp('x?ay?bz?c'))", + String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c')))); - // 'abcd'.match(new RegExp('x?ay?bz?c')) - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(new RegExp('x?ay?bz?c'))", - String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c')))); +// 'abcd'.match(/x?ay?bz?c/) +new TestCase ( SECTION, "'abcd'.match(/x?ay?bz?c/)", + String(["abc"]), String('abcd'.match(/x?ay?bz?c/))); - // 'abcd'.match(/x?ay?bz?c/) - testcases[count++] = new TestCase ( SECTION, "'abcd'.match(/x?ay?bz?c/)", - String(["abc"]), String('abcd'.match(/x?ay?bz?c/))); +// 'abbbbc'.match(new RegExp('b?b?b?b')) +new TestCase ( SECTION, "'abbbbc'.match(new RegExp('b?b?b?b'))", + String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b')))); - // 'abbbbc'.match(new RegExp('b?b?b?b')) - testcases[count++] = new TestCase ( SECTION, "'abbbbc'.match(new RegExp('b?b?b?b'))", - String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b')))); +// '123az789'.match(new RegExp('ab?c?d?x?y?z')) +new TestCase ( SECTION, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))", + String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z')))); - // '123az789'.match(new RegExp('ab?c?d?x?y?z')) - testcases[count++] = new TestCase ( SECTION, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))", - String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z')))); +// '123az789'.match(/ab?c?d?x?y?z/) +new TestCase ( SECTION, "'123az789'.match(/ab?c?d?x?y?z/)", + String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/))); - // '123az789'.match(/ab?c?d?x?y?z/) - testcases[count++] = new TestCase ( SECTION, "'123az789'.match(/ab?c?d?x?y?z/)", - String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/))); +// '?????'.match(new RegExp('\\??\\??\\??\\??\\??')) +new TestCase ( SECTION, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))", + String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??')))); - // '?????'.match(new RegExp('\\??\\??\\??\\??\\??')) - testcases[count++] = new TestCase ( SECTION, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))", - String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??')))); +// 'test'.match(new RegExp('.?.?.?.?.?.?.?')) +new TestCase ( SECTION, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))", + String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?')))); - // 'test'.match(new RegExp('.?.?.?.?.?.?.?')) - testcases[count++] = new TestCase ( SECTION, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))", - String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?')))); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/regress-6359.js b/mozilla/js/tests/js1_2/regexp/regress-6359.js index 415c8f0ddd1..fb0c51bab35 100644 --- a/mozilla/js/tests/js1_2/regexp/regress-6359.js +++ b/mozilla/js/tests/js1_2/regexp/regress-6359.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -41,43 +42,43 @@ * Author: ** replace with your e-mail address ** */ - var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) - var VERSION = "ECMA_2"; // Version of JavaScript or ECMA - var TITLE = "Regression test for bugzilla # 6359"; // Provide ECMA section title or a description - var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=6359"; // Provide URL to bugsplat or bugzilla report +var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA_2"; // Version of JavaScript or ECMA +var TITLE = "Regression test for bugzilla # 6359"; // Provide ECMA section title or a description +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=6359"; // Provide URL to bugsplat or bugzilla report - startTest(); // leave this alone +startTest(); // leave this alone - /* - * Calls to AddTestCase here. AddTestCase is a function that is defined - * in shell.js and takes three arguments: - * - a string representation of what is being tested - * - the expected result - * - the actual result - * - * For example, a test might look like this: - * - * var zip = /[\d]{5}$/; - * - * AddTestCase( - * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test - * "02134", // expected result - * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result - * - */ +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ - AddTestCase( '/(a*)b\1+/("baaac").length', - 2, - /(a*)b\1+/("baaac").length ); +AddTestCase( '/(a*)b\1+/("baaac").length', + 2, + /(a*)b\1+/("baaac").length ); - AddTestCase( '/(a*)b\1+/("baaac")[0]', - "b", - /(a*)b\1+/("baaac")[0]); +AddTestCase( '/(a*)b\1+/("baaac")[0]', + "b", + /(a*)b\1+/("baaac")[0]); - AddTestCase( '/(a*)b\1+/("baaac")[1]', - "", - /(a*)b\1+/("baaac")[1]); +AddTestCase( '/(a*)b\1+/("baaac")[1]', + "", + /(a*)b\1+/("baaac")[1]); - test(); // leave this alone. this executes the test cases and - // displays results. +test(); // leave this alone. this executes the test cases and +// displays results. diff --git a/mozilla/js/tests/js1_2/regexp/regress-9141.js b/mozilla/js/tests/js1_2/regexp/regress-9141.js index 8f90f6a1a30..209ca3f05dc 100644 --- a/mozilla/js/tests/js1_2/regexp/regress-9141.js +++ b/mozilla/js/tests/js1_2/regexp/regress-9141.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,6 +35,7 @@ * * ***** END LICENSE BLOCK ***** */ + /** * File Name: regress-9141.js * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; @@ -58,44 +60,44 @@ * </BODY> */ - var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) - var VERSION = "ECMA_2"; // Version of JavaScript or ECMA - var TITLE = "Regression test for bugzilla # 9141"; // Provide ECMA section title or a description - var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; // Provide URL to bugsplat or bugzilla report +var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA_2"; // Version of JavaScript or ECMA +var TITLE = "Regression test for bugzilla # 9141"; // Provide ECMA section title or a description +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=9141"; // Provide URL to bugsplat or bugzilla report - startTest(); // leave this alone +startTest(); // leave this alone - /* - * Calls to AddTestCase here. AddTestCase is a function that is defined - * in shell.js and takes three arguments: - * - a string representation of what is being tested - * - the expected result - * - the actual result - * - * For example, a test might look like this: - * - * var zip = /[\d]{5}$/; - * - * AddTestCase( - * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test - * "02134", // expected result - * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result - * - */ +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ - var s = "x"; - for (var i = 0; i != 13; i++) s += s; - var a = /(?:xx|x)*/(s); - var b = /(xx|x)*/(s); +var s = "x"; +for (var i = 0; i != 13; i++) s += s; +var a = /(?:xx|x)*/(s); +var b = /(xx|x)*/(s); - AddTestCase( "var s = 'x'; for (var i = 0; i != 13; i++) s += s; " + - "a = /(?:xx|x)*/(s); a.length", - 1, - a.length ); +AddTestCase( "var s = 'x'; for (var i = 0; i != 13; i++) s += s; " + + "a = /(?:xx|x)*/(s); a.length", + 1, + a.length ); - AddTestCase( "var b = /(xx|x)*/(s); b.length", - 2, - b.length ); +AddTestCase( "var b = /(xx|x)*/(s); b.length", + 2, + b.length ); - test(); // leave this alone. this executes the test cases and - // displays results. +test(); // leave this alone. this executes the test cases and +// displays results. diff --git a/mozilla/js/tests/js1_2/regexp/shell.js b/mozilla/js/tests/js1_2/regexp/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/regexp/simple_form.js b/mozilla/js/tests/js1_2/regexp/simple_form.js index 754bc338446..021091b9807 100644 --- a/mozilla/js/tests/js1_2/regexp/simple_form.js +++ b/mozilla/js/tests/js1_2/regexp/simple_form.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,72 +35,56 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: simple_form.js - Description: 'Tests regular expressions using simple form: re(...)' - Author: Nick Lerissa - Date: March 19, 1998 +/** + Filename: simple_form.js + Description: 'Tests regular expressions using simple form: re(...)' + + Author: Nick Lerissa + Date: March 19, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: simple form'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: simple form'; - writeHeaderToLog('Executing script: simple_form.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: simple_form.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +new TestCase ( SECTION, + "/[0-9]{3}/('23 2 34 678 9 09')", + String(["678"]), String(/[0-9]{3}/('23 2 34 678 9 09'))); - testcases[count++] = new TestCase ( SECTION, - "/[0-9]{3}/('23 2 34 678 9 09')", - String(["678"]), String(/[0-9]{3}/('23 2 34 678 9 09'))); +new TestCase ( SECTION, + "/3.{4}8/('23 2 34 678 9 09')", + String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09'))); - testcases[count++] = new TestCase ( SECTION, - "/3.{4}8/('23 2 34 678 9 09')", - String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09'))); +new TestCase ( SECTION, + "(/3.{4}8/('23 2 34 678 9 09').length", + 1, (/3.{4}8/('23 2 34 678 9 09')).length); - testcases[count++] = new TestCase ( SECTION, - "(/3.{4}8/('23 2 34 678 9 09').length", - 1, (/3.{4}8/('23 2 34 678 9 09')).length); +var re = /[0-9]{3}/; +new TestCase ( SECTION, + "re('23 2 34 678 9 09')", + String(["678"]), String(re('23 2 34 678 9 09'))); - var re = /[0-9]{3}/; - testcases[count++] = new TestCase ( SECTION, - "re('23 2 34 678 9 09')", - String(["678"]), String(re('23 2 34 678 9 09'))); +re = /3.{4}8/; +new TestCase ( SECTION, + "re('23 2 34 678 9 09')", + String(["34 678"]), String(re('23 2 34 678 9 09'))); - re = /3.{4}8/; - testcases[count++] = new TestCase ( SECTION, - "re('23 2 34 678 9 09')", - String(["34 678"]), String(re('23 2 34 678 9 09'))); +new TestCase ( SECTION, + "/3.{4}8/('23 2 34 678 9 09')", + String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09'))); - testcases[count++] = new TestCase ( SECTION, - "/3.{4}8/('23 2 34 678 9 09')", - String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09'))); +re =/3.{4}8/; +new TestCase ( SECTION, + "(re('23 2 34 678 9 09').length", + 1, (re('23 2 34 678 9 09')).length); - re =/3.{4}8/; - testcases[count++] = new TestCase ( SECTION, - "(re('23 2 34 678 9 09').length", - 1, (re('23 2 34 678 9 09')).length); +new TestCase ( SECTION, + "(/3.{4}8/('23 2 34 678 9 09').length", + 1, (/3.{4}8/('23 2 34 678 9 09')).length); - testcases[count++] = new TestCase ( SECTION, - "(/3.{4}8/('23 2 34 678 9 09').length", - 1, (/3.{4}8/('23 2 34 678 9 09')).length); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/source.js b/mozilla/js/tests/js1_2/regexp/source.js index b6b9e32cf2c..e9601215cfc 100644 --- a/mozilla/js/tests/js1_2/regexp/source.js +++ b/mozilla/js/tests/js1_2/regexp/source.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,69 +35,54 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: source.js - Description: 'Tests RegExp attribute source' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: source.js + Description: 'Tests RegExp attribute source' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: source'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: source'; - writeHeaderToLog('Executing script: source.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: source.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // /xyz/g.source - testcases[count++] = new TestCase ( SECTION, "/xyz/g.source", - "xyz", /xyz/g.source); +// /xyz/g.source +new TestCase ( SECTION, "/xyz/g.source", + "xyz", /xyz/g.source); - // /xyz/.source - testcases[count++] = new TestCase ( SECTION, "/xyz/.source", - "xyz", /xyz/.source); +// /xyz/.source +new TestCase ( SECTION, "/xyz/.source", + "xyz", /xyz/.source); - // /abc\\def/.source - testcases[count++] = new TestCase ( SECTION, "/abc\\\\def/.source", - "abc\\\\def", /abc\\def/.source); +// /abc\\def/.source +new TestCase ( SECTION, "/abc\\\\def/.source", + "abc\\\\def", /abc\\def/.source); - // /abc[\b]def/.source - testcases[count++] = new TestCase ( SECTION, "/abc[\\b]def/.source", - "abc[\\b]def", /abc[\b]def/.source); +// /abc[\b]def/.source +new TestCase ( SECTION, "/abc[\\b]def/.source", + "abc[\\b]def", /abc[\b]def/.source); - // (new RegExp('xyz')).source - testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz')).source", - "xyz", (new RegExp('xyz')).source); +// (new RegExp('xyz')).source +new TestCase ( SECTION, "(new RegExp('xyz')).source", + "xyz", (new RegExp('xyz')).source); - // (new RegExp('xyz','g')).source - testcases[count++] = new TestCase ( SECTION, "(new RegExp('xyz','g')).source", - "xyz", (new RegExp('xyz','g')).source); +// (new RegExp('xyz','g')).source +new TestCase ( SECTION, "(new RegExp('xyz','g')).source", + "xyz", (new RegExp('xyz','g')).source); - // (new RegExp('abc\\\\def')).source - testcases[count++] = new TestCase ( SECTION, "(new RegExp('abc\\\\\\\\def')).source", - "abc\\\\def", (new RegExp('abc\\\\def')).source); +// (new RegExp('abc\\\\def')).source +new TestCase ( SECTION, "(new RegExp('abc\\\\\\\\def')).source", + "abc\\\\def", (new RegExp('abc\\\\def')).source); - // (new RegExp('abc[\\b]def')).source - testcases[count++] = new TestCase ( SECTION, "(new RegExp('abc[\\\\b]def')).source", - "abc[\\b]def", (new RegExp('abc[\\b]def')).source); +// (new RegExp('abc[\\b]def')).source +new TestCase ( SECTION, "(new RegExp('abc[\\\\b]def')).source", + "abc[\\b]def", (new RegExp('abc[\\b]def')).source); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/special_characters.js b/mozilla/js/tests/js1_2/regexp/special_characters.js index c3cbf226932..a4db26b023a 100644 --- a/mozilla/js/tests/js1_2/regexp/special_characters.js +++ b/mozilla/js/tests/js1_2/regexp/special_characters.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,139 +35,124 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: special_characters.js - Description: 'Tests regular expressions containing special characters' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: special_characters.js + Description: 'Tests regular expressions containing special characters' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: special_charaters'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: special_charaters'; - writeHeaderToLog('Executing script: special_characters.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: special_characters.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // testing backslash '\' - testcases[count++] = new TestCase ( SECTION, "'^abcdefghi'.match(/\^abc/)", String(["^abc"]), String('^abcdefghi'.match(/\^abc/))); +// testing backslash '\' +new TestCase ( SECTION, "'^abcdefghi'.match(/\^abc/)", String(["^abc"]), String('^abcdefghi'.match(/\^abc/))); - // testing beginning of line '^' - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/^abc/)", String(["abc"]), String('abcdefghi'.match(/^abc/))); +// testing beginning of line '^' +new TestCase ( SECTION, "'abcdefghi'.match(/^abc/)", String(["abc"]), String('abcdefghi'.match(/^abc/))); - // testing end of line '$' - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/fghi$/)", String(["ghi"]), String('abcdefghi'.match(/ghi$/))); +// testing end of line '$' +new TestCase ( SECTION, "'abcdefghi'.match(/fghi$/)", String(["ghi"]), String('abcdefghi'.match(/ghi$/))); - // testing repeat '*' - testcases[count++] = new TestCase ( SECTION, "'eeeefghi'.match(/e*/)", String(["eeee"]), String('eeeefghi'.match(/e*/))); +// testing repeat '*' +new TestCase ( SECTION, "'eeeefghi'.match(/e*/)", String(["eeee"]), String('eeeefghi'.match(/e*/))); - // testing repeat 1 or more times '+' - testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e+/)", String(["eeee"]), String('abcdeeeefghi'.match(/e+/))); +// testing repeat 1 or more times '+' +new TestCase ( SECTION, "'abcdeeeefghi'.match(/e+/)", String(["eeee"]), String('abcdeeeefghi'.match(/e+/))); - // testing repeat 0 or 1 time '?' - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/abc?de/)", String(["abcde"]), String('abcdefghi'.match(/abc?de/))); +// testing repeat 0 or 1 time '?' +new TestCase ( SECTION, "'abcdefghi'.match(/abc?de/)", String(["abcde"]), String('abcdefghi'.match(/abc?de/))); - // testing any character '.' - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/c.e/)", String(["cde"]), String('abcdefghi'.match(/c.e/))); +// testing any character '.' +new TestCase ( SECTION, "'abcdefghi'.match(/c.e/)", String(["cde"]), String('abcdefghi'.match(/c.e/))); - // testing remembering () - testcases[count++] = new TestCase ( SECTION, "'abcewirjskjdabciewjsdf'.match(/(abc).+\\1'/)", - String(["abcewirjskjdabc","abc"]), String('abcewirjskjdabciewjsdf'.match(/(abc).+\1/))); +// testing remembering () +new TestCase ( SECTION, "'abcewirjskjdabciewjsdf'.match(/(abc).+\\1'/)", + String(["abcewirjskjdabc","abc"]), String('abcewirjskjdabciewjsdf'.match(/(abc).+\1/))); - // testing or match '|' - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/xyz|def/)", String(["def"]), String('abcdefghi'.match(/xyz|def/))); +// testing or match '|' +new TestCase ( SECTION, "'abcdefghi'.match(/xyz|def/)", String(["def"]), String('abcdefghi'.match(/xyz|def/))); - // testing repeat n {n} - testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{3}/)", String(["eee"]), String('abcdeeeefghi'.match(/e{3}/))); +// testing repeat n {n} +new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{3}/)", String(["eee"]), String('abcdeeeefghi'.match(/e{3}/))); - // testing min repeat n {n,} - testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{3,}/)", String(["eeee"]), String('abcdeeeefghi'.match(/e{3,}/))); +// testing min repeat n {n,} +new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{3,}/)", String(["eeee"]), String('abcdeeeefghi'.match(/e{3,}/))); - // testing min/max repeat {min, max} - testcases[count++] = new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{2,8}/)", String(["eeee"]), String('abcdeeeefghi'.match(/e{2,8}/))); +// testing min/max repeat {min, max} +new TestCase ( SECTION, "'abcdeeeefghi'.match(/e{2,8}/)", String(["eeee"]), String('abcdeeeefghi'.match(/e{2,8}/))); - // testing any in set [abc...] - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/cd[xey]fgh/)", String(["cdefgh"]), String('abcdefghi'.match(/cd[xey]fgh/))); +// testing any in set [abc...] +new TestCase ( SECTION, "'abcdefghi'.match(/cd[xey]fgh/)", String(["cdefgh"]), String('abcdefghi'.match(/cd[xey]fgh/))); - // testing any in set [a-z] - testcases[count++] = new TestCase ( SECTION, "'netscape inc'.match(/t[r-v]ca/)", String(["tsca"]), String('netscape inc'.match(/t[r-v]ca/))); +// testing any in set [a-z] +new TestCase ( SECTION, "'netscape inc'.match(/t[r-v]ca/)", String(["tsca"]), String('netscape inc'.match(/t[r-v]ca/))); - // testing any not in set [^abc...] - testcases[count++] = new TestCase ( SECTION, "'abcdefghi'.match(/cd[^xy]fgh/)", String(["cdefgh"]), String('abcdefghi'.match(/cd[^xy]fgh/))); +// testing any not in set [^abc...] +new TestCase ( SECTION, "'abcdefghi'.match(/cd[^xy]fgh/)", String(["cdefgh"]), String('abcdefghi'.match(/cd[^xy]fgh/))); - // testing any not in set [^a-z] - testcases[count++] = new TestCase ( SECTION, "'netscape inc'.match(/t[^a-c]ca/)", String(["tsca"]), String('netscape inc'.match(/t[^a-c]ca/))); +// testing any not in set [^a-z] +new TestCase ( SECTION, "'netscape inc'.match(/t[^a-c]ca/)", String(["tsca"]), String('netscape inc'.match(/t[^a-c]ca/))); - // testing backspace [\b] - testcases[count++] = new TestCase ( SECTION, "'this is b\ba test'.match(/is b[\b]a test/)", - String(["is b\ba test"]), String('this is b\ba test'.match(/is b[\b]a test/))); +// testing backspace [\b] +new TestCase ( SECTION, "'this is b\ba test'.match(/is b[\b]a test/)", + String(["is b\ba test"]), String('this is b\ba test'.match(/is b[\b]a test/))); - // testing word boundary \b - testcases[count++] = new TestCase ( SECTION, "'today is now - day is not now'.match(/\bday.*now/)", - String(["day is not now"]), String('today is now - day is not now'.match(/\bday.*now/))); +// testing word boundary \b +new TestCase ( SECTION, "'today is now - day is not now'.match(/\bday.*now/)", + String(["day is not now"]), String('today is now - day is not now'.match(/\bday.*now/))); - // control characters??? +// control characters??? - // testing any digit \d - testcases[count++] = new TestCase ( SECTION, "'a dog - 1 dog'.match(/\d dog/)", String(["1 dog"]), String('a dog - 1 dog'.match(/\d dog/))); +// testing any digit \d +new TestCase ( SECTION, "'a dog - 1 dog'.match(/\d dog/)", String(["1 dog"]), String('a dog - 1 dog'.match(/\d dog/))); - // testing any non digit \d - testcases[count++] = new TestCase ( SECTION, "'a dog - 1 dog'.match(/\D dog/)", String(["a dog"]), String('a dog - 1 dog'.match(/\D dog/))); +// testing any non digit \d +new TestCase ( SECTION, "'a dog - 1 dog'.match(/\D dog/)", String(["a dog"]), String('a dog - 1 dog'.match(/\D dog/))); - // testing form feed '\f' - testcases[count++] = new TestCase ( SECTION, "'a b a\fb'.match(/a\fb/)", String(["a\fb"]), String('a b a\fb'.match(/a\fb/))); +// testing form feed '\f' +new TestCase ( SECTION, "'a b a\fb'.match(/a\fb/)", String(["a\fb"]), String('a b a\fb'.match(/a\fb/))); - // testing line feed '\n' - testcases[count++] = new TestCase ( SECTION, "'a b a\nb'.match(/a\nb/)", String(["a\nb"]), String('a b a\nb'.match(/a\nb/))); +// testing line feed '\n' +new TestCase ( SECTION, "'a b a\nb'.match(/a\nb/)", String(["a\nb"]), String('a b a\nb'.match(/a\nb/))); - // testing carriage return '\r' - testcases[count++] = new TestCase ( SECTION, "'a b a\rb'.match(/a\rb/)", String(["a\rb"]), String('a b a\rb'.match(/a\rb/))); +// testing carriage return '\r' +new TestCase ( SECTION, "'a b a\rb'.match(/a\rb/)", String(["a\rb"]), String('a b a\rb'.match(/a\rb/))); - // testing whitespace '\s' - testcases[count++] = new TestCase ( SECTION, "'xa\f\n\r\t\vbz'.match(/a\s+b/)", String(["a\f\n\r\t\vb"]), String('xa\f\n\r\t\vbz'.match(/a\s+b/))); +// testing whitespace '\s' +new TestCase ( SECTION, "'xa\f\n\r\t\vbz'.match(/a\s+b/)", String(["a\f\n\r\t\vb"]), String('xa\f\n\r\t\vbz'.match(/a\s+b/))); - // testing non whitespace '\S' - testcases[count++] = new TestCase ( SECTION, "'a\tb a b a-b'.match(/a\Sb/)", String(["a-b"]), String('a\tb a b a-b'.match(/a\Sb/))); +// testing non whitespace '\S' +new TestCase ( SECTION, "'a\tb a b a-b'.match(/a\Sb/)", String(["a-b"]), String('a\tb a b a-b'.match(/a\Sb/))); - // testing tab '\t' - testcases[count++] = new TestCase ( SECTION, "'a\t\tb a b'.match(/a\t{2}/)", String(["a\t\t"]), String('a\t\tb a b'.match(/a\t{2}/))); +// testing tab '\t' +new TestCase ( SECTION, "'a\t\tb a b'.match(/a\t{2}/)", String(["a\t\t"]), String('a\t\tb a b'.match(/a\t{2}/))); - // testing vertical tab '\v' - testcases[count++] = new TestCase ( SECTION, "'a\v\vb a b'.match(/a\v{2}/)", String(["a\v\v"]), String('a\v\vb a b'.match(/a\v{2}/))); +// testing vertical tab '\v' +new TestCase ( SECTION, "'a\v\vb a b'.match(/a\v{2}/)", String(["a\v\v"]), String('a\v\vb a b'.match(/a\v{2}/))); - // testing alphnumeric characters '\w' - testcases[count++] = new TestCase ( SECTION, "'%AZaz09_$'.match(/\w+/)", String(["AZaz09_"]), String('%AZaz09_$'.match(/\w+/))); +// testing alphnumeric characters '\w' +new TestCase ( SECTION, "'%AZaz09_$'.match(/\w+/)", String(["AZaz09_"]), String('%AZaz09_$'.match(/\w+/))); - // testing non alphnumeric characters '\W' - testcases[count++] = new TestCase ( SECTION, "'azx$%#@*4534'.match(/\W+/)", String(["$%#@*"]), String('azx$%#@*4534'.match(/\W+/))); +// testing non alphnumeric characters '\W' +new TestCase ( SECTION, "'azx$%#@*4534'.match(/\W+/)", String(["$%#@*"]), String('azx$%#@*4534'.match(/\W+/))); - // testing back references '\<number>' - testcases[count++] = new TestCase ( SECTION, "'test'.match(/(t)es\\1/)", String(["test","t"]), String('test'.match(/(t)es\1/))); +// testing back references '\<number>' +new TestCase ( SECTION, "'test'.match(/(t)es\\1/)", String(["test","t"]), String('test'.match(/(t)es\1/))); - // testing hex excaping with '\' - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/\x63\x64/)", String(["cd"]), String('abcdef'.match(/\x63\x64/))); +// testing hex excaping with '\' +new TestCase ( SECTION, "'abcdef'.match(/\x63\x64/)", String(["cd"]), String('abcdef'.match(/\x63\x64/))); - // testing oct excaping with '\' - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/\\143\\144/)", String(["cd"]), String('abcdef'.match(/\143\144/))); +// testing oct excaping with '\' +new TestCase ( SECTION, "'abcdef'.match(/\\143\\144/)", String(["cd"]), String('abcdef'.match(/\143\144/))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/string_replace.js b/mozilla/js/tests/js1_2/regexp/string_replace.js index 01b8b7e06a0..f315f3a4de9 100644 --- a/mozilla/js/tests/js1_2/regexp/string_replace.js +++ b/mozilla/js/tests/js1_2/regexp/string_replace.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: string_replace.js - Description: 'Tests the replace method on Strings using regular expressions' - Author: Nick Lerissa - Date: March 11, 1998 +/** + Filename: string_replace.js + Description: 'Tests the replace method on Strings using regular expressions' + + Author: Nick Lerissa + Date: March 11, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String: replace'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String: replace'; - writeHeaderToLog('Executing script: string_replace.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); - - // 'adddb'.replace(/ddd/,"XX") - testcases[count++] = new TestCase ( SECTION, "'adddb'.replace(/ddd/,'XX')", - "aXXb", 'adddb'.replace(/ddd/,'XX')); - - // 'adddb'.replace(/eee/,"XX") - testcases[count++] = new TestCase ( SECTION, "'adddb'.replace(/eee/,'XX')", - 'adddb', 'adddb'.replace(/eee/,'XX')); - - // '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**') - testcases[count++] = new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')", - "34 56 ** 12", '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')); - - // '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX') - testcases[count++] = new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')", - "34 56 78b 12", '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')); - - // 'original'.replace(new RegExp(),'XX') - testcases[count++] = new TestCase ( SECTION, "'original'.replace(new RegExp(),'XX')", - "XXoriginal", 'original'.replace(new RegExp(),'XX')); - - // 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\s*\d+(..)$'),'****') - testcases[count++] = new TestCase ( SECTION, "'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')", - "qwe ert ****", 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')); +writeHeaderToLog('Executing script: string_replace.js'); +writeHeaderToLog( SECTION + " "+ TITLE); -function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } +// 'adddb'.replace(/ddd/,"XX") +new TestCase ( SECTION, "'adddb'.replace(/ddd/,'XX')", + "aXXb", 'adddb'.replace(/ddd/,'XX')); - test(); +// 'adddb'.replace(/eee/,"XX") +new TestCase ( SECTION, "'adddb'.replace(/eee/,'XX')", + 'adddb', 'adddb'.replace(/eee/,'XX')); + +// '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**') +new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')", + "34 56 ** 12", '34 56 78b 12'.replace(new RegExp('[0-9]+b'),'**')); + +// '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX') +new TestCase ( SECTION, "'34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')", + "34 56 78b 12", '34 56 78b 12'.replace(new RegExp('[0-9]+c'),'XX')); + +// 'original'.replace(new RegExp(),'XX') +new TestCase ( SECTION, "'original'.replace(new RegExp(),'XX')", + "XXoriginal", 'original'.replace(new RegExp(),'XX')); + +// 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\s*\d+(..)$'),'****') +new TestCase ( SECTION, "'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')", + "qwe ert ****", 'qwe ert x\t\n 345654AB'.replace(new RegExp('x\\s*\\d+(..)$'),'****')); + + +test(); diff --git a/mozilla/js/tests/js1_2/regexp/string_search.js b/mozilla/js/tests/js1_2/regexp/string_search.js index d386ae90a62..d8699ce4058 100644 --- a/mozilla/js/tests/js1_2/regexp/string_search.js +++ b/mozilla/js/tests/js1_2/regexp/string_search.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,69 +35,53 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: string_search.js - Description: 'Tests the search method on Strings using regular expressions' - Author: Nick Lerissa - Date: March 12, 1998 +/** + Filename: string_search.js + Description: 'Tests the search method on Strings using regular expressions' + + Author: Nick Lerissa + Date: March 12, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String: search'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String: search'; - writeHeaderToLog('Executing script: string_search.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: string_search.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// 'abcdefg'.search(/d/) +new TestCase ( SECTION, "'abcdefg'.search(/d/)", + 3, 'abcdefg'.search(/d/)); - // 'abcdefg'.search(/d/) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.search(/d/)", - 3, 'abcdefg'.search(/d/)); +// 'abcdefg'.search(/x/) +new TestCase ( SECTION, "'abcdefg'.search(/x/)", + -1, 'abcdefg'.search(/x/)); - // 'abcdefg'.search(/x/) - testcases[count++] = new TestCase ( SECTION, "'abcdefg'.search(/x/)", - -1, 'abcdefg'.search(/x/)); +// 'abcdefg123456hijklmn'.search(/\d+/) +new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(/\d+/)", + 7, 'abcdefg123456hijklmn'.search(/\d+/)); - // 'abcdefg123456hijklmn'.search(/\d+/) - testcases[count++] = new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(/\d+/)", - 7, 'abcdefg123456hijklmn'.search(/\d+/)); +// 'abcdefg123456hijklmn'.search(new RegExp()) +new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(new RegExp())", + 0, 'abcdefg123456hijklmn'.search(new RegExp())); - // 'abcdefg123456hijklmn'.search(new RegExp()) - testcases[count++] = new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(new RegExp())", - 0, 'abcdefg123456hijklmn'.search(new RegExp())); +// 'abc'.search(new RegExp('$')) +new TestCase ( SECTION, "'abc'.search(new RegExp('$'))", + 3, 'abc'.search(new RegExp('$'))); - // 'abc'.search(new RegExp('$')) - testcases[count++] = new TestCase ( SECTION, "'abc'.search(new RegExp('$'))", - 3, 'abc'.search(new RegExp('$'))); +// 'abc'.search(new RegExp('^')) +new TestCase ( SECTION, "'abc'.search(new RegExp('^'))", + 0, 'abc'.search(new RegExp('^'))); - // 'abc'.search(new RegExp('^')) - testcases[count++] = new TestCase ( SECTION, "'abc'.search(new RegExp('^'))", - 0, 'abc'.search(new RegExp('^'))); +// 'abc1'.search(/.\d/) +new TestCase ( SECTION, "'abc1'.search(/.\d/)", + 2, 'abc1'.search(/.\d/)); - // 'abc1'.search(/.\d/) - testcases[count++] = new TestCase ( SECTION, "'abc1'.search(/.\d/)", - 2, 'abc1'.search(/.\d/)); +// 'abc1'.search(/\d{2}/) +new TestCase ( SECTION, "'abc1'.search(/\d{2}/)", + -1, 'abc1'.search(/\d{2}/)); - // 'abc1'.search(/\d{2}/) - testcases[count++] = new TestCase ( SECTION, "'abc1'.search(/\d{2}/)", - -1, 'abc1'.search(/\d{2}/)); - -function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/string_split.js b/mozilla/js/tests/js1_2/regexp/string_split.js index 7d17a331e9b..62ae2cbc083 100644 --- a/mozilla/js/tests/js1_2/regexp/string_split.js +++ b/mozilla/js/tests/js1_2/regexp/string_split.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,73 +35,58 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: string_split.js - Description: 'Tests the split method on Strings using regular expressions' - Author: Nick Lerissa - Date: March 11, 1998 +/** + Filename: string_split.js + Description: 'Tests the split method on Strings using regular expressions' + + Author: Nick Lerissa + Date: March 11, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'String: split'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'String: split'; - writeHeaderToLog('Executing script: string_split.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: string_split.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'a b c de f'.split(/\s/) - testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/\s/)", - String(["a","b","c","de","f"]), String('a b c de f'.split(/\s/))); +// 'a b c de f'.split(/\s/) +new TestCase ( SECTION, "'a b c de f'.split(/\s/)", + String(["a","b","c","de","f"]), String('a b c de f'.split(/\s/))); - // 'a b c de f'.split(/\s/,3) - testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/\s/,3)", - String(["a","b","c"]), String('a b c de f'.split(/\s/,3))); +// 'a b c de f'.split(/\s/,3) +new TestCase ( SECTION, "'a b c de f'.split(/\s/,3)", + String(["a","b","c"]), String('a b c de f'.split(/\s/,3))); - // 'a b c de f'.split(/X/) - testcases[count++] = new TestCase ( SECTION, "'a b c de f'.split(/X/)", - String(["a b c de f"]), String('a b c de f'.split(/X/))); +// 'a b c de f'.split(/X/) +new TestCase ( SECTION, "'a b c de f'.split(/X/)", + String(["a b c de f"]), String('a b c de f'.split(/X/))); - // 'dfe23iu 34 =+65--'.split(/\d+/) - testcases[count++] = new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(/\d+/)", - String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(/\d+/))); +// 'dfe23iu 34 =+65--'.split(/\d+/) +new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(/\d+/)", + String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(/\d+/))); - // 'dfe23iu 34 =+65--'.split(new RegExp('\d+')) - testcases[count++] = new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(new RegExp('\\d+'))", - String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(new RegExp('\\d+')))); +// 'dfe23iu 34 =+65--'.split(new RegExp('\d+')) +new TestCase ( SECTION, "'dfe23iu 34 =+65--'.split(new RegExp('\\d+'))", + String(["dfe","iu "," =+","--"]), String('dfe23iu 34 =+65--'.split(new RegExp('\\d+')))); - // 'abc'.split(/[a-z]/) - testcases[count++] = new TestCase ( SECTION, "'abc'.split(/[a-z]/)", - String(["","",""]), String('abc'.split(/[a-z]/))); +// 'abc'.split(/[a-z]/) +new TestCase ( SECTION, "'abc'.split(/[a-z]/)", + String(["","",""]), String('abc'.split(/[a-z]/))); - // 'abc'.split(/[a-z]/) - testcases[count++] = new TestCase ( SECTION, "'abc'.split(/[a-z]/)", - String(["","",""]), String('abc'.split(/[a-z]/))); +// 'abc'.split(/[a-z]/) +new TestCase ( SECTION, "'abc'.split(/[a-z]/)", + String(["","",""]), String('abc'.split(/[a-z]/))); - // 'abc'.split(new RegExp('[a-z]')) - testcases[count++] = new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))", - String(["","",""]), String('abc'.split(new RegExp('[a-z]')))); +// 'abc'.split(new RegExp('[a-z]')) +new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))", + String(["","",""]), String('abc'.split(new RegExp('[a-z]')))); - // 'abc'.split(new RegExp('[a-z]')) - testcases[count++] = new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))", - String(["","",""]), String('abc'.split(new RegExp('[a-z]')))); +// 'abc'.split(new RegExp('[a-z]')) +new TestCase ( SECTION, "'abc'.split(new RegExp('[a-z]'))", + String(["","",""]), String('abc'.split(new RegExp('[a-z]')))); -function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/test.js b/mozilla/js/tests/js1_2/regexp/test.js index 3bc7d625e38..cd6f53e345b 100644 --- a/mozilla/js/tests/js1_2/regexp/test.js +++ b/mozilla/js/tests/js1_2/regexp/test.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,69 +35,53 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: test.js - Description: 'Tests regular expressions method compile' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: test.js + Description: 'Tests regular expressions method compile' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: test'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: test'; - writeHeaderToLog('Executing script: test.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: test.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +new TestCase ( SECTION, + "/[0-9]{3}/.test('23 2 34 678 9 09')", + true, /[0-9]{3}/.test('23 2 34 678 9 09')); - testcases[count++] = new TestCase ( SECTION, - "/[0-9]{3}/.test('23 2 34 678 9 09')", - true, /[0-9]{3}/.test('23 2 34 678 9 09')); +new TestCase ( SECTION, + "/[0-9]{3}/.test('23 2 34 78 9 09')", + false, /[0-9]{3}/.test('23 2 34 78 9 09')); - testcases[count++] = new TestCase ( SECTION, - "/[0-9]{3}/.test('23 2 34 78 9 09')", - false, /[0-9]{3}/.test('23 2 34 78 9 09')); +new TestCase ( SECTION, + "/\w+ \w+ \w+/.test('do a test')", + true, /\w+ \w+ \w+/.test("do a test")); - testcases[count++] = new TestCase ( SECTION, - "/\w+ \w+ \w+/.test('do a test')", - true, /\w+ \w+ \w+/.test("do a test")); +new TestCase ( SECTION, + "/\w+ \w+ \w+/.test('a test')", + false, /\w+ \w+ \w+/.test("a test")); - testcases[count++] = new TestCase ( SECTION, - "/\w+ \w+ \w+/.test('a test')", - false, /\w+ \w+ \w+/.test("a test")); +new TestCase ( SECTION, + "(new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')", + true, (new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')); - testcases[count++] = new TestCase ( SECTION, - "(new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')", - true, (new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')); +new TestCase ( SECTION, + "(new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')", + false, (new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')); - testcases[count++] = new TestCase ( SECTION, - "(new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')", - false, (new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')); +new TestCase ( SECTION, + "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('do a test')", + true, (new RegExp('\\w+ \\w+ \\w+')).test("do a test")); - testcases[count++] = new TestCase ( SECTION, - "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('do a test')", - true, (new RegExp('\\w+ \\w+ \\w+')).test("do a test")); +new TestCase ( SECTION, + "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('a test')", + false, (new RegExp('\\w+ \\w+ \\w+')).test("a test")); - testcases[count++] = new TestCase ( SECTION, - "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('a test')", - false, (new RegExp('\\w+ \\w+ \\w+')).test("a test")); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/toString.js b/mozilla/js/tests/js1_2/regexp/toString.js index 64182009cf9..46ba509ba1d 100644 --- a/mozilla/js/tests/js1_2/regexp/toString.js +++ b/mozilla/js/tests/js1_2/regexp/toString.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,60 +35,45 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: toString.js - Description: 'Tests RegExp method toString' - Author: Nick Lerissa - Date: March 13, 1998 +/** + Filename: toString.js + Description: 'Tests RegExp method toString' + + Author: Nick Lerissa + Date: March 13, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: toString'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: toString'; - writeHeaderToLog('Executing script: toString.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: toString.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - /* - * var re = new RegExp(); re.toString() For what to expect, - * see http://bugzilla.mozilla.org/show_bug.cgi?id=225343#c7 - */ - var re = new RegExp(); - testcases[count++] = new TestCase ( SECTION, "var re = new RegExp(); re.toString()", - '/(?:)/', re.toString()); +/* + * var re = new RegExp(); re.toString() For what to expect, + * see http://bugzilla.mozilla.org/show_bug.cgi?id=225343#c7 + */ +var re = new RegExp(); +new TestCase ( SECTION, "var re = new RegExp(); re.toString()", + '/(?:)/', re.toString()); - // re = /.+/; re.toString(); - re = /.+/; - testcases[count++] = new TestCase ( SECTION, "re = /.+/; re.toString()", - '/.+/', re.toString()); +// re = /.+/; re.toString(); +re = /.+/; +new TestCase ( SECTION, "re = /.+/; re.toString()", + '/.+/', re.toString()); - // re = /test/gi; re.toString() - re = /test/gi; - testcases[count++] = new TestCase ( SECTION, "re = /test/gi; re.toString()", - '/test/gi', re.toString()); +// re = /test/gi; re.toString() +re = /test/gi; +new TestCase ( SECTION, "re = /test/gi; re.toString()", + '/test/gi', re.toString()); - // re = /test2/ig; re.toString() - re = /test2/ig; - testcases[count++] = new TestCase ( SECTION, "re = /test2/ig; re.toString()", - '/test2/gi', re.toString()); +// re = /test2/ig; re.toString() +re = /test2/ig; +new TestCase ( SECTION, "re = /test2/ig; re.toString()", + '/test2/gi', re.toString()); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/vertical_bar.js b/mozilla/js/tests/js1_2/regexp/vertical_bar.js index e660643f7fe..94b9a3fe5af 100644 --- a/mozilla/js/tests/js1_2/regexp/vertical_bar.js +++ b/mozilla/js/tests/js1_2/regexp/vertical_bar.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,77 +35,62 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: vertical_bar.js - Description: 'Tests regular expressions containing |' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: vertical_bar.js + Description: 'Tests regular expressions containing |' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: |'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: |'; - writeHeaderToLog('Executing script: vertical_bar.js'); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog('Executing script: vertical_bar.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - // 'abc'.match(new RegExp('xyz|abc')) - testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|abc'))", - String(["abc"]), String('abc'.match(new RegExp('xyz|abc')))); +// 'abc'.match(new RegExp('xyz|abc')) +new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|abc'))", + String(["abc"]), String('abc'.match(new RegExp('xyz|abc')))); - // 'this is a test'.match(new RegExp('quiz|exam|test|homework')) - testcases[count++] = new TestCase ( SECTION, "'this is a test'.match(new RegExp('quiz|exam|test|homework'))", - String(["test"]), String('this is a test'.match(new RegExp('quiz|exam|test|homework')))); +// 'this is a test'.match(new RegExp('quiz|exam|test|homework')) +new TestCase ( SECTION, "'this is a test'.match(new RegExp('quiz|exam|test|homework'))", + String(["test"]), String('this is a test'.match(new RegExp('quiz|exam|test|homework')))); - // 'abc'.match(new RegExp('xyz|...')) - testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|...'))", - String(["abc"]), String('abc'.match(new RegExp('xyz|...')))); +// 'abc'.match(new RegExp('xyz|...')) +new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|...'))", + String(["abc"]), String('abc'.match(new RegExp('xyz|...')))); - // 'abc'.match(new RegExp('(.)..|abc')) - testcases[count++] = new TestCase ( SECTION, "'abc'.match(new RegExp('(.)..|abc'))", - String(["abc","a"]), String('abc'.match(new RegExp('(.)..|abc')))); +// 'abc'.match(new RegExp('(.)..|abc')) +new TestCase ( SECTION, "'abc'.match(new RegExp('(.)..|abc'))", + String(["abc","a"]), String('abc'.match(new RegExp('(.)..|abc')))); - // 'color: grey'.match(new RegExp('.+: gr(a|e)y')) - testcases[count++] = new TestCase ( SECTION, "'color: grey'.match(new RegExp('.+: gr(a|e)y'))", - String(["color: grey","e"]), String('color: grey'.match(new RegExp('.+: gr(a|e)y')))); +// 'color: grey'.match(new RegExp('.+: gr(a|e)y')) +new TestCase ( SECTION, "'color: grey'.match(new RegExp('.+: gr(a|e)y'))", + String(["color: grey","e"]), String('color: grey'.match(new RegExp('.+: gr(a|e)y')))); - // 'no match'.match(new RegExp('red|white|blue')) - testcases[count++] = new TestCase ( SECTION, "'no match'.match(new RegExp('red|white|blue'))", - null, 'no match'.match(new RegExp('red|white|blue'))); +// 'no match'.match(new RegExp('red|white|blue')) +new TestCase ( SECTION, "'no match'.match(new RegExp('red|white|blue'))", + null, 'no match'.match(new RegExp('red|white|blue'))); - // 'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)')) - testcases[count++] = new TestCase ( SECTION, "'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))", - String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)')))); +// 'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)')) +new TestCase ( SECTION, "'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))", + String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)')))); - // 'abcdef'.match(new RegExp('abc|bcd|cde|def')) - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(new RegExp('abc|bcd|cde|def'))", - String(["abc"]), String('abcdef'.match(new RegExp('abc|bcd|cde|def')))); +// 'abcdef'.match(new RegExp('abc|bcd|cde|def')) +new TestCase ( SECTION, "'abcdef'.match(new RegExp('abc|bcd|cde|def'))", + String(["abc"]), String('abcdef'.match(new RegExp('abc|bcd|cde|def')))); - // 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/) - testcases[count++] = new TestCase ( SECTION, "'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)", - String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/))); +// 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/) +new TestCase ( SECTION, "'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)", + String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/))); - // 'abcdef'.match(/abc|bcd|cde|def/) - testcases[count++] = new TestCase ( SECTION, "'abcdef'.match(/abc|bcd|cde|def/)", - String(["abc"]), String('abcdef'.match(/abc|bcd|cde|def/))); +// 'abcdef'.match(/abc|bcd|cde|def/) +new TestCase ( SECTION, "'abcdef'.match(/abc|bcd|cde|def/)", + String(["abc"]), String('abcdef'.match(/abc|bcd|cde|def/))); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/regexp/whitespace.js b/mozilla/js/tests/js1_2/regexp/whitespace.js index 636bd1da113..ed80cdd7c9a 100644 --- a/mozilla/js/tests/js1_2/regexp/whitespace.js +++ b/mozilla/js/tests/js1_2/regexp/whitespace.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,104 +35,89 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: whitespace.js - Description: 'Tests regular expressions containing \f\n\r\t\v\s\S\ ' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: whitespace.js + Description: 'Tests regular expressions containing \f\n\r\t\v\s\S\ ' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: \\f\\n\\r\\t\\v\\s\\S '; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: \\f\\n\\r\\t\\v\\s\\S '; - writeHeaderToLog('Executing script: whitespace.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); - - var non_whitespace = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()-+={[}]|\\:;'<,>./?1234567890" + '"'; - var whitespace = "\f\n\r\t\v "; - - // be sure all whitespace is matched by \s - testcases[count++] = new TestCase ( SECTION, - "'" + whitespace + "'.match(new RegExp('\\s+'))", - String([whitespace]), String(whitespace.match(new RegExp('\\s+')))); - - // be sure all non-whitespace is matched by \S - testcases[count++] = new TestCase ( SECTION, - "'" + non_whitespace + "'.match(new RegExp('\\S+'))", - String([non_whitespace]), String(non_whitespace.match(new RegExp('\\S+')))); - - // be sure all non-whitespace is not matched by \s - testcases[count++] = new TestCase ( SECTION, - "'" + non_whitespace + "'.match(new RegExp('\\s'))", - null, non_whitespace.match(new RegExp('\\s'))); - - // be sure all whitespace is not matched by \S - testcases[count++] = new TestCase ( SECTION, - "'" + whitespace + "'.match(new RegExp('\\S'))", - null, whitespace.match(new RegExp('\\S'))); - - var s = non_whitespace + whitespace; - - // be sure all digits are matched by \s - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\s+'))", - String([whitespace]), String(s.match(new RegExp('\\s+')))); - - s = whitespace + non_whitespace; - - // be sure all non-whitespace are matched by \S - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\S+'))", - String([non_whitespace]), String(s.match(new RegExp('\\S+')))); - - // '1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+')) - testcases[count++] = new TestCase ( SECTION, "'1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+'))", - String(["find me"]), String('1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+')))); - - var i; - - // be sure all whitespace characters match individually - for (i = 0; i < whitespace.length; ++i) - { - s = 'ab' + whitespace[i] + 'cd'; - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\\\s'))", - String([whitespace[i]]), String(s.match(new RegExp('\\s')))); - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/\s/)", - String([whitespace[i]]), String(s.match(/\s/))); - } - // be sure all non_whitespace characters match individually - for (i = 0; i < non_whitespace.length; ++i) - { - s = ' ' + non_whitespace[i] + ' '; - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\\\S'))", - String([non_whitespace[i]]), String(s.match(new RegExp('\\S')))); - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/\S/)", - String([non_whitespace[i]]), String(s.match(/\S/))); - } +writeHeaderToLog('Executing script: whitespace.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } +var non_whitespace = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&*()-+={[}]|\\:;'<,>./?1234567890" + '"'; +var whitespace = "\f\n\r\t\v "; - test(); +// be sure all whitespace is matched by \s +new TestCase ( SECTION, + "'" + whitespace + "'.match(new RegExp('\\s+'))", + String([whitespace]), String(whitespace.match(new RegExp('\\s+')))); + +// be sure all non-whitespace is matched by \S +new TestCase ( SECTION, + "'" + non_whitespace + "'.match(new RegExp('\\S+'))", + String([non_whitespace]), String(non_whitespace.match(new RegExp('\\S+')))); + +// be sure all non-whitespace is not matched by \s +new TestCase ( SECTION, + "'" + non_whitespace + "'.match(new RegExp('\\s'))", + null, non_whitespace.match(new RegExp('\\s'))); + +// be sure all whitespace is not matched by \S +new TestCase ( SECTION, + "'" + whitespace + "'.match(new RegExp('\\S'))", + null, whitespace.match(new RegExp('\\S'))); + +var s = non_whitespace + whitespace; + +// be sure all digits are matched by \s +new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\s+'))", + String([whitespace]), String(s.match(new RegExp('\\s+')))); + +s = whitespace + non_whitespace; + +// be sure all non-whitespace are matched by \S +new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\S+'))", + String([non_whitespace]), String(s.match(new RegExp('\\S+')))); + +// '1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+')) +new TestCase ( SECTION, "'1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+'))", + String(["find me"]), String('1233345find me345'.match(new RegExp('[a-z\\s][a-z\\s]+')))); + +var i; + +// be sure all whitespace characters match individually +for (i = 0; i < whitespace.length; ++i) +{ + s = 'ab' + whitespace[i] + 'cd'; + new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\\\s'))", + String([whitespace[i]]), String(s.match(new RegExp('\\s')))); + new TestCase ( SECTION, + "'" + s + "'.match(/\s/)", + String([whitespace[i]]), String(s.match(/\s/))); +} +// be sure all non_whitespace characters match individually +for (i = 0; i < non_whitespace.length; ++i) +{ + s = ' ' + non_whitespace[i] + ' '; + new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\\\S'))", + String([non_whitespace[i]]), String(s.match(new RegExp('\\S')))); + new TestCase ( SECTION, + "'" + s + "'.match(/\S/)", + String([non_whitespace[i]]), String(s.match(/\S/))); +} + + +test(); diff --git a/mozilla/js/tests/js1_2/regexp/word_boundary.js b/mozilla/js/tests/js1_2/regexp/word_boundary.js index a1ed3eb2918..682841f1598 100644 --- a/mozilla/js/tests/js1_2/regexp/word_boundary.js +++ b/mozilla/js/tests/js1_2/regexp/word_boundary.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,101 +35,85 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: word_boundary.js - Description: 'Tests regular expressions containing \b and \B' - Author: Nick Lerissa - Date: March 10, 1998 +/** + Filename: word_boundary.js + Description: 'Tests regular expressions containing \b and \B' + + Author: Nick Lerissa + Date: March 10, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'RegExp: \\b and \\B'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'RegExp: \\b and \\B'; - writeHeaderToLog('Executing script: word_boundary.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); - - // 'cowboy boyish boy'.match(new RegExp('\bboy\b')) - testcases[count++] = new TestCase ( SECTION, "'cowboy boyish boy'.match(new RegExp('\\bboy\\b'))", - String(["boy"]), String('cowboy boyish boy'.match(new RegExp('\\bboy\\b')))); - - var boundary_characters = "\f\n\r\t\v~`!@#$%^&*()-+={[}]|\\:;'<,>./? " + '"'; - var non_boundary_characters = '1234567890_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - var s = ''; - var i; - - // testing whether all boundary characters are matched when they should be - for (i = 0; i < boundary_characters.length; ++i) - { - s = '123ab' + boundary_characters.charAt(i) + '123c' + boundary_characters.charAt(i); - - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\b123[a-z]\\b'))", - String(["123c"]), String(s.match(new RegExp('\\b123[a-z]\\b')))); - } - - // testing whether all non-boundary characters are matched when they should be - for (i = 0; i < non_boundary_characters.length; ++i) - { - s = '123ab' + non_boundary_characters.charAt(i) + '123c' + non_boundary_characters.charAt(i); - - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\B123[a-z]\\B'))", - String(["123c"]), String(s.match(new RegExp('\\B123[a-z]\\B')))); - } - - s = ''; - - // testing whether all boundary characters are not matched when they should not be - for (i = 0; i < boundary_characters.length; ++i) - { - s += boundary_characters[i] + "a" + i + "b"; - } - s += "xa1111bx"; - - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\Ba\\d+b\\B'))", - String(["a1111b"]), String(s.match(new RegExp('\\Ba\\d+b\\B')))); - - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/\\Ba\\d+b\\B/)", - String(["a1111b"]), String(s.match(/\Ba\d+b\B/))); - - s = ''; - - // testing whether all non-boundary characters are not matched when they should not be - for (i = 0; i < non_boundary_characters.length; ++i) - { - s += non_boundary_characters[i] + "a" + i + "b"; - } - s += "(a1111b)"; - - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(new RegExp('\\ba\\d+b\\b'))", - String(["a1111b"]), String(s.match(new RegExp('\\ba\\d+b\\b')))); - - testcases[count++] = new TestCase ( SECTION, - "'" + s + "'.match(/\\ba\\d+b\\b/)", - String(["a1111b"]), String(s.match(/\ba\d+b\b/))); +writeHeaderToLog('Executing script: word_boundary.js'); +writeHeaderToLog( SECTION + " "+ TITLE); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } +// 'cowboy boyish boy'.match(new RegExp('\bboy\b')) +new TestCase ( SECTION, "'cowboy boyish boy'.match(new RegExp('\\bboy\\b'))", + String(["boy"]), String('cowboy boyish boy'.match(new RegExp('\\bboy\\b')))); - test(); +var boundary_characters = "\f\n\r\t\v~`!@#$%^&*()-+={[}]|\\:;'<,>./? " + '"'; +var non_boundary_characters = '1234567890_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; +var s = ''; +var i; + +// testing whether all boundary characters are matched when they should be +for (i = 0; i < boundary_characters.length; ++i) +{ + s = '123ab' + boundary_characters.charAt(i) + '123c' + boundary_characters.charAt(i); + + new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\b123[a-z]\\b'))", + String(["123c"]), String(s.match(new RegExp('\\b123[a-z]\\b')))); +} + +// testing whether all non-boundary characters are matched when they should be +for (i = 0; i < non_boundary_characters.length; ++i) +{ + s = '123ab' + non_boundary_characters.charAt(i) + '123c' + non_boundary_characters.charAt(i); + + new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\B123[a-z]\\B'))", + String(["123c"]), String(s.match(new RegExp('\\B123[a-z]\\B')))); +} + +s = ''; + +// testing whether all boundary characters are not matched when they should not be +for (i = 0; i < boundary_characters.length; ++i) +{ + s += boundary_characters[i] + "a" + i + "b"; +} +s += "xa1111bx"; + +new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\Ba\\d+b\\B'))", + String(["a1111b"]), String(s.match(new RegExp('\\Ba\\d+b\\B')))); + +new TestCase ( SECTION, + "'" + s + "'.match(/\\Ba\\d+b\\B/)", + String(["a1111b"]), String(s.match(/\Ba\d+b\B/))); + +s = ''; + +// testing whether all non-boundary characters are not matched when they should not be +for (i = 0; i < non_boundary_characters.length; ++i) +{ + s += non_boundary_characters[i] + "a" + i + "b"; +} +s += "(a1111b)"; + +new TestCase ( SECTION, + "'" + s + "'.match(new RegExp('\\ba\\d+b\\b'))", + String(["a1111b"]), String(s.match(new RegExp('\\ba\\d+b\\b')))); + +new TestCase ( SECTION, + "'" + s + "'.match(/\\ba\\d+b\\b/)", + String(["a1111b"]), String(s.match(/\ba\d+b\b/))); + +test(); diff --git a/mozilla/js/tests/js1_2/regress/browser.js b/mozilla/js/tests/js1_2/regress/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/regress/regress-144834.js b/mozilla/js/tests/js1_2/regress/regress-144834.js index e9b8ce1edc8..9375388cdda 100644 --- a/mozilla/js/tests/js1_2/regress/regress-144834.js +++ b/mozilla/js/tests/js1_2/regress/regress-144834.js @@ -47,8 +47,8 @@ var bug = 144834; var summary = 'Local var having same name as switch label inside function'; -print(bug); -print(summary); +writeLineToLog(bug); +writeLineToLog(summary); function RedrawSched() diff --git a/mozilla/js/tests/js1_2/regress/regress-7703.js b/mozilla/js/tests/js1_2/regress/regress-7703.js index 1796e0a3945..b29174b7080 100644 --- a/mozilla/js/tests/js1_2/regress/regress-7703.js +++ b/mozilla/js/tests/js1_2/regress/regress-7703.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,65 +35,66 @@ * * ***** END LICENSE BLOCK ***** */ + /** * File Name: regress-7703.js * Reference: "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; * Description: See the text of the bugnumber above */ - var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) - var VERSION = "JS1_2"; // Version of JavaScript or ECMA - var TITLE = "Regression test for bugzilla # 7703"; // Provide ECMA section title or a description - var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; // Provide URL to bugsplat or bugzilla report +var SECTION = "js1_2"; // provide a document reference (ie, ECMA section) +var VERSION = "JS1_2"; // Version of JavaScript or ECMA +var TITLE = "Regression test for bugzilla # 7703"; // Provide ECMA section title or a description +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7703"; // Provide URL to bugsplat or bugzilla report - startTest(); // leave this alone +startTest(); // leave this alone - /* - * Calls to AddTestCase here. AddTestCase is a function that is defined - * in shell.js and takes three arguments: - * - a string representation of what is being tested - * - the expected result - * - the actual result - * - * For example, a test might look like this: - * - * var zip = /[\d]{5}$/; - * - * AddTestCase( - * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test - * "02134", // expected result - * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result - * - */ +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ - types = []; - function inspect(object) { - for (prop in object) { - var x = object[prop]; - types[types.length] = (typeof x); - } +types = []; +function inspect(object) { + for (prop in object) { + var x = object[prop]; + types[types.length] = (typeof x); } +} - var o = {a: 1, b: 2}; - inspect(o); +var o = {a: 1, b: 2}; +inspect(o); - AddTestCase( "inspect(o),length", 2, types.length ); - AddTestCase( "inspect(o)[0]", "number", types[0] ); - AddTestCase( "inspect(o)[1]", "number", types[1] ); +AddTestCase( "inspect(o),length", 2, types.length ); +AddTestCase( "inspect(o)[0]", "number", types[0] ); +AddTestCase( "inspect(o)[1]", "number", types[1] ); - types_2 = []; +types_2 = []; - function inspect_again(object) { - for (prop in object) { - types_2[types_2.length] = (typeof object[prop]); - } +function inspect_again(object) { + for (prop in object) { + types_2[types_2.length] = (typeof object[prop]); } +} - inspect_again(o); - AddTestCase( "inspect_again(o),length", 2, types.length ); - AddTestCase( "inspect_again(o)[0]", "number", types[0] ); - AddTestCase( "inspect_again(o)[1]", "number", types[1] ); +inspect_again(o); +AddTestCase( "inspect_again(o),length", 2, types.length ); +AddTestCase( "inspect_again(o)[0]", "number", types[0] ); +AddTestCase( "inspect_again(o)[1]", "number", types[1] ); - test(); // leave this alone. this executes the test cases and - // displays results. +test(); // leave this alone. this executes the test cases and +// displays results. diff --git a/mozilla/js/tests/js1_2/regress/shell.js b/mozilla/js/tests/js1_2/regress/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/shell.js b/mozilla/js/tests/js1_2/shell.js index d6ea14f2bbc..d66b26eebce 100644 --- a/mozilla/js/tests/js1_2/shell.js +++ b/mozilla/js/tests/js1_2/shell.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -35,98 +36,128 @@ * * ***** END LICENSE BLOCK ***** */ var completed = false; -var testcases; +var testcases = new Array(); +var tc = testcases.length; var SECTION = ""; var VERSION = ""; var BUGNUMBER = ""; +/* + * constant strings + */ var GLOBAL = "[object global]"; var PASSED = " PASSED!" var FAILED = " FAILED! expected: "; -startTest(); +var DEBUG = false; - version(120); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +if (typeof version != "undefined") { + version(120); } -/* wrapper for test cas constructor that doesn't require the SECTION + +/* + * wrapper for test case constructor that doesn't require the SECTION * argument. */ function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); + new TestCase( SECTION, description, expect, actual ); } function TestCase( n, d, e, a ) { - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; - this.passed = getTestCaseResult( this.expect, this.actual ); + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } + /* + * testcases are solely maintained in the TestCase + * constructor. tc will _always_ point to one past the + * last testcase. If an exception occurs during the call + * to the constructor, then we are assured that the tc + * index has not been incremented. + */ + + testcases[tc++] = this; } + function startTest() { - version(120); + version(120); - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } } + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + try + { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + catch(e) + { + writeLineToLog('test(): empty testcase for tc = ' + tc + ' ' + e); + } + } + stopTest(); + return ( testcases ); +} + +/* + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ function getTestCaseResult( expect, actual ) { - // because ( NaN == NaN ) always returns false, need to do - // a special compare to see if we got the right result. - if ( actual != actual ) { - if ( typeof actual == "object" ) { - actual = "NaN object"; - } else { - actual = "NaN number"; - } - } - if ( expect != expect ) { - if ( typeof expect == "object" ) { - expect = "NaN object"; - } else { - expect = "NaN number"; - } - } + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } - var passed = ( expect == actual ) ? true : false; + var passed = ( expect == actual ) ? true : false; - // if both objects are numbers, give a little leeway for rounding. - if ( !passed - && typeof(actual) == "number" - && typeof(expect) == "number" - ) { - if ( Math.abs(actual-expect) < 0.0000001 ) { - passed = true; - } - } + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } - // verify type is the same - if ( typeof(expect) != typeof(actual) ) { - passed = false; - } + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } - return passed; + return passed; } /* * Begin printing functions. These functions use the shell's @@ -136,15 +167,15 @@ function getTestCaseResult( expect, actual ) { */ function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; } function writeFormattedResult( expect, actual, string, passed ) { - var s = string ; - s += ( passed ) ? PASSED : FAILED + expect; - writeLineToLog( s); - return passed; + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; } function writeLineToLog( string ) { print( string ); @@ -155,8 +186,8 @@ function writeHeaderToLog( string ) { /* end of print functions */ function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } + var gc; + if ( gc != undefined ) { + gc(); + } } diff --git a/mozilla/js/tests/js1_2/statements/break.js b/mozilla/js/tests/js1_2/statements/break.js index adbd460c988..19a551abfa4 100644 --- a/mozilla/js/tests/js1_2/statements/break.js +++ b/mozilla/js/tests/js1_2/statements/break.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,144 +35,128 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: break.js - Description: 'Tests the break statement' - Author: Nick Lerissa - Date: March 18, 1998 +/** + Filename: break.js + Description: 'Tests the break statement' + + Author: Nick Lerissa + Date: March 18, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'statements: break'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'statements: break'; - writeHeaderToLog("Executing script: break.js"); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog("Executing script: break.js"); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var i,j; - var i,j; +for (i = 0; i < 1000; i++) +{ + if (i == 100) break; +} - for (i = 0; i < 1000; i++) +// 'breaking out of "for" loop' +new TestCase ( SECTION, 'breaking out of "for" loop', + 100, i); + +j = 2000; + +out1: +for (i = 0; i < 1000; i++) +{ + if (i == 100) + { + out2: + for (j = 0; j < 1000; j++) { - if (i == 100) break; + if (j == 500) break out1; } + j = 2001; + } + j = 2002; +} - // 'breaking out of "for" loop' - testcases[count++] = new TestCase ( SECTION, 'breaking out of "for" loop', - 100, i); +// 'breaking out of a "for" loop with a "label"' +new TestCase ( SECTION, 'breaking out of a "for" loop with a "label"', + 500, j); - j = 2000; +i = 0; - out1: - for (i = 0; i < 1000; i++) +while (i < 1000) +{ + if (i == 100) break; + i++; +} + +// 'breaking out of a "while" loop' +new TestCase ( SECTION, 'breaking out of a "while" loop', + 100, i ); + + +j = 2000; +i = 0; + +out3: +while (i < 1000) +{ + if (i == 100) + { + j = 0; + out4: + while (j < 1000) { - if (i == 100) - { - out2: - for (j = 0; j < 1000; j++) - { - if (j == 500) break out1; - } - j = 2001; - } - j = 2002; + if (j == 500) break out3; + j++; } + j = 2001; + } + j = 2002; + i++; +} - // 'breaking out of a "for" loop with a "label"' - testcases[count++] = new TestCase ( SECTION, 'breaking out of a "for" loop with a "label"', - 500, j); +// 'breaking out of a "while" loop with a "label"' +new TestCase ( SECTION, 'breaking out of a "while" loop with a "label"', + 500, j); - i = 0; +i = 0; - while (i < 1000) - { - if (i == 100) break; - i++; - } +do +{ + if (i == 100) break; + i++; +} while (i < 1000); - // 'breaking out of a "while" loop' - testcases[count++] = new TestCase ( SECTION, 'breaking out of a "while" loop', - 100, i ); +// 'breaking out of a "do" loop' +new TestCase ( SECTION, 'breaking out of a "do" loop', + 100, i ); +j = 2000; +i = 0; - j = 2000; - i = 0; - - out3: - while (i < 1000) - { - if (i == 100) - { - j = 0; - out4: - while (j < 1000) - { - if (j == 500) break out3; - j++; - } - j = 2001; - } - j = 2002; - i++; - } - - // 'breaking out of a "while" loop with a "label"' - testcases[count++] = new TestCase ( SECTION, 'breaking out of a "while" loop with a "label"', - 500, j); - - i = 0; - +out5: +do +{ + if (i == 100) + { + j = 0; + out6: do { - if (i == 100) break; - i++; - } while (i < 1000); + if (j == 500) break out5; + j++; + }while (j < 1000); + j = 2001; + } + j = 2002; + i++; +}while (i < 1000); - // 'breaking out of a "do" loop' - testcases[count++] = new TestCase ( SECTION, 'breaking out of a "do" loop', - 100, i ); +// 'breaking out of a "do" loop with a "label"' +new TestCase ( SECTION, 'breaking out of a "do" loop with a "label"', + 500, j); - j = 2000; - i = 0; - - out5: - do - { - if (i == 100) - { - j = 0; - out6: - do - { - if (j == 500) break out5; - j++; - }while (j < 1000); - j = 2001; - } - j = 2002; - i++; - }while (i < 1000); - - // 'breaking out of a "do" loop with a "label"' - testcases[count++] = new TestCase ( SECTION, 'breaking out of a "do" loop with a "label"', - 500, j); - - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/statements/browser.js b/mozilla/js/tests/js1_2/statements/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/statements/continue.js b/mozilla/js/tests/js1_2/statements/continue.js index 5702e7324e3..0298efe6ce2 100644 --- a/mozilla/js/tests/js1_2/statements/continue.js +++ b/mozilla/js/tests/js1_2/statements/continue.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,157 +35,141 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: continue.js - Description: 'Tests the continue statement' - Author: Nick Lerissa - Date: March 18, 1998 +/** + Filename: continue.js + Description: 'Tests the continue statement' + + Author: Nick Lerissa + Date: March 18, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'statements: continue'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'statements: continue'; - writeHeaderToLog("Executing script: continue.js"); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog("Executing script: continue.js"); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +var i,j; - var i,j; +j = 0; +for (i = 0; i < 200; i++) +{ + if (i == 100) + continue; + j++; +} - j = 0; - for (i = 0; i < 200; i++) +// '"continue" in a "for" loop' +new TestCase ( SECTION, '"continue" in "for" loop', + 199, j); + + +j = 0; +out1: +for (i = 0; i < 1000; i++) +{ + if (i == 100) + { + out2: + for (var k = 0; k < 1000; k++) { - if (i == 100) - continue; - j++; + if (k == 500) continue out1; } + j = 3000; + } + j++; +} - // '"continue" in a "for" loop' - testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop', - 199, j); +// '"continue" in a "for" loop with a "label"' +new TestCase ( SECTION, '"continue" in "for" loop with a "label"', + 999, j); +i = 0; +j = 1; - j = 0; - out1: - for (i = 0; i < 1000; i++) +while (i != j) +{ + i++; + if (i == 100) continue; + j++; +} + +// '"continue" in a "while" loop' +new TestCase ( SECTION, '"continue" in a "while" loop', + 100, j ); + +j = 0; +i = 0; +out3: +while (i < 1000) +{ + if (i == 100) + { + var k = 0; + out4: + while (k < 1000) { - if (i == 100) + if (k == 500) { - out2: - for (var k = 0; k < 1000; k++) - { - if (k == 500) continue out1; - } - j = 3000; + i++; + continue out3; } - j++; + k++; } + j = 3000; + } + j++; + i++; +} - // '"continue" in a "for" loop with a "label"' - testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop with a "label"', - 999, j); +// '"continue" in a "while" loop with a "label"' +new TestCase ( SECTION, '"continue" in a "while" loop with a "label"', + 999, j); - i = 0; - j = 1; +i = 0; +j = 1; - while (i != j) - { - i++; - if (i == 100) continue; - j++; - } +do +{ + i++; + if (i == 100) continue; + j++; +} while (i != j); - // '"continue" in a "while" loop' - testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop', - 100, j ); - j = 0; - i = 0; - out3: - while (i < 1000) - { - if (i == 100) - { - var k = 0; - out4: - while (k < 1000) - { - if (k == 500) - { - i++; - continue out3; - } - k++; - } - j = 3000; - } - j++; - i++; - } - - // '"continue" in a "while" loop with a "label"' - testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop with a "label"', - 999, j); - - i = 0; - j = 1; +// '"continue" in a "do" loop' +new TestCase ( SECTION, '"continue" in a "do" loop', + 100, j ); +j = 0; +i = 0; +out5: +do +{ + if (i == 100) + { + var k = 0; + out6: do { - i++; - if (i == 100) continue; - j++; - } while (i != j); - - - // '"continue" in a "do" loop' - testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop', - 100, j ); - - j = 0; - i = 0; - out5: - do - { - if (i == 100) + if (k == 500) { - var k = 0; - out6: - do - { - if (k == 500) - { - i++; - continue out5; - } - k++; - }while (k < 1000); - j = 3000; + i++; + continue out5; } - j++; - i++; - }while (i < 1000); + k++; + }while (k < 1000); + j = 3000; + } + j++; + i++; +}while (i < 1000); - // '"continue" in a "do" loop with a "label"' - testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop with a "label"', - 999, j); +// '"continue" in a "do" loop with a "label"' +new TestCase ( SECTION, '"continue" in a "do" loop with a "label"', + 999, j); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/statements/do_while.js b/mozilla/js/tests/js1_2/statements/do_while.js index a7261b44eb4..d4650117575 100644 --- a/mozilla/js/tests/js1_2/statements/do_while.js +++ b/mozilla/js/tests/js1_2/statements/do_while.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,50 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -/** - Filename: do_while.js - Description: 'This tests the new do_while loop' - Author: Nick Lerissa - Date: Fri Feb 13 09:58:28 PST 1998 +/** + Filename: do_while.js + Description: 'This tests the new do_while loop' + + Author: Nick Lerissa + Date: Fri Feb 13 09:58:28 PST 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'statements: do_while'; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'statements: do_while'; - writeHeaderToLog('Executing script: do_while.js'); - writeHeaderToLog( SECTION + " "+ TITLE); - - var count = 0; - var testcases = new Array(); +writeHeaderToLog('Executing script: do_while.js'); +writeHeaderToLog( SECTION + " "+ TITLE); +var done = false; +var x = 0; +do +{ + if (x++ == 3) done = true; +} while (!done); - var done = false; - var x = 0; - do - { - if (x++ == 3) done = true; - } while (!done); +new TestCase( SECTION, "do_while ", + 4, x); - testcases[count++] = new TestCase( SECTION, "do_while ", - 4, x); - - //load('d:/javascript/tests/output/statements/do_while.js') - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +//load('d:/javascript/tests/output/statements/do_while.js') +test(); diff --git a/mozilla/js/tests/js1_2/statements/shell.js b/mozilla/js/tests/js1_2/statements/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_2/statements/switch.js b/mozilla/js/tests/js1_2/statements/switch.js index b543e186346..66a599f11e9 100644 --- a/mozilla/js/tests/js1_2/statements/switch.js +++ b/mozilla/js/tests/js1_2/statements/switch.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,109 +35,94 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - Filename: switch.js - Description: 'Tests the switch statement' + Filename: switch.js + Description: 'Tests the switch statement' - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 - Author: Nick Lerissa - Date: March 19, 1998 + Author: Nick Lerissa + Date: March 19, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'statements: switch'; - var BUGNUMBER="323696"; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'statements: switch'; +var BUGNUMBER="323696"; - writeHeaderToLog("Executing script: switch.js"); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog("Executing script: switch.js"); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); - var var1 = "match string"; - var match1 = false; - var match2 = false; - var match3 = false; +var var1 = "match string"; +var match1 = false; +var match2 = false; +var match3 = false; - switch (var1) - { - case "match string": - match1 = true; - case "bad string 1": - match2 = true; - break; - case "bad string 2": - match3 = true; - } +switch (var1) +{ +case "match string": + match1 = true; +case "bad string 1": + match2 = true; + break; +case "bad string 2": + match3 = true; +} - testcases[count++] = new TestCase ( SECTION, 'switch statement', - true, match1); +new TestCase ( SECTION, 'switch statement', + true, match1); - testcases[count++] = new TestCase ( SECTION, 'switch statement', - true, match2); +new TestCase ( SECTION, 'switch statement', + true, match2); - testcases[count++] = new TestCase ( SECTION, 'switch statement', - false, match3); +new TestCase ( SECTION, 'switch statement', + false, match3); - var var2 = 3; +var var2 = 3; - var match1 = false; - var match2 = false; - var match3 = false; - var match4 = false; - var match5 = false; +var match1 = false; +var match2 = false; +var match3 = false; +var match4 = false; +var match5 = false; - switch (var2) - { - case 1: +switch (var2) +{ +case 1: /* switch (var1) { - case "foo": - match1 = true; - break; - case 3: - match2 = true; - break; + case "foo": + match1 = true; + break; + case 3: + match2 = true; + break; }*/ - match3 = true; - break; - case 2: - match4 = true; - break; - case 3: - match5 = true; - break; - } - testcases[count++] = new TestCase ( SECTION, 'switch statement', - false, match1); + match3 = true; + break; +case 2: + match4 = true; + break; +case 3: + match5 = true; + break; +} +new TestCase ( SECTION, 'switch statement', + false, match1); - testcases[count++] = new TestCase ( SECTION, 'switch statement', - false, match2); +new TestCase ( SECTION, 'switch statement', + false, match2); - testcases[count++] = new TestCase ( SECTION, 'switch statement', - false, match3); +new TestCase ( SECTION, 'switch statement', + false, match3); - testcases[count++] = new TestCase ( SECTION, 'switch statement', - false, match4); +new TestCase ( SECTION, 'switch statement', + false, match4); - testcases[count++] = new TestCase ( SECTION, 'switch statement', - true, match5); +new TestCase ( SECTION, 'switch statement', + true, match5); - function test() - { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } - - test(); +test(); diff --git a/mozilla/js/tests/js1_2/statements/switch2.js b/mozilla/js/tests/js1_2/statements/switch2.js index f3b689e296e..cdc8e0bbbea 100644 --- a/mozilla/js/tests/js1_2/statements/switch2.js +++ b/mozilla/js/tests/js1_2/statements/switch2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,170 +35,156 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - Filename: switch2.js - Description: 'Tests the switch statement' + Filename: switch2.js + Description: 'Tests the switch statement' - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 - Author: Norris Boyd - Date: July 31, 1998 + Author: Norris Boyd + Date: July 31, 1998 */ - var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; - var VERSION = 'no version'; - startTest(); - var TITLE = 'statements: switch'; - var BUGNUMBER="323626"; +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; +var VERSION = 'no version'; +startTest(); +var TITLE = 'statements: switch'; +var BUGNUMBER="323626"; - writeHeaderToLog("Executing script: switch2.js"); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog("Executing script: switch2.js"); +writeHeaderToLog( SECTION + " "+ TITLE); - var count = 0; - var testcases = new Array(); +// test defaults not at the end; regression test for a bug that +// nearly made it into 4.06 +function f0(i) { + switch(i) { + default: + case "a": + case "b": + return "ab*" + case "c": + return "c"; + case "d": + return "d"; + } + return ""; +} +new TestCase(SECTION, 'switch statement', + f0("a"), "ab*"); - // test defaults not at the end; regression test for a bug that - // nearly made it into 4.06 - function f0(i) { - switch(i) { - default: - case "a": - case "b": - return "ab*" - case "c": - return "c"; - case "d": - return "d"; - } - return ""; - } - testcases[count++] = new TestCase(SECTION, 'switch statement', - f0("a"), "ab*"); +new TestCase(SECTION, 'switch statement', + f0("b"), "ab*"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f0("b"), "ab*"); +new TestCase(SECTION, 'switch statement', + f0("*"), "ab*"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f0("*"), "ab*"); +new TestCase(SECTION, 'switch statement', + f0("c"), "c"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f0("c"), "c"); +new TestCase(SECTION, 'switch statement', + f0("d"), "d"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f0("d"), "d"); +function f1(i) { + switch(i) { + case "a": + case "b": + default: + return "ab*" + case "c": + return "c"; + case "d": + return "d"; + } + return ""; +} - function f1(i) { - switch(i) { - case "a": - case "b": - default: - return "ab*" - case "c": - return "c"; - case "d": - return "d"; - } - return ""; - } +new TestCase(SECTION, 'switch statement', + f1("a"), "ab*"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f1("a"), "ab*"); +new TestCase(SECTION, 'switch statement', + f1("b"), "ab*"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f1("b"), "ab*"); +new TestCase(SECTION, 'switch statement', + f1("*"), "ab*"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f1("*"), "ab*"); +new TestCase(SECTION, 'switch statement', + f1("c"), "c"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f1("c"), "c"); +new TestCase(SECTION, 'switch statement', + f1("d"), "d"); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f1("d"), "d"); +// Switch on integer; will use TABLESWITCH opcode in C engine +function f2(i) { + switch (i) { + case 0: + case 1: + return 1; + case 2: + return 2; + } + // with no default, control will fall through + return 3; +} - // Switch on integer; will use TABLESWITCH opcode in C engine - function f2(i) { - switch (i) { - case 0: - case 1: - return 1; - case 2: - return 2; - } - // with no default, control will fall through - return 3; - } +new TestCase(SECTION, 'switch statement', + f2(0), 1); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f2(0), 1); +new TestCase(SECTION, 'switch statement', + f2(1), 1); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f2(1), 1); +new TestCase(SECTION, 'switch statement', + f2(2), 2); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f2(2), 2); +new TestCase(SECTION, 'switch statement', + f2(3), 3); - testcases[count++] = new TestCase(SECTION, 'switch statement', - f2(3), 3); +// empty switch: make sure expression is evaluated +var se = 0; +switch (se = 1) { +} +new TestCase(SECTION, 'switch statement', + se, 1); - // empty switch: make sure expression is evaluated - var se = 0; - switch (se = 1) { - } - testcases[count++] = new TestCase(SECTION, 'switch statement', - se, 1); +// only default +se = 0; +switch (se) { +default: + se = 1; +} +new TestCase(SECTION, 'switch statement', + se, 1); - // only default - se = 0; - switch (se) { - default: - se = 1; - } - testcases[count++] = new TestCase(SECTION, 'switch statement', - se, 1); +// in loop, break should only break out of switch +se = 0; +for (var i=0; i < 2; i++) { + switch (i) { + case 0: + case 1: + break; + } + se = 1; +} +new TestCase(SECTION, 'switch statement', + se, 1); - // in loop, break should only break out of switch - se = 0; - for (var i=0; i < 2; i++) { - switch (i) { - case 0: - case 1: - break; - } - se = 1; - } - testcases[count++] = new TestCase(SECTION, 'switch statement', - se, 1); +// test "fall through" +se = 0; +i = 0; +switch (i) { +case 0: + se++; + /* fall through */ +case 1: + se++; + break; +} +new TestCase(SECTION, 'switch statement', + se, 2); +writeLineToLog("hi"); - // test "fall through" - se = 0; - i = 0; - switch (i) { - case 0: - se++; - /* fall through */ - case 1: - se++; - break; - } - testcases[count++] = new TestCase(SECTION, 'switch statement', - se, 2); +test(); - test(); +// Needed: tests for evaluation time of case expressions. +// This issue was under debate at ECMA, so postponing for now. - // Needed: tests for evaluation time of case expressions. - // This issue was under debate at ECMA, so postponing for now. - - function test() { - writeLineToLog("hi"); - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); - } diff --git a/mozilla/js/tests/js1_2/version120/boolean-001.js b/mozilla/js/tests/js1_2/version120/boolean-001.js index 3a56335d7a1..daf9c35b500 100644 --- a/mozilla/js/tests/js1_2/version120/boolean-001.js +++ b/mozilla/js/tests/js1_2/version120/boolean-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -43,21 +44,19 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "boolean-001.js"; - var VERSION = "JS1_2"; - startTest(); - var TITLE = "new Boolean(false) should evaluate to false"; +var SECTION = "boolean-001.js"; +var VERSION = "JS1_2"; +startTest(); +var TITLE = "new Boolean(false) should evaluate to false"; - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +BooleanTest( "new Boolean(true)", new Boolean(true), true ); +BooleanTest( "new Boolean(false)", new Boolean(false), false ); +BooleanTest( "true", true, true ); +BooleanTest( "false", false, false ); - BooleanTest( "new Boolean(true)", new Boolean(true), true ); - BooleanTest( "new Boolean(false)", new Boolean(false), false ); - BooleanTest( "true", true, true ); - BooleanTest( "false", false, false ); - - test(); +test(); function BooleanTest( string, object, expect ) { if ( object ) { @@ -66,23 +65,10 @@ function BooleanTest( string, object, expect ) { result = false; } - testcases[tc++] = new TestCase( + new TestCase( SECTION, string, expect, result ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_2/version120/browser.js b/mozilla/js/tests/js1_2/version120/browser.js new file mode 100644 index 00000000000..4916e5651e1 --- /dev/null +++ b/mozilla/js/tests/js1_2/version120/browser.js @@ -0,0 +1,21 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + diff --git a/mozilla/js/tests/js1_2/version120/shell.js b/mozilla/js/tests/js1_2/version120/shell.js index db02dadd6ed..725d90afe79 100644 --- a/mozilla/js/tests/js1_2/version120/shell.js +++ b/mozilla/js/tests/js1_2/version120/shell.js @@ -36,4 +36,4 @@ /* all files in this dir need version(120) called before they are *loaded* */ -version(120); \ No newline at end of file +version(120); diff --git a/mozilla/js/tests/js1_3/Boolean/boolean-001.js b/mozilla/js/tests/js1_3/Boolean/boolean-001.js index 6c4124a752d..a994bf0ab5e 100644 --- a/mozilla/js/tests/js1_3/Boolean/boolean-001.js +++ b/mozilla/js/tests/js1_3/Boolean/boolean-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -43,21 +44,19 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "boolean-001.js"; - var VERSION = "JS_1.3"; - var TITLE = "new Boolean(false) should evaluate to false"; +var SECTION = "boolean-001.js"; +var VERSION = "JS_1.3"; +var TITLE = "new Boolean(false) should evaluate to false"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +BooleanTest( "new Boolean(true)", new Boolean(true), true ); +BooleanTest( "new Boolean(false)", new Boolean(false), true ); +BooleanTest( "true", true, true ); +BooleanTest( "false", false, false ); - BooleanTest( "new Boolean(true)", new Boolean(true), true ); - BooleanTest( "new Boolean(false)", new Boolean(false), true ); - BooleanTest( "true", true, true ); - BooleanTest( "false", false, false ); - - test(); +test(); function BooleanTest( string, object, expect ) { if ( object ) { @@ -66,23 +65,10 @@ function BooleanTest( string, object, expect ) { result = false; } - testcases[tc++] = new TestCase( + new TestCase( SECTION, string, expect, result ); } -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_3/Boolean/browser.js b/mozilla/js/tests/js1_3/Boolean/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/Boolean/shell.js b/mozilla/js/tests/js1_3/Boolean/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/README b/mozilla/js/tests/js1_3/README new file mode 100755 index 00000000000..82f668486b0 --- /dev/null +++ b/mozilla/js/tests/js1_3/README @@ -0,0 +1 @@ +JavaScript 1.3 diff --git a/mozilla/js/tests/js1_3/Script/browser.js b/mozilla/js/tests/js1_3/Script/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/Script/delete-001.js b/mozilla/js/tests/js1_3/Script/delete-001.js index 87525f86a4e..17c7ac50d7d 100644 --- a/mozilla/js/tests/js1_3/Script/delete-001.js +++ b/mozilla/js/tests/js1_3/Script/delete-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: delete-001.js - Section: regress - Description: + File Name: delete-001.js + Section: regress + Description: - Regression test for - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=108736 + Regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=108736 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "JS1_2"; - var VERSION = "JS1_2"; - var TITLE = "The variable statment"; +var SECTION = "JS1_2"; +var VERSION = "JS1_2"; +var TITLE = "The variable statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// delete all properties of the global object +// per ecma, this does not affect variables in the global object declared +// with var or functions - // delete all properties of the global object - // per ecma, this does not affect variables in the global object declared - // with var or functions - - for ( p in this ) { - delete p; - } - - var result =""; - - for ( p in this ) { - result += String( p ); - } - - // not too picky here... just want to make sure we didn't crash or something - - testcases[testcases.length] = new TestCase( SECTION, - "delete all properties of the global object", - "PASSED", - result == "" ? "FAILED" : "PASSED" ); - - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( p in this ) { + delete p; } + +var result =""; + +for ( p in this ) { + result += String( p ); +} + +// not too picky here... just want to make sure we didn't crash or something + +new TestCase( SECTION, + "delete all properties of the global object", + "PASSED", + result == "" ? "FAILED" : "PASSED" ); + + +test(); + diff --git a/mozilla/js/tests/js1_3/Script/function-001-n.js b/mozilla/js/tests/js1_3/Script/function-001-n.js index dc656e898cb..fc17484bd61 100644 --- a/mozilla/js/tests/js1_3/Script/function-001-n.js +++ b/mozilla/js/tests/js1_3/Script/function-001-n.js @@ -63,9 +63,7 @@ startTest(); writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - testcases[tc++] = new TestCase( + new TestCase( SECTION, "eval(\"function f(){}function g(){}\")", "error", @@ -74,16 +72,3 @@ test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_3/Script/function-002.js b/mozilla/js/tests/js1_3/Script/function-002.js index 617d51e6ed4..8bc72d6dbb9 100644 --- a/mozilla/js/tests/js1_3/Script/function-002.js +++ b/mozilla/js/tests/js1_3/Script/function-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,43 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: function-002.js - Section: - Description: + File Name: function-002.js + Section: + Description: - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=249579 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=249579 - function definitions in conditional statements should be allowed. + function definitions in conditional statements should be allowed. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "function-002"; - var VERSION = "JS1_3"; - var TITLE = "Regression test for 249579"; - var BUGNUMBER="249579"; +var SECTION = "function-002"; +var VERSION = "JS1_3"; +var TITLE = "Regression test for 249579"; +var BUGNUMBER="249579"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - testcases[tc++] = new TestCase( - SECTION, - "0?function(){}:0", - 0, - 0?function(){}:0 ); +new TestCase( + SECTION, + "0?function(){}:0", + 0, + 0?function(){}:0 ); - bar = true; - foo = bar ? function () { return true; } : function() { return false; }; +bar = true; +foo = bar ? function () { return true; } : function() { return false; }; - testcases[tc++] = new TestCase( - SECTION, - "bar = true; foo = bar ? function () { return true; } : function() { return false; }; foo()", - true, - foo() ); +new TestCase( + SECTION, + "bar = true; foo = bar ? function () { return true; } : function() { return false; }; foo()", + true, + foo() ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_3/Script/in-001.js b/mozilla/js/tests/js1_3/Script/in-001.js index 75de0e95abc..7759a39ecad 100644 --- a/mozilla/js/tests/js1_3/Script/in-001.js +++ b/mozilla/js/tests/js1_3/Script/in-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,34 +35,33 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: in-001.js - Section: - Description: + File Name: in-001.js + Section: + Description: - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=196109 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=196109 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "in-001"; - var VERSION = "JS1_3"; - var TITLE = "Regression test for 196109"; - var BUGNUMBER="196109"; +var SECTION = "in-001"; +var VERSION = "JS1_3"; +var TITLE = "Regression test for 196109"; +var BUGNUMBER="196109"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +o = {}; +o.foo = 'sil'; - o = {}; - o.foo = 'sil'; +new TestCase( + SECTION, + "\"foo\" in o", + true, + "foo" in o ); - testcases[tc++] = new TestCase( - SECTION, - "\"foo\" in o", - true, - "foo" in o ); - - test(); +test(); diff --git a/mozilla/js/tests/js1_3/Script/new-001.js b/mozilla/js/tests/js1_3/Script/new-001.js index 6d40976cb25..70fd02b8192 100644 --- a/mozilla/js/tests/js1_3/Script/new-001.js +++ b/mozilla/js/tests/js1_3/Script/new-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,102 +35,87 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: new-001.js - Section: - Description: + File Name: new-001.js + Section: + Description: - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "new-001"; - var VERSION = "JS1_3"; - var TITLE = "new-001"; - var BUGNUMBER="31567"; +var SECTION = "new-001"; +var VERSION = "JS1_3"; +var TITLE = "new-001"; +var BUGNUMBER="31567"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +function Test_One (x) { + this.v = x+1; + return x*2 + } - function Test_One (x) { - this.v = x+1; - return x*2 - } - - function Test_Two( x, y ) { - this.v = x; - return y; - } - - testcases[tc++] = new TestCase( - SECTION, - "Test_One(18)", - 36, - Test_One(18) ); - - testcases[tc++] = new TestCase( - SECTION, - "new Test_One(18)", - "[object Object]", - new Test_One(18) +"" ); - - testcases[tc++] = new TestCase( - SECTION, - "new Test_One(18).v", - 19, - new Test_One(18).v ); - - testcases[tc++] = new TestCase( - SECTION, - "Test_Two(2,7)", - 7, - Test_Two(2,7) ); - - testcases[tc++] = new TestCase( - SECTION, - "new Test_Two(2,7)", - "[object Object]", - new Test_Two(2,7) +"" ); - - testcases[tc++] = new TestCase( - SECTION, - "new Test_Two(2,7).v", - 2, - new Test_Two(2,7).v ); - - testcases[tc++] = new TestCase( - SECTION, - "new (Function)(\"x\", \"return x+3\")(5,6)", - 8, - new (Function)("x","return x+3")(5,6) ); - - testcases[tc++] = new TestCase( - SECTION, - "new new Test_Two(String, 2).v(0123)", - "83", - new new Test_Two(String, 2).v(0123) +""); - - testcases[tc++] = new TestCase( - SECTION, - "new new Test_Two(String, 2).v(0123).length", - 2, - new new Test_Two(String, 2).v(0123).length ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function Test_Two( x, y ) { + this.v = x; + return y; } + +new TestCase( + SECTION, + "Test_One(18)", + 36, + Test_One(18) ); + +new TestCase( + SECTION, + "new Test_One(18)", + "[object Object]", + new Test_One(18) +"" ); + +new TestCase( + SECTION, + "new Test_One(18).v", + 19, + new Test_One(18).v ); + +new TestCase( + SECTION, + "Test_Two(2,7)", + 7, + Test_Two(2,7) ); + +new TestCase( + SECTION, + "new Test_Two(2,7)", + "[object Object]", + new Test_Two(2,7) +"" ); + +new TestCase( + SECTION, + "new Test_Two(2,7).v", + 2, + new Test_Two(2,7).v ); + +new TestCase( + SECTION, + "new (Function)(\"x\", \"return x+3\")(5,6)", + 8, + new (Function)("x","return x+3")(5,6) ); + +new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123)", + "83", + new new Test_Two(String, 2).v(0123) +""); + +new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123).length", + 2, + new new Test_Two(String, 2).v(0123).length ); + +test(); diff --git a/mozilla/js/tests/js1_3/Script/script-001.js b/mozilla/js/tests/js1_3/Script/script-001.js index a718e278048..71cccdc5cc1 100644 --- a/mozilla/js/tests/js1_3/Script/script-001.js +++ b/mozilla/js/tests/js1_3/Script/script-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,141 +35,127 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: script-001.js - Section: - Description: new NativeScript object + File Name: script-001.js + Section: + Description: new NativeScript object -js> parseInt(123,"hi") -123 -js> parseInt(123, "blah") -123 -js> s -js: s is not defined -js> s = new Script + js> parseInt(123,"hi") + 123 + js> parseInt(123, "blah") + 123 + js> s + js: s is not defined + js> s = new Script -undefined; + undefined; -js> s = new Script() + js> s = new Script() -undefined; + undefined; -js> s.getJSClass -js> s.getJSClass = Object.prototype.toString -function toString() { - [native code] -} + js> s.getJSClass + js> s.getJSClass = Object.prototype.toString + function toString() { + [native code] + } -js> s.getJSClass() -[object Script] -js> s.compile( "return 3+4" ) -js: JavaScript exception: javax.javascript.EvaluatorException: "<Scr -js> s.compile( "3+4" ) + js> s.getJSClass() + [object Script] + js> s.compile( "return 3+4" ) + js: JavaScript exception: javax.javascript.EvaluatorException: "<Scr + js> s.compile( "3+4" ) -3 + 4; + 3 + 4; -js> typeof s -function -js> s() -Jit failure! -invalid opcode: 1 -Jit Pass1 Failure! -javax/javascript/gen/c13 initScript (Ljavax/javascript/Scriptable;)V -An internal JIT error has occurred. Please report this with .class -jit-bugs@itools.symantec.com + js> typeof s + function + js> s() + Jit failure! + invalid opcode: 1 + Jit Pass1 Failure! + javax/javascript/gen/c13 initScript (Ljavax/javascript/Scriptable;)V + An internal JIT error has occurred. Please report this with .class + jit-bugs@itools.symantec.com -7 -js> s.compile("3+4") + 7 + js> s.compile("3+4") -3 + 4; + 3 + 4; -js> s() -Jit failure! -invalid opcode: 1 -Jit Pass1 Failure! -javax/javascript/gen/c17 initScript (Ljavax/javascript/Scriptable;)V -An internal JIT error has occurred. Please report this with .class -jit-bugs@itools.symantec.com + js> s() + Jit failure! + invalid opcode: 1 + Jit Pass1 Failure! + javax/javascript/gen/c17 initScript (Ljavax/javascript/Scriptable;)V + An internal JIT error has occurred. Please report this with .class + jit-bugs@itools.symantec.com -7 -js> quit() + 7 + js> quit() -C:\src\ns_priv\js\tests\ecma>shell + C:\src\ns_priv\js\tests\ecma>shell -C:\src\ns_priv\js\tests\ecma>java -classpath c:\cafe\java\JavaScope; -:\src\ns_priv\js\tests javax.javascript.examples.Shell -Symantec Java! JustInTime Compiler Version 210.054 for JDK 1.1.2 -Copyright (C) 1996-97 Symantec Corporation + C:\src\ns_priv\js\tests\ecma>java -classpath c:\cafe\java\JavaScope; + :\src\ns_priv\js\tests javax.javascript.examples.Shell + Symantec Java! JustInTime Compiler Version 210.054 for JDK 1.1.2 + Copyright (C) 1996-97 Symantec Corporation -js> s = new Script("3+4") + js> s = new Script("3+4") -3 + 4; + 3 + 4; -js> s() -7 -js> s2 = new Script(); + js> s() + 7 + js> s2 = new Script(); -undefined; + undefined; -js> s.compile( "3+4") + js> s.compile( "3+4") -3 + 4; + 3 + 4; -js> s() -Jit failure! -invalid opcode: 1 -Jit Pass1 Failure! -javax/javascript/gen/c7 initScript (Ljavax/javascript/Scriptable;)V -An internal JIT error has occurred. Please report this with .class -jit-bugs@itools.symantec.com + js> s() + Jit failure! + invalid opcode: 1 + Jit Pass1 Failure! + javax/javascript/gen/c7 initScript (Ljavax/javascript/Scriptable;)V + An internal JIT error has occurred. Please report this with .class + jit-bugs@itools.symantec.com -7 -js> quit() - Author: christine@netscape.com - Date: 12 november 1997 + 7 + js> quit() + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "script-001"; - var VERSION = "JS1_3"; - var TITLE = "NativeScript"; +var SECTION = "script-001"; +var VERSION = "JS1_3"; +var TITLE = "NativeScript"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var s = new Script(); +s.getJSClass = Object.prototype.toString; - var s = new Script(); - s.getJSClass = Object.prototype.toString; +new TestCase( SECTION, + "var s = new Script(); typeof s", + "function", + typeof s ); - testcases[tc++] = new TestCase( SECTION, - "var s = new Script(); typeof s", - "function", - typeof s ); +new TestCase( SECTION, + "s.getJSClass()", + "[object Script]", + s.getJSClass() ); - testcases[tc++] = new TestCase( SECTION, - "s.getJSClass()", - "[object Script]", - s.getJSClass() ); - - test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +test(); diff --git a/mozilla/js/tests/js1_3/Script/shell.js b/mozilla/js/tests/js1_3/Script/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/Script/switch-001.js b/mozilla/js/tests/js1_3/Script/switch-001.js index f445ecc1f0f..d45eb5cc98a 100644 --- a/mozilla/js/tests/js1_3/Script/switch-001.js +++ b/mozilla/js/tests/js1_3/Script/switch-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,48 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: switch-001.js - Section: - Description: + File Name: switch-001.js + Section: + Description: - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 - Verify that switches do not use strict equality in - versions of JavaScript < 1.4 + Verify that switches do not use strict equality in + versions of JavaScript < 1.4 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "switch-001"; - var VERSION = "JS1_3"; - var TITLE = "switch-001"; - var BUGNUMBER="315767"; +var SECTION = "switch-001"; +var VERSION = "JS1_3"; +var TITLE = "switch-001"; +var BUGNUMBER="315767"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +result = "fail: did not enter switch"; - result = "fail: did not enter switch"; - - switch (true) { - case 1: - result = "fail: for backwards compatibility, version 130 use strict equality"; - break; - case true: - result = "pass"; - break; - default: - result = "fail: evaluated default statement"; - } - - testcases[tc++] = new TestCase( - SECTION, - "switch / case should use strict equality in version of JS < 1.4", - "pass", - result ); - - - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +switch (true) { +case 1: + result = "fail: for backwards compatibility, version 130 use strict equality"; + break; +case true: + result = "pass"; + break; +default: + result = "fail: evaluated default statement"; } + +new TestCase( + SECTION, + "switch / case should use strict equality in version of JS < 1.4", + "pass", + result ); + + + +test(); + diff --git a/mozilla/js/tests/js1_3/browser.js b/mozilla/js/tests/js1_3/browser.js new file mode 100644 index 00000000000..6586316732c --- /dev/null +++ b/mozilla/js/tests/js1_3/browser.js @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * <script src="./../shell.js"></script> + * <script src="./../browser.js"></script> + * <script src="./mytest.js"></script> + */ + +GLOBAL = "[object Window]"; + +function writeLineToLog( string ) { + document.write( string + "<br>\n"); +} +function writeHeaderToLog( string ) { + document.write( "<h2>" + string + "</h2>" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = "<tt>"+ string ; + s += "<b>" ; + s += ( passed ) ? "<font color=#009900>  " + PASSED + : "<font color=#aa0000> " + FAILED + expect + "</tt>"; + writeLineToLog( s + "</font></b></tt>" ); + return passed; +} + + +/* + * The earlier versions of the test code used exceptions + * to terminate the test script in "negative" test cases + * before the failure reporting code could run. In order + * to be able to capture errors for the "negative" case + * where the exception is a sign the test actually passed, + * the err online handler will assume that any error is a + * failure unless gExceptionExpected is true. + */ +window.onerror = err; +var gExceptionExpected = false; + +function err( msg, page, line ) { + var testcase; + + if (typeof(EXPECTED) == "undefined" || EXPECTED != "error") { + /* + * an unexpected exception occured + */ + writeLineToLog( "Test failed with the message: " + msg ); + testcase = new TestCase(SECTION, "unknown", "unknown", "unknown"); + testcase.passed = false; + testcase.reason = "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + return; + } + + if (typeof SECTION == 'undefined') + { + SECTION = 'Unknown'; + } + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + + testcase = new TestCase(SECTION, DESCRIPTION, EXPECTED, "error"); + testcase.reason += "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + stopTest(); +} + +function version(v) +{ + if (v) { + gVersion = v; + } + return gVersion; +} diff --git a/mozilla/js/tests/js1_3/inherit/browser.js b/mozilla/js/tests/js1_3/inherit/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/inherit/proto_1.js b/mozilla/js/tests/js1_3/inherit/proto_1.js index aabcffff8f0..9ac93b279ed 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_1.js +++ b/mozilla/js/tests/js1_3/inherit/proto_1.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,43 +35,42 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_1.js - Section: - Description: new PrototypeObject + File Name: proto_1.js + Section: + Description: new PrototypeObject - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_1"; - var VERSION = "JS1_3"; - var TITLE = "new PrototypeObject"; +var SECTION = "proto_1"; +var VERSION = "JS1_3"; +var TITLE = "new PrototypeObject"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee () { - this.name = ""; - this.dept = "general"; + this.name = ""; + this.dept = "general"; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee () { - this.projects = new Array(); + this.projects = new Array(); } WorkerBee.prototype = new Employee(); @@ -86,96 +86,83 @@ function Engineer () { } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var jim = new Employee(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - var jim = new Employee(); - - testcases[tc++] = new TestCase( SECTION, - "jim = new Employee(); jim.name", - "", - jim.name ); +new TestCase( SECTION, + "jim = new Employee(); jim.name", + "", + jim.name ); - testcases[tc++] = new TestCase( SECTION, - "jim = new Employee(); jim.dept", - "general", - jim.dept ); +new TestCase( SECTION, + "jim = new Employee(); jim.dept", + "general", + jim.dept ); - var sally = new Manager(); +var sally = new Manager(); - testcases[tc++] = new TestCase( SECTION, - "sally = new Manager(); sally.name", - "", - sally.name ); - testcases[tc++] = new TestCase( SECTION, - "sally = new Manager(); sally.dept", - "general", - sally.dept ); +new TestCase( SECTION, + "sally = new Manager(); sally.name", + "", + sally.name ); +new TestCase( SECTION, + "sally = new Manager(); sally.dept", + "general", + sally.dept ); - testcases[tc++] = new TestCase( SECTION, - "sally = new Manager(); sally.reports.length", - 0, - sally.reports.length ); +new TestCase( SECTION, + "sally = new Manager(); sally.reports.length", + 0, + sally.reports.length ); - testcases[tc++] = new TestCase( SECTION, - "sally = new Manager(); typeof sally.reports", - "object", - typeof sally.reports ); +new TestCase( SECTION, + "sally = new Manager(); typeof sally.reports", + "object", + typeof sally.reports ); - var fred = new SalesPerson(); +var fred = new SalesPerson(); - testcases[tc++] = new TestCase( SECTION, - "fred = new SalesPerson(); fred.name", - "", - fred.name ); +new TestCase( SECTION, + "fred = new SalesPerson(); fred.name", + "", + fred.name ); - testcases[tc++] = new TestCase( SECTION, - "fred = new SalesPerson(); fred.dept", - "sales", - fred.dept ); +new TestCase( SECTION, + "fred = new SalesPerson(); fred.dept", + "sales", + fred.dept ); - testcases[tc++] = new TestCase( SECTION, - "fred = new SalesPerson(); fred.quota", - 100, - fred.quota ); +new TestCase( SECTION, + "fred = new SalesPerson(); fred.quota", + 100, + fred.quota ); - testcases[tc++] = new TestCase( SECTION, - "fred = new SalesPerson(); fred.projects.length", - 0, - fred.projects.length ); +new TestCase( SECTION, + "fred = new SalesPerson(); fred.projects.length", + 0, + fred.projects.length ); - var jane = new Engineer(); +var jane = new Engineer(); - testcases[tc++] = new TestCase( SECTION, - "jane = new Engineer(); jane.name", - "", - jane.name ); +new TestCase( SECTION, + "jane = new Engineer(); jane.name", + "", + jane.name ); - testcases[tc++] = new TestCase( SECTION, - "jane = new Engineer(); jane.dept", - "engineering", - jane.dept ); +new TestCase( SECTION, + "jane = new Engineer(); jane.dept", + "engineering", + jane.dept ); - testcases[tc++] = new TestCase( SECTION, - "jane = new Engineer(); jane.projects.length", - 0, - jane.projects.length ); +new TestCase( SECTION, + "jane = new Engineer(); jane.projects.length", + 0, + jane.projects.length ); - testcases[tc++] = new TestCase( SECTION, - "jane = new Engineer(); jane.machine", - "", - jane.machine ); +new TestCase( SECTION, + "jane = new Engineer(); jane.machine", + "", + jane.machine ); - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_10.js b/mozilla/js/tests/js1_3/inherit/proto_10.js index d1f02409928..d9b74bdcaf6 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_10.js +++ b/mozilla/js/tests/js1_3/inherit/proto_10.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,31 +35,30 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_10.js - Section: - Description: Determining Instance Relationships + File Name: proto_10.js + Section: + Description: Determining Instance Relationships - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_10"; - var VERSION = "JS1_3"; - var TITLE = "Determining Instance Relationships"; +var SECTION = "proto_10"; +var VERSION = "JS1_3"; +var TITLE = "Determining Instance Relationships"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function InstanceOf( object, constructor ) { while ( object != null ) { @@ -70,19 +70,19 @@ function InstanceOf( object, constructor ) { return false; } function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; + this.name = name || ""; + this.dept = dept || "general"; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee ( name, dept, projs ) { this.base = Employee; this.base( name, dept) - this.projects = projs || new Array(); + this.projects = projs || new Array(); } WorkerBee.prototype = new Employee(); @@ -95,73 +95,60 @@ SalesPerson.prototype = new WorkerBee(); function Engineer ( name, projs, machine ) { this.base = WorkerBee; this.base( name, "engineering", projs ) - this.machine = machine || ""; + this.machine = machine || ""; } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var pat = new Engineer() - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - var pat = new Engineer() + new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__ == Engineer.prototype", - true, - pat.__proto__ == Engineer.prototype ); +new TestCase( SECTION, + "pat.__proto__.__proto__ == WorkerBee.prototype", + true, + pat.__proto__.__proto__ == WorkerBee.prototype ); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__.__proto__ == WorkerBee.prototype", - true, - pat.__proto__.__proto__ == WorkerBee.prototype ); +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__ == Employee.prototype", + true, + pat.__proto__.__proto__.__proto__ == Employee.prototype ); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__ == Employee.prototype", - true, - pat.__proto__.__proto__.__proto__ == Employee.prototype ); +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", + true, + pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", - true, - pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); - - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", - true, - pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", + true, + pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); - testcases[tc++] = new TestCase( SECTION, - "InstanceOf( pat, Engineer )", - true, - InstanceOf( pat, Engineer ) ); +new TestCase( SECTION, + "InstanceOf( pat, Engineer )", + true, + InstanceOf( pat, Engineer ) ); - testcases[tc++] = new TestCase( SECTION, - "InstanceOf( pat, WorkerBee )", - true, - InstanceOf( pat, WorkerBee ) ); +new TestCase( SECTION, + "InstanceOf( pat, WorkerBee )", + true, + InstanceOf( pat, WorkerBee ) ); - testcases[tc++] = new TestCase( SECTION, - "InstanceOf( pat, Employee )", - true, - InstanceOf( pat, Employee ) ); +new TestCase( SECTION, + "InstanceOf( pat, Employee )", + true, + InstanceOf( pat, Employee ) ); - testcases[tc++] = new TestCase( SECTION, - "InstanceOf( pat, Object )", - true, - InstanceOf( pat, Object ) ); +new TestCase( SECTION, + "InstanceOf( pat, Object )", + true, + InstanceOf( pat, Object ) ); - testcases[tc++] = new TestCase( SECTION, - "InstanceOf( pat, SalesPerson )", - false, - InstanceOf ( pat, SalesPerson ) ); - test(); +new TestCase( SECTION, + "InstanceOf( pat, SalesPerson )", + false, + InstanceOf ( pat, SalesPerson ) ); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_11.js b/mozilla/js/tests/js1_3/inherit/proto_11.js index 9fe1f6f0f25..cac87eadc07 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_11.js +++ b/mozilla/js/tests/js1_3/inherit/proto_11.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,48 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_11.js - Section: - Description: Global Information in Constructors + File Name: proto_11.js + Section: + Description: Global Information in Constructors - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_11"; - var VERSION = "JS1_3"; - var TITLE = "Global Information in Constructors"; +var SECTION = "proto_11"; +var VERSION = "JS1_3"; +var TITLE = "Global Information in Constructors"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - var idCounter = 1; +var idCounter = 1; function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; - this.id = idCounter++; + this.name = name || ""; + this.dept = dept || "general"; + this.id = idCounter++; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee ( name, dept, projs ) { this.base = Employee; this.base( name, dept) - this.projects = projs || new Array(); + this.projects = projs || new Array(); } WorkerBee.prototype = new Employee(); @@ -88,43 +89,30 @@ SalesPerson.prototype = new WorkerBee(); function Engineer ( name, projs, machine ) { this.base = WorkerBee; this.base( name, "engineering", projs ) - this.machine = machine || ""; + this.machine = machine || ""; } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - var pat = new Employee( "Toonces, Pat", "Tech Pubs" ) +var pat = new Employee( "Toonces, Pat", "Tech Pubs" ) var terry = new Employee( "O'Sherry Terry", "Marketing" ); - var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); +var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); - testcases[tc++] = new TestCase( SECTION, - "pat.id", - 5, - pat.id ); +new TestCase( SECTION, + "pat.id", + 5, + pat.id ); - testcases[tc++] = new TestCase( SECTION, - "terry.id", - 6, - terry.id ); +new TestCase( SECTION, + "terry.id", + 6, + terry.id ); - testcases[tc++] = new TestCase( SECTION, - "les.id", - 7, - les.id ); +new TestCase( SECTION, + "les.id", + 7, + les.id ); - test(); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_12.js b/mozilla/js/tests/js1_3/inherit/proto_12.js index b5374c9143c..65f2d996aa2 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_12.js +++ b/mozilla/js/tests/js1_3/inherit/proto_12.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,44 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_12.js - Section: - Description: new PrototypeObject + File Name: proto_12.js + Section: + Description: new PrototypeObject - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - No Multiple Inheritance + No Multiple Inheritance - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_12"; - var VERSION = "JS1_3"; - var TITLE = "No Multiple Inheritance"; +var SECTION = "proto_12"; +var VERSION = "JS1_3"; +var TITLE = "No Multiple Inheritance"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; - this.id = idCounter++; + this.name = name || ""; + this.dept = dept || "general"; + this.id = idCounter++; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee ( name, dept, projs ) { this.base = Employee; this.base( name, dept) - this.projects = projs || new Array(); + this.projects = projs || new Array(); } WorkerBee.prototype = new Employee(); @@ -90,7 +90,7 @@ function Engineer ( name, projs, machine, hobby ) { this.base1 = WorkerBee; this.base1( name, "engineering", projs ) - this.base2 = Hobbyist; + this.base2 = Hobbyist; this.base2( hobby ); this.projects = projs || new Array(); @@ -98,60 +98,47 @@ function Engineer ( name, projs, machine, hobby ) { } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var idCounter = 1; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - var idCounter = 1; +var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); - var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); +Hobbyist.prototype.equipment = [ "horn", "mountain", "goat" ]; - Hobbyist.prototype.equipment = [ "horn", "mountain", "goat" ]; +new TestCase( SECTION, + "les.name", + "Morris, Les", + les.name ); - testcases[tc++] = new TestCase( SECTION, - "les.name", - "Morris, Les", - les.name ); +new TestCase( SECTION, + "les.dept", + "engineering", + les.dept ); - testcases[tc++] = new TestCase( SECTION, - "les.dept", - "engineering", - les.dept ); +Array.prototype.getClass = Object.prototype.toString; - Array.prototype.getClass = Object.prototype.toString; +new TestCase( SECTION, + "les.projects.getClass()", + "[object Array]", + les.projects.getClass() ); - testcases[tc++] = new TestCase( SECTION, - "les.projects.getClass()", - "[object Array]", - les.projects.getClass() ); +new TestCase( SECTION, + "les.projects[0]", + "JavaScript", + les.projects[0] ); - testcases[tc++] = new TestCase( SECTION, - "les.projects[0]", - "JavaScript", - les.projects[0] ); +new TestCase( SECTION, + "les.machine", + "indy", + les.machine ); - testcases[tc++] = new TestCase( SECTION, - "les.machine", - "indy", - les.machine ); +new TestCase( SECTION, + "les.hobby", + "yodeling", + les.hobby ); - testcases[tc++] = new TestCase( SECTION, - "les.hobby", - "yodeling", - les.hobby ); +new TestCase( SECTION, + "les.equpment", + void 0, + les.equipment ); - testcases[tc++] = new TestCase( SECTION, - "les.equpment", - void 0, - les.equipment ); - - test(); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_2.js b/mozilla/js/tests/js1_3/inherit/proto_2.js index f0e2a63e9ee..5413971e069 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_2.js +++ b/mozilla/js/tests/js1_3/inherit/proto_2.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,43 +35,42 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_2.js - Section: - Description: new PrototypeObject + File Name: proto_2.js + Section: + Description: new PrototypeObject - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_2"; - var VERSION = "JS1_3"; - var TITLE = "new PrototypeObject"; +var SECTION = "proto_2"; +var VERSION = "JS1_3"; +var TITLE = "new PrototypeObject"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee () { - this.name = ""; - this.dept = "general"; + this.name = ""; + this.dept = "general"; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee () { - this.projects = new Array(); + this.projects = new Array(); } WorkerBee.prototype = new Employee; @@ -88,50 +88,36 @@ function Engineer () { Engineer.prototype = new WorkerBee; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var employee = new Employee(); +var manager = new Manager(); +var workerbee = new WorkerBee(); +var salesperson = new SalesPerson(); +var engineer = new Engineer(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +new TestCase( SECTION, + "employee.__proto__ == Employee.prototype", + true, + employee.__proto__ == Employee.prototype ); - var employee = new Employee(); - var manager = new Manager(); - var workerbee = new WorkerBee(); - var salesperson = new SalesPerson(); - var engineer = new Engineer(); +new TestCase( SECTION, + "manager.__proto__ == Manager.prototype", + true, + manager.__proto__ == Manager.prototype ); - testcases[tc++] = new TestCase( SECTION, - "employee.__proto__ == Employee.prototype", - true, - employee.__proto__ == Employee.prototype ); +new TestCase( SECTION, + "workerbee.__proto__ == WorkerBee.prototype", + true, + workerbee.__proto__ == WorkerBee.prototype ); - testcases[tc++] = new TestCase( SECTION, - "manager.__proto__ == Manager.prototype", - true, - manager.__proto__ == Manager.prototype ); +new TestCase( SECTION, + "salesperson.__proto__ == SalesPerson.prototype", + true, + salesperson.__proto__ == SalesPerson.prototype ); - testcases[tc++] = new TestCase( SECTION, - "workerbee.__proto__ == WorkerBee.prototype", - true, - workerbee.__proto__ == WorkerBee.prototype ); +new TestCase( SECTION, + "engineer.__proto__ == Engineer.prototype", + true, + engineer.__proto__ == Engineer.prototype ); - testcases[tc++] = new TestCase( SECTION, - "salesperson.__proto__ == SalesPerson.prototype", - true, - salesperson.__proto__ == SalesPerson.prototype ); - - testcases[tc++] = new TestCase( SECTION, - "engineer.__proto__ == Engineer.prototype", - true, - engineer.__proto__ == Engineer.prototype ); - - test(); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_3.js b/mozilla/js/tests/js1_3/inherit/proto_3.js index 9fece3d261b..664009f2a1a 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_3.js +++ b/mozilla/js/tests/js1_3/inherit/proto_3.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,43 +35,42 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_3.js - Section: - Description: Adding properties to an instance + File Name: proto_3.js + Section: + Description: Adding properties to an instance - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_3"; - var VERSION = "JS1_3"; - var TITLE = "Adding properties to an Instance"; +var SECTION = "proto_3"; +var VERSION = "JS1_3"; +var TITLE = "Adding properties to an Instance"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee () { - this.name = ""; - this.dept = "general"; + this.name = ""; + this.dept = "general"; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee () { - this.projects = new Array(); + this.projects = new Array(); } WorkerBee.prototype = new Employee(); @@ -87,32 +87,19 @@ function Engineer () { } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var jim = new Employee(); +var pat = new Employee(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - var jim = new Employee(); - var pat = new Employee(); +jim.bonus = 300; - jim.bonus = 300; - - testcases[tc++] = new TestCase( SECTION, - "jim = new Employee(); jim.bonus = 300; jim.bonus", - 300, - jim.bonus ); +new TestCase( SECTION, + "jim = new Employee(); jim.bonus = 300; jim.bonus", + 300, + jim.bonus ); - testcases[tc++] = new TestCase( SECTION, - "pat = new Employee(); pat.bonus", - void 0, - pat.bonus ); - test(); +new TestCase( SECTION, + "pat = new Employee(); pat.bonus", + void 0, + pat.bonus ); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_4.js b/mozilla/js/tests/js1_3/inherit/proto_4.js index 3bf4947861d..3079122be15 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_4.js +++ b/mozilla/js/tests/js1_3/inherit/proto_4.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_4.js - Section: - Description: new PrototypeObject + File Name: proto_4.js + Section: + Description: new PrototypeObject - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - If you add a property to an object in the prototype chain, instances of - objects that derive from that prototype should inherit that property, even - if they were instatiated after the property was added to the prototype object. + If you add a property to an object in the prototype chain, instances of + objects that derive from that prototype should inherit that property, even + if they were instatiated after the property was added to the prototype object. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_3"; - var VERSION = "JS1_3"; - var TITLE = "Adding properties to the prototype"; +var SECTION = "proto_3"; +var VERSION = "JS1_3"; +var TITLE = "Adding properties to the prototype"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee () { - this.name = ""; - this.dept = "general"; + this.name = ""; + this.dept = "general"; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee () { - this.projects = new Array(); + this.projects = new Array(); } WorkerBee.prototype = new Employee(); @@ -92,80 +92,66 @@ function Engineer () { } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var jim = new Employee(); +var terry = new Engineer(); +var sean = new SalesPerson(); +var wally = new Manager(); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +Employee.prototype.specialty = "none"; - var jim = new Employee(); - var terry = new Engineer(); - var sean = new SalesPerson(); - var wally = new Manager(); +var pat = new Employee(); +var leslie = new Engineer(); +var bubbles = new SalesPerson(); +var furry = new Manager(); - Employee.prototype.specialty = "none"; +Engineer.prototype.specialty = "code"; - var pat = new Employee(); - var leslie = new Engineer(); - var bubbles = new SalesPerson(); - var furry = new Manager(); - - Engineer.prototype.specialty = "code"; - - var chris = new Engineer(); +var chris = new Engineer(); - testcases[tc++] = new TestCase( SECTION, - "jim = new Employee(); jim.specialty", - "none", - jim.specialty ); +new TestCase( SECTION, + "jim = new Employee(); jim.specialty", + "none", + jim.specialty ); - testcases[tc++] = new TestCase( SECTION, - "terry = new Engineer(); terry.specialty", - "code", - terry.specialty ); +new TestCase( SECTION, + "terry = new Engineer(); terry.specialty", + "code", + terry.specialty ); - testcases[tc++] = new TestCase( SECTION, - "sean = new SalesPerson(); sean.specialty", - "none", - sean.specialty ); +new TestCase( SECTION, + "sean = new SalesPerson(); sean.specialty", + "none", + sean.specialty ); - testcases[tc++] = new TestCase( SECTION, - "wally = new Manager(); wally.specialty", - "none", - wally.specialty ); +new TestCase( SECTION, + "wally = new Manager(); wally.specialty", + "none", + wally.specialty ); - testcases[tc++] = new TestCase( SECTION, - "furry = new Manager(); furry.specialty", - "none", - furry.specialty ); +new TestCase( SECTION, + "furry = new Manager(); furry.specialty", + "none", + furry.specialty ); - testcases[tc++] = new TestCase( SECTION, - "pat = new Employee(); pat.specialty", - "none", - pat.specialty ); +new TestCase( SECTION, + "pat = new Employee(); pat.specialty", + "none", + pat.specialty ); - testcases[tc++] = new TestCase( SECTION, - "leslie = new Engineer(); leslie.specialty", - "code", - leslie.specialty ); +new TestCase( SECTION, + "leslie = new Engineer(); leslie.specialty", + "code", + leslie.specialty ); - testcases[tc++] = new TestCase( SECTION, - "bubbles = new SalesPerson(); bubbles.specialty", - "none", - bubbles.specialty ); +new TestCase( SECTION, + "bubbles = new SalesPerson(); bubbles.specialty", + "none", + bubbles.specialty ); - testcases[tc++] = new TestCase( SECTION, - "chris = new Employee(); chris.specialty", - "code", - chris.specialty ); - test(); +new TestCase( SECTION, + "chris = new Employee(); chris.specialty", + "code", + chris.specialty ); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_5.js b/mozilla/js/tests/js1_3/inherit/proto_5.js index 197d74a196d..78400ba74e3 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_5.js +++ b/mozilla/js/tests/js1_3/inherit/proto_5.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,45 +35,44 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_5.js - Section: - Description: Logical OR || in Constructors + File Name: proto_5.js + Section: + Description: Logical OR || in Constructors - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - This tests the logical OR opererator || syntax in constructors. + This tests the logical OR opererator || syntax in constructors. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_5"; - var VERSION = "JS1_3"; - var TITLE = "Logical OR || in Constructors"; +var SECTION = "proto_5"; +var VERSION = "JS1_3"; +var TITLE = "Logical OR || in Constructors"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; + this.name = name || ""; + this.dept = dept || "general"; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee ( projs ) { - this.projects = projs || new Array(); + this.projects = projs || new Array(); } WorkerBee.prototype = new Employee(); @@ -88,74 +88,60 @@ function Engineer ( machine ) { } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} +var pat = new Engineer( "indy" ); + +var les = new Engineer(); + +new TestCase( SECTION, + "var pat = new Engineer(\"indy\"); pat.name", + "", + pat.name ); + +new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + +new TestCase( SECTION, + "pat.projects.length", + 0, + pat.projects.length ); + +new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + +new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); + +new TestCase( SECTION, + "var les = new Engineer(); les.name", + "", + les.name ); + +new TestCase( SECTION, + "les.dept", + "engineering", + les.dept ); + +new TestCase( SECTION, + "les.projects.length", + 0, + les.projects.length ); + +new TestCase( SECTION, + "les.machine", + "", + les.machine ); + +new TestCase( SECTION, + "les.__proto__ == Engineer.prototype", + true, + les.__proto__ == Engineer.prototype ); - var pat = new Engineer( "indy" ); - - var les = new Engineer(); - - testcases[tc++] = new TestCase( SECTION, - "var pat = new Engineer(\"indy\"); pat.name", - "", - pat.name ); - - testcases[tc++] = new TestCase( SECTION, - "pat.dept", - "engineering", - pat.dept ); - - testcases[tc++] = new TestCase( SECTION, - "pat.projects.length", - 0, - pat.projects.length ); - - testcases[tc++] = new TestCase( SECTION, - "pat.machine", - "indy", - pat.machine ); - - testcases[tc++] = new TestCase( SECTION, - "pat.__proto__ == Engineer.prototype", - true, - pat.__proto__ == Engineer.prototype ); - - testcases[tc++] = new TestCase( SECTION, - "var les = new Engineer(); les.name", - "", - les.name ); - - testcases[tc++] = new TestCase( SECTION, - "les.dept", - "engineering", - les.dept ); - - testcases[tc++] = new TestCase( SECTION, - "les.projects.length", - 0, - les.projects.length ); - - testcases[tc++] = new TestCase( SECTION, - "les.machine", - "", - les.machine ); - - testcases[tc++] = new TestCase( SECTION, - "les.__proto__ == Engineer.prototype", - true, - les.__proto__ == Engineer.prototype ); - - - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_6.js b/mozilla/js/tests/js1_3/inherit/proto_6.js index 33c2534b5f0..2dedfd994ea 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_6.js +++ b/mozilla/js/tests/js1_3/inherit/proto_6.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,47 +35,46 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_6.js - Section: - Description: Logical OR || in constructors + File Name: proto_6.js + Section: + Description: Logical OR || in constructors - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - This tests the logical OR opererator || syntax in constructors. + This tests the logical OR opererator || syntax in constructors. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_6"; - var VERSION = "JS1_3"; - var TITLE = "Logical OR || in constructors"; +var SECTION = "proto_6"; +var VERSION = "JS1_3"; +var TITLE = "Logical OR || in constructors"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; + this.name = name || ""; + this.dept = dept || "general"; } function Manager () { - this.reports = []; + this.reports = []; } Manager.prototype = new Employee(); function WorkerBee ( name, dept, projs ) { this.base = Employee; this.base( name, dept) - this.projects = projs || new Array(); + this.projects = projs || new Array(); } WorkerBee.prototype = new Employee(); @@ -88,99 +88,85 @@ SalesPerson.prototype = new WorkerBee(); function Engineer ( name, projs, machine ) { this.base = WorkerBee; this.base( name, "engineering", projs ) - this.machine = machine || ""; + this.machine = machine || ""; } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - - var pat = new Engineer( "Toonces, Pat", - ["SpiderMonkey", "Rhino"], - "indy" ); - - var les = new WorkerBee( "Morris, Les", - "Training", - ["Hippo"] ) +var les = new WorkerBee( "Morris, Les", + "Training", + ["Hippo"] ) var terry = new Employee( "Boomberi, Terry", "Marketing" ); - // Pat, the Engineer +// Pat, the Engineer - testcases[tc++] = new TestCase( SECTION, - "pat.name", - "Toonces, Pat", - pat.name ); +new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); - testcases[tc++] = new TestCase( SECTION, - "pat.dept", - "engineering", - pat.dept ); +new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects.length", - 2, - pat.projects.length ); +new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects[0]", - "SpiderMonkey", - pat.projects[0] ); +new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects[1]", - "Rhino", - pat.projects[1] ); +new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); - testcases[tc++] = new TestCase( SECTION, - "pat.machine", - "indy", - pat.machine ); +new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); - // Les, the WorkerBee +// Les, the WorkerBee - testcases[tc++] = new TestCase( SECTION, - "les.name", - "Morris, Les", - les.name ); +new TestCase( SECTION, + "les.name", + "Morris, Les", + les.name ); - testcases[tc++] = new TestCase( SECTION, - "les.dept", - "Training", - les.dept ); +new TestCase( SECTION, + "les.dept", + "Training", + les.dept ); - testcases[tc++] = new TestCase( SECTION, - "les.projects.length", - 1, - les.projects.length ); +new TestCase( SECTION, + "les.projects.length", + 1, + les.projects.length ); - testcases[tc++] = new TestCase( SECTION, - "les.projects[0]", - "Hippo", - les.projects[0] ); +new TestCase( SECTION, + "les.projects[0]", + "Hippo", + les.projects[0] ); - // Terry, the Employee - testcases[tc++] = new TestCase( SECTION, - "terry.name", - "Boomberi, Terry", - terry.name ); +// Terry, the Employee +new TestCase( SECTION, + "terry.name", + "Boomberi, Terry", + terry.name ); - testcases[tc++] = new TestCase( SECTION, - "terry.dept", - "Marketing", - terry.dept ); - test(); +new TestCase( SECTION, + "terry.dept", + "Marketing", + terry.dept ); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_7.js b/mozilla/js/tests/js1_3/inherit/proto_7.js index ee53038d8c5..7faf11fd5af 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_7.js +++ b/mozilla/js/tests/js1_3/inherit/proto_7.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,107 +35,93 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_7.js - Section: - Description: Adding Properties to the Prototype Object + File Name: proto_7.js + Section: + Description: Adding Properties to the Prototype Object - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - This tests + This tests - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_6"; - var VERSION = "JS1_3"; - var TITLE = "Adding properties to the Prototype Object"; +var SECTION = "proto_6"; +var VERSION = "JS1_3"; +var TITLE = "Adding properties to the Prototype Object"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; + this.name = name || ""; + this.dept = dept || "general"; } function WorkerBee ( name, dept, projs ) { this.base = Employee; this.base( name, dept) - this.projects = projs || new Array(); + this.projects = projs || new Array(); } WorkerBee.prototype = new Employee(); function Engineer ( name, projs, machine ) { this.base = WorkerBee; this.base( name, "engineering", projs ) - this.machine = machine || ""; + this.machine = machine || ""; } // Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - var pat = new Engineer( "Toonces, Pat", - ["SpiderMonkey", "Rhino"], - "indy" ); - - Employee.prototype.specialty = "none"; +Employee.prototype.specialty = "none"; - // Pat, the Engineer +// Pat, the Engineer - testcases[tc++] = new TestCase( SECTION, - "pat.name", - "Toonces, Pat", - pat.name ); +new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); - testcases[tc++] = new TestCase( SECTION, - "pat.dept", - "engineering", - pat.dept ); +new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects.length", - 2, - pat.projects.length ); +new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects[0]", - "SpiderMonkey", - pat.projects[0] ); +new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects[1]", - "Rhino", - pat.projects[1] ); +new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); - testcases[tc++] = new TestCase( SECTION, - "pat.machine", - "indy", - pat.machine ); +new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); - testcases[tc++] = new TestCase( SECTION, - "pat.specialty", - void 0, - pat.specialty ); +new TestCase( SECTION, + "pat.specialty", + void 0, + pat.specialty ); - test(); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_8.js b/mozilla/js/tests/js1_3/inherit/proto_8.js index 79390e36c25..85391fa18a2 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_8.js +++ b/mozilla/js/tests/js1_3/inherit/proto_8.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,105 +35,91 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_8.js - Section: - Description: Adding Properties to the Prototype Object + File Name: proto_8.js + Section: + Description: Adding Properties to the Prototype Object - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_8"; - var VERSION = "JS1_3"; - var TITLE = "Adding Properties to the Prototype Object"; +var SECTION = "proto_8"; +var VERSION = "JS1_3"; +var TITLE = "Adding Properties to the Prototype Object"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; + this.name = name || ""; + this.dept = dept || "general"; } function WorkerBee ( name, dept, projs ) { this.base = Employee; this.base( name, dept) - this.projects = projs || new Array(); + this.projects = projs || new Array(); } WorkerBee.prototype = new Employee(); function Engineer ( name, projs, machine ) { this.base = WorkerBee; this.base( name, "engineering", projs ) - this.machine = machine || ""; + this.machine = machine || ""; } Engineer.prototype = new WorkerBee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - var pat = new Engineer( "Toonces, Pat", - ["SpiderMonkey", "Rhino"], - "indy" ); - - Employee.prototype.specialty = "none"; +Employee.prototype.specialty = "none"; - // Pat, the Engineer +// Pat, the Engineer - testcases[tc++] = new TestCase( SECTION, - "pat.name", - "Toonces, Pat", - pat.name ); +new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); - testcases[tc++] = new TestCase( SECTION, - "pat.dept", - "engineering", - pat.dept ); +new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects.length", - 2, - pat.projects.length ); +new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects[0]", - "SpiderMonkey", - pat.projects[0] ); +new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects[1]", - "Rhino", - pat.projects[1] ); +new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); - testcases[tc++] = new TestCase( SECTION, - "pat.machine", - "indy", - pat.machine ); +new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); - testcases[tc++] = new TestCase( SECTION, - "pat.specialty", - "none", - pat.specialty ); +new TestCase( SECTION, + "pat.specialty", + "none", + pat.specialty ); - test(); +test(); diff --git a/mozilla/js/tests/js1_3/inherit/proto_9.js b/mozilla/js/tests/js1_3/inherit/proto_9.js index 2132bfa1d1b..4d7c2ca6bc7 100644 --- a/mozilla/js/tests/js1_3/inherit/proto_9.js +++ b/mozilla/js/tests/js1_3/inherit/proto_9.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,83 +35,69 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: proto_9.js - Section: - Description: Local versus Inherited Values + File Name: proto_9.js + Section: + Description: Local versus Inherited Values - This tests Object Hierarchy and Inheritance, as described in the document - Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 - 15:19:34 on http://devedge.netscape.com/. Current URL: - http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm - This tests the syntax ObjectName.prototype = new PrototypeObject using the - Employee example in the document referenced above. + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. - This tests + This tests - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "proto_9"; - var VERSION = "JS1_3"; - var TITLE = "Local versus Inherited Values"; +var SECTION = "proto_9"; +var VERSION = "JS1_3"; +var TITLE = "Local versus Inherited Values"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); - - var testcases = new Array(); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); function Employee ( name, dept ) { - this.name = name || ""; - this.dept = dept || "general"; + this.name = name || ""; + this.dept = dept || "general"; } function WorkerBee ( name, dept, projs ) { this.projects = new Array(); } WorkerBee.prototype = new Employee(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} - var pat = new WorkerBee() +var pat = new WorkerBee() Employee.prototype.specialty = "none"; - Employee.prototype.name = "Unknown"; +Employee.prototype.name = "Unknown"; - Array.prototype.getClass = Object.prototype.toString; +Array.prototype.getClass = Object.prototype.toString; - // Pat, the WorkerBee +// Pat, the WorkerBee - testcases[tc++] = new TestCase( SECTION, - "pat.name", - "", - pat.name ); +new TestCase( SECTION, + "pat.name", + "", + pat.name ); - testcases[tc++] = new TestCase( SECTION, - "pat.dept", - "general", - pat.dept ); +new TestCase( SECTION, + "pat.dept", + "general", + pat.dept ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects.getClass", - "[object Array]", - pat.projects.getClass() ); +new TestCase( SECTION, + "pat.projects.getClass", + "[object Array]", + pat.projects.getClass() ); - testcases[tc++] = new TestCase( SECTION, - "pat.projects.length", - 0, - pat.projects.length ); +new TestCase( SECTION, + "pat.projects.length", + 0, + pat.projects.length ); - test(); \ No newline at end of file +test(); diff --git a/mozilla/js/tests/js1_3/inherit/shell.js b/mozilla/js/tests/js1_3/inherit/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/misc/browser.js b/mozilla/js/tests/js1_3/misc/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/misc/shell.js b/mozilla/js/tests/js1_3/misc/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/regress/browser.js b/mozilla/js/tests/js1_3/regress/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/regress/delete-001.js b/mozilla/js/tests/js1_3/regress/delete-001.js index 87525f86a4e..17c7ac50d7d 100644 --- a/mozilla/js/tests/js1_3/regress/delete-001.js +++ b/mozilla/js/tests/js1_3/regress/delete-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,61 +35,47 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: delete-001.js - Section: regress - Description: + File Name: delete-001.js + Section: regress + Description: - Regression test for - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=108736 + Regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=108736 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "JS1_2"; - var VERSION = "JS1_2"; - var TITLE = "The variable statment"; +var SECTION = "JS1_2"; +var VERSION = "JS1_2"; +var TITLE = "The variable statement"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +// delete all properties of the global object +// per ecma, this does not affect variables in the global object declared +// with var or functions - // delete all properties of the global object - // per ecma, this does not affect variables in the global object declared - // with var or functions - - for ( p in this ) { - delete p; - } - - var result =""; - - for ( p in this ) { - result += String( p ); - } - - // not too picky here... just want to make sure we didn't crash or something - - testcases[testcases.length] = new TestCase( SECTION, - "delete all properties of the global object", - "PASSED", - result == "" ? "FAILED" : "PASSED" ); - - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +for ( p in this ) { + delete p; } + +var result =""; + +for ( p in this ) { + result += String( p ); +} + +// not too picky here... just want to make sure we didn't crash or something + +new TestCase( SECTION, + "delete all properties of the global object", + "PASSED", + result == "" ? "FAILED" : "PASSED" ); + + +test(); + diff --git a/mozilla/js/tests/js1_3/regress/function-001-n.js b/mozilla/js/tests/js1_3/regress/function-001-n.js index dc656e898cb..fc17484bd61 100644 --- a/mozilla/js/tests/js1_3/regress/function-001-n.js +++ b/mozilla/js/tests/js1_3/regress/function-001-n.js @@ -63,9 +63,7 @@ startTest(); writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - testcases[tc++] = new TestCase( + new TestCase( SECTION, "eval(\"function f(){}function g(){}\")", "error", @@ -74,16 +72,3 @@ test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_3/regress/function-002.js b/mozilla/js/tests/js1_3/regress/function-002.js index 617d51e6ed4..8bc72d6dbb9 100644 --- a/mozilla/js/tests/js1_3/regress/function-002.js +++ b/mozilla/js/tests/js1_3/regress/function-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,57 +35,43 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: function-002.js - Section: - Description: + File Name: function-002.js + Section: + Description: - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=249579 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=249579 - function definitions in conditional statements should be allowed. + function definitions in conditional statements should be allowed. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "function-002"; - var VERSION = "JS1_3"; - var TITLE = "Regression test for 249579"; - var BUGNUMBER="249579"; +var SECTION = "function-002"; +var VERSION = "JS1_3"; +var TITLE = "Regression test for 249579"; +var BUGNUMBER="249579"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - testcases[tc++] = new TestCase( - SECTION, - "0?function(){}:0", - 0, - 0?function(){}:0 ); +new TestCase( + SECTION, + "0?function(){}:0", + 0, + 0?function(){}:0 ); - bar = true; - foo = bar ? function () { return true; } : function() { return false; }; +bar = true; +foo = bar ? function () { return true; } : function() { return false; }; - testcases[tc++] = new TestCase( - SECTION, - "bar = true; foo = bar ? function () { return true; } : function() { return false; }; foo()", - true, - foo() ); +new TestCase( + SECTION, + "bar = true; foo = bar ? function () { return true; } : function() { return false; }; foo()", + true, + foo() ); - test(); +test(); -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_3/regress/in-001.js b/mozilla/js/tests/js1_3/regress/in-001.js index d9dc685d2c1..41364b134ab 100644 --- a/mozilla/js/tests/js1_3/regress/in-001.js +++ b/mozilla/js/tests/js1_3/regress/in-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,48 +35,34 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: in-001.js - Section: - Description: + File Name: in-001.js + Section: + Description: - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=196109 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=196109 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "in-001"; - var VERSION = "JS1_3"; - var TITLE = "Regression test for 196109"; - var BUGNUMBER="196109"; +var SECTION = "in-001"; +var VERSION = "JS1_3"; +var TITLE = "Regression test for 196109"; +var BUGNUMBER="196109"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +o = {}; +o.foo = 'sil'; - o = {}; - o.foo = 'sil'; +new TestCase( + SECTION, + "\"foo\" in o", + true, + "foo" in o ); - testcases[tc++] = new TestCase( - SECTION, - "\"foo\" in o", - true, - "foo" in o ); +test(); - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} diff --git a/mozilla/js/tests/js1_3/regress/new-001.js b/mozilla/js/tests/js1_3/regress/new-001.js index 6d40976cb25..70fd02b8192 100644 --- a/mozilla/js/tests/js1_3/regress/new-001.js +++ b/mozilla/js/tests/js1_3/regress/new-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,102 +35,87 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: new-001.js - Section: - Description: + File Name: new-001.js + Section: + Description: - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103 - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "new-001"; - var VERSION = "JS1_3"; - var TITLE = "new-001"; - var BUGNUMBER="31567"; +var SECTION = "new-001"; +var VERSION = "JS1_3"; +var TITLE = "new-001"; +var BUGNUMBER="31567"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +function Test_One (x) { + this.v = x+1; + return x*2 + } - function Test_One (x) { - this.v = x+1; - return x*2 - } - - function Test_Two( x, y ) { - this.v = x; - return y; - } - - testcases[tc++] = new TestCase( - SECTION, - "Test_One(18)", - 36, - Test_One(18) ); - - testcases[tc++] = new TestCase( - SECTION, - "new Test_One(18)", - "[object Object]", - new Test_One(18) +"" ); - - testcases[tc++] = new TestCase( - SECTION, - "new Test_One(18).v", - 19, - new Test_One(18).v ); - - testcases[tc++] = new TestCase( - SECTION, - "Test_Two(2,7)", - 7, - Test_Two(2,7) ); - - testcases[tc++] = new TestCase( - SECTION, - "new Test_Two(2,7)", - "[object Object]", - new Test_Two(2,7) +"" ); - - testcases[tc++] = new TestCase( - SECTION, - "new Test_Two(2,7).v", - 2, - new Test_Two(2,7).v ); - - testcases[tc++] = new TestCase( - SECTION, - "new (Function)(\"x\", \"return x+3\")(5,6)", - 8, - new (Function)("x","return x+3")(5,6) ); - - testcases[tc++] = new TestCase( - SECTION, - "new new Test_Two(String, 2).v(0123)", - "83", - new new Test_Two(String, 2).v(0123) +""); - - testcases[tc++] = new TestCase( - SECTION, - "new new Test_Two(String, 2).v(0123).length", - 2, - new new Test_Two(String, 2).v(0123).length ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +function Test_Two( x, y ) { + this.v = x; + return y; } + +new TestCase( + SECTION, + "Test_One(18)", + 36, + Test_One(18) ); + +new TestCase( + SECTION, + "new Test_One(18)", + "[object Object]", + new Test_One(18) +"" ); + +new TestCase( + SECTION, + "new Test_One(18).v", + 19, + new Test_One(18).v ); + +new TestCase( + SECTION, + "Test_Two(2,7)", + 7, + Test_Two(2,7) ); + +new TestCase( + SECTION, + "new Test_Two(2,7)", + "[object Object]", + new Test_Two(2,7) +"" ); + +new TestCase( + SECTION, + "new Test_Two(2,7).v", + 2, + new Test_Two(2,7).v ); + +new TestCase( + SECTION, + "new (Function)(\"x\", \"return x+3\")(5,6)", + 8, + new (Function)("x","return x+3")(5,6) ); + +new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123)", + "83", + new new Test_Two(String, 2).v(0123) +""); + +new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123).length", + 2, + new new Test_Two(String, 2).v(0123).length ); + +test(); diff --git a/mozilla/js/tests/js1_3/regress/shell.js b/mozilla/js/tests/js1_3/regress/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_3/regress/switch-001.js b/mozilla/js/tests/js1_3/regress/switch-001.js index b5c08b41ea5..a6f0c7342d7 100644 --- a/mozilla/js/tests/js1_3/regress/switch-001.js +++ b/mozilla/js/tests/js1_3/regress/switch-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -34,62 +35,48 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + /** - File Name: switch-001.js - Section: - Description: + File Name: switch-001.js + Section: + Description: - http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 - Verify that switches do not use strict equality in - versions of JavaScript < 1.4. It's now been decided that - we won't put in version switches, so all switches will - be ECMA. + Verify that switches do not use strict equality in + versions of JavaScript < 1.4. It's now been decided that + we won't put in version switches, so all switches will + be ECMA. - Author: christine@netscape.com - Date: 12 november 1997 + Author: christine@netscape.com + Date: 12 november 1997 */ - var SECTION = "switch-001"; - var VERSION = "JS1_3"; - var TITLE = "switch-001"; - var BUGNUMBER="315767"; +var SECTION = "switch-001"; +var VERSION = "JS1_3"; +var TITLE = "switch-001"; +var BUGNUMBER="315767"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +result = "fail: did not enter switch"; - result = "fail: did not enter switch"; - - switch (true) { - case 1: - result = "fail: version 130 should force strict equality"; - break; - case true: - result = "pass"; - break; - default: - result = "fail: evaluated default statement"; - } - - testcases[tc++] = new TestCase( - SECTION, - "switch / case should use strict equality in version of JS < 1.4", - "pass", - result ); - - test(); - -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); - - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); +switch (true) { +case 1: + result = "fail: version 130 should force strict equality"; + break; +case true: + result = "pass"; + break; +default: + result = "fail: evaluated default statement"; } + +new TestCase( + SECTION, + "switch / case should use strict equality in version of JS < 1.4", + "pass", + result ); + +test(); + diff --git a/mozilla/js/tests/js1_3/shell.js b/mozilla/js/tests/js1_3/shell.js index dc0ec4ef35e..e9e3e26ed3e 100644 --- a/mozilla/js/tests/js1_3/shell.js +++ b/mozilla/js/tests/js1_3/shell.js @@ -1,133 +1,177 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * + */ + + +/* + * JavaScript shared functions file for running the tests in either + * stand-alone JavaScript engine. To run a test, first load this file, + * then load the test script. + */ + var completed = false; -var testcases; -var tc = 0; +var testcases = new Array(); +var tc = testcases.length; -SECTION = ""; -VERSION = ""; -BUGNUMBER = ""; -DEBUG = false; +var SECTION = ""; +var VERSION = ""; +var BUGNUMBER = ""; +/* + * constant strings + */ var GLOBAL = "[object global]"; var PASSED = " PASSED!" var FAILED = " FAILED! expected: "; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var DEBUG = false; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -/* wrapper for test cas constructor that doesn't require the SECTION +/* + * wrapper for test case constructor that doesn't require the SECTION * argument. */ function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); + new TestCase( SECTION, description, expect, actual ); } + +/* + * TestCase constructor + * + */ function TestCase( n, d, e, a ) { - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; - this.bugnumber = BUGNUMBER; + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; - this.passed = getTestCaseResult( this.expect, this.actual ); - if ( DEBUG ) { - writeLineToLog( "added " + this.description ); - } + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } + /* + * testcases are solely maintained in the TestCase + * constructor. tc will _always_ point to one past the + * last testcase. If an exception occurs during the call + * to the constructor, then we are assured that the tc + * index has not been incremented. + */ + + testcases[tc++] = this; } + +/* + * Set up test environment. + * + */ function startTest() { - // JavaScript 1.3 is supposed to be compliant ecma version 1.0 - if ( VERSION == "ECMA_1" ) { - version ( 130 ); - } - if ( VERSION == "JS_1.3" ) { - version ( 130 ); - } - if ( VERSION == "JS_1.2" ) { - version ( 120 ); - } - if ( VERSION == "JS_1.1" ) { - version ( 110 ); - } - // for ecma version 2.0, we will leave the javascript version to - // the default ( for now ). + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( 130 ); + } + if ( VERSION == "JS_1.3" ) { + version ( 130 ); + } + if ( VERSION == "JS_1.2" ) { + version ( 120 ); + } + if ( VERSION == "JS_1.1" ) { + version ( 110 ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; + writeHeaderToLog( SECTION + " "+ TITLE); + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } } +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + try + { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + catch(e) + { + writeLineToLog('test(): empty testcase for tc = ' + tc + ' ' + e); + } + } + stopTest(); + return ( testcases ); +} + +/* + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ function getTestCaseResult( expect, actual ) { - // because ( NaN == NaN ) always returns false, need to do - // a special compare to see if we got the right result. - if ( actual != actual ) { - if ( typeof actual == "object" ) { - actual = "NaN object"; - } else { - actual = "NaN number"; - } - } - if ( expect != expect ) { - if ( typeof expect == "object" ) { - expect = "NaN object"; - } else { - expect = "NaN number"; - } - } + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } - var passed = ( expect == actual ) ? true : false; + var passed = ( expect == actual ) ? true : false; - // if both objects are numbers - // need to replace w/ IEEE standard for rounding - if ( !passed - && typeof(actual) == "number" - && typeof(expect) == "number" - ) { - if ( Math.abs(actual-expect) < 0.0000001 ) { - passed = true; - } - } + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } - // verify type is the same - if ( typeof(expect) != typeof(actual) ) { - passed = false; - } + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } - return passed; -} -function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; -} -function writeFormattedResult( expect, actual, string, passed ) { - var s = TT + string ; - - for ( k = 0; - k < (60 - string.length >= 0 ? 60 - string.length : 5) ; - k++ ) { - } - - s += B ; - s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; - - writeLineToLog( s + FONT_ + B_ + TT_ ); - - return passed; + return passed; } /* * Begin printing functions. These functions use the shell's @@ -137,15 +181,15 @@ function writeFormattedResult( expect, actual, string, passed ) { */ function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; } function writeFormattedResult( expect, actual, string, passed ) { - var s = string ; - s += ( passed ) ? PASSED : FAILED + expect; - writeLineToLog( s); - return passed; + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; } function writeLineToLog( string ) { print( string ); @@ -155,9 +199,29 @@ function writeHeaderToLog( string ) { } /* end of print functions */ + +/* + * When running in the shell, run the garbage collector after the + * test has completed. + */ + function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } + var gc; + if ( gc != undefined ) { + gc(); + } } + +/* + * Convenience function for displaying failed test cases. Useful + * when running tests manually. + * + */ +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + writeLineToLog( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} + diff --git a/mozilla/js/tests/js1_4/Eval/browser.js b/mozilla/js/tests/js1_4/Eval/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_4/Eval/eval-001.js b/mozilla/js/tests/js1_4/Eval/eval-001.js index 8e7b563df76..8c12641a427 100644 --- a/mozilla/js/tests/js1_4/Eval/eval-001.js +++ b/mozilla/js/tests/js1_4/Eval/eval-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -63,28 +64,25 @@ * of the evalnative method. * */ - var SECTION = "eval-001.js"; - var VERSION = "JS1_4"; - var TITLE = "Calling eval indirectly should NOT fail in version 140"; - var BUGNUMBER="38512"; +var SECTION = "eval-001.js"; +var VERSION = "JS1_4"; +var TITLE = "Calling eval indirectly should NOT fail in version 140"; +var BUGNUMBER="38512"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var MY_EVAL = eval; +var RESULT = ""; +var EXPECT = "abcdefg"; +MY_EVAL( "RESULT = EXPECT" ); - var MY_EVAL = eval; - var RESULT = ""; - var EXPECT = "abcdefg"; +new TestCase( + SECTION, + "Call eval indirectly", + EXPECT, + RESULT ); - MY_EVAL( "RESULT = EXPECT" ); - - testcases[tc++] = new TestCase( - SECTION, - "Call eval indirectly", - EXPECT, - RESULT ); - - test(); +test(); diff --git a/mozilla/js/tests/js1_4/Eval/eval-002.js b/mozilla/js/tests/js1_4/Eval/eval-002.js index 2f69f636ff5..a13804cf74a 100644 --- a/mozilla/js/tests/js1_4/Eval/eval-002.js +++ b/mozilla/js/tests/js1_4/Eval/eval-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -63,30 +64,28 @@ * of the evalnative method. * */ - var SECTION = "eval-002.js"; - var VERSION = "JS1_4"; - var TITLE = "Calling eval indirectly should NOT fail in version 140"; - var BUGNUMBER="38512"; +var SECTION = "eval-002.js"; +var VERSION = "JS1_4"; +var TITLE = "Calling eval indirectly should NOT fail in version 140"; +var BUGNUMBER="38512"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var MY_EVAL = eval; +var RESULT = ""; +var EXPECT = 1 + "testString" - var MY_EVAL = eval; - var RESULT = ""; - var EXPECT = 1 + "testString" +EvalTest(); - EvalTest(); - - test(); +test(); function EvalTest() { - MY_EVAL( "RESULT = EXPECT" ); + MY_EVAL( "RESULT = EXPECT" ); - testcases[tc++] = new TestCase( + new TestCase( SECTION, "Call eval indirectly", EXPECT, diff --git a/mozilla/js/tests/js1_4/Eval/eval-003.js b/mozilla/js/tests/js1_4/Eval/eval-003.js index 5411a56c47c..0703fe94934 100644 --- a/mozilla/js/tests/js1_4/Eval/eval-003.js +++ b/mozilla/js/tests/js1_4/Eval/eval-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -63,38 +64,35 @@ * of the evalnative method. * */ - var SECTION = "eval-003.js"; - var VERSION = "JS1_4"; - var TITLE = "Calling eval indirectly should NOT fail in version 140"; - var BUGNUMBER="38512"; +var SECTION = "eval-003.js"; +var VERSION = "JS1_4"; +var TITLE = "Calling eval indirectly should NOT fail in version 140"; +var BUGNUMBER="38512"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - var MY_EVAL = eval; - var RESULT = ""; - var EXPECT= ""; - var h = function f(x,y){var g = function(z){return Math.exp(z);}; return g(x+y);}; +var MY_EVAL = eval; +var RESULT = ""; +var EXPECT= ""; +var h = function f(x,y){var g = function(z){return Math.exp(z);}; return g(x+y);}; - new EvalTest(); +new EvalTest(); - test(); +test(); function EvalTest() { - with( this ) - { - MY_EVAL( "RESULT = h(-1, 1)" ); - EXPECT = 1; //The base e to the power (-1 + 1), i.e. the power 0, equals 1 .... + with( this ) { + MY_EVAL( "RESULT = h(-1, 1)" ); + EXPECT = 1; //The base e to the power (-1 + 1), i.e. the power 0, equals 1 .... - testcases[tc++] = new TestCase( - SECTION, - "Call eval indirectly", - EXPECT, - RESULT ); + new TestCase( + SECTION, + "Call eval indirectly", + EXPECT, + RESULT ); } } diff --git a/mozilla/js/tests/js1_4/Eval/shell.js b/mozilla/js/tests/js1_4/Eval/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_4/Functions/browser.js b/mozilla/js/tests/js1_4/Functions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_4/Functions/function-001.js b/mozilla/js/tests/js1_4/Functions/function-001.js index 118b4317a09..932dd9fd42c 100644 --- a/mozilla/js/tests/js1_4/Functions/function-001.js +++ b/mozilla/js/tests/js1_4/Functions/function-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -65,57 +66,55 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "function-001.js"; - var VERSION = "JS1_4"; - var TITLE = "Accessing the arguments property of a function object"; - var BUGNUMBER="324455"; - startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +var SECTION = "function-001.js"; +var VERSION = "JS1_4"; +var TITLE = "Accessing the arguments property of a function object"; +var BUGNUMBER="324455"; +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); - - testcases[tc++] = new TestCase( - SECTION, - "return function.arguments", - "P", - TestFunction_2("P", "A","S","S")[0] +""); +new TestCase( + SECTION, + "return function.arguments", + "P", + TestFunction_2("P", "A","S","S")[0] +""); - testcases[tc++] = new TestCase( - SECTION, - "return arguments", - "P", - TestFunction_1( "P", "A", "S", "S" )[0] +""); +new TestCase( + SECTION, + "return arguments", + "P", + TestFunction_1( "P", "A", "S", "S" )[0] +""); - testcases[tc++] = new TestCase( - SECTION, - "return arguments when function contains an arguments property", - "PASS", - TestFunction_3( "P", "A", "S", "S" ) +""); +new TestCase( + SECTION, + "return arguments when function contains an arguments property", + "PASS", + TestFunction_3( "P", "A", "S", "S" ) +""); - testcases[tc++] = new TestCase( - SECTION, - "return function.arguments when function contains an arguments property", - "PASS", - TestFunction_4( "F", "A", "I", "L" ) +""); +new TestCase( + SECTION, + "return function.arguments when function contains an arguments property", + "PASS", + TestFunction_4( "F", "A", "I", "L" ) +""); - test(); +test(); - function TestFunction_1( a, b, c, d, e ) { - return arguments; - } +function TestFunction_1( a, b, c, d, e ) { + return arguments; +} - function TestFunction_2( a, b, c, d, e ) { - return TestFunction_2.arguments; - } +function TestFunction_2( a, b, c, d, e ) { + return TestFunction_2.arguments; +} - function TestFunction_3( a, b, c, d, e ) { - var arguments = "PASS"; - return arguments; - } +function TestFunction_3( a, b, c, d, e ) { + var arguments = "PASS"; + return arguments; +} - function TestFunction_4( a, b, c, d, e ) { - var arguments = "PASS"; - return TestFunction_4.arguments; - } +function TestFunction_4( a, b, c, d, e ) { + var arguments = "PASS"; + return TestFunction_4.arguments; +} diff --git a/mozilla/js/tests/js1_4/Functions/shell.js b/mozilla/js/tests/js1_4/Functions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_4/README b/mozilla/js/tests/js1_4/README new file mode 100755 index 00000000000..53a00cf68b3 --- /dev/null +++ b/mozilla/js/tests/js1_4/README @@ -0,0 +1 @@ +JavaScript 1.4 diff --git a/mozilla/js/tests/js1_4/Regress/browser.js b/mozilla/js/tests/js1_4/Regress/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_4/Regress/date-001-n.js b/mozilla/js/tests/js1_4/Regress/date-001-n.js index 5753a78c488..a83bad3dfa4 100644 --- a/mozilla/js/tests/js1_4/Regress/date-001-n.js +++ b/mozilla/js/tests/js1_4/Regress/date-001-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -43,28 +44,30 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "date-001-n.js"; - var VERSION = "JS1_4"; - var TITLE = "Regression test case for 299903"; - var BUGNUMBER="299903"; +var SECTION = "date-001-n.js"; +var VERSION = "JS1_4"; +var TITLE = "Regression test case for 299903"; +var BUGNUMBER="299903"; - startTest(); +startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +function MyDate() { + this.foo = "bar"; +} +MyDate.prototype = new Date(); - function MyDate() { - this.foo = "bar"; - } - MyDate.prototype = new Date(); +DESCRIPTION = +"function MyDate() { this.foo = \"bar\"; }; MyDate.prototype = new Date(); new MyDate().toString()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( - SECTION, - "function MyDate() { this.foo = \"bar\"; }; "+ - "MyDate.prototype = new Date(); " + - "new MyDate().toString()", - "error", - new MyDate().toString() ); +new TestCase( + SECTION, + "function MyDate() { this.foo = \"bar\"; }; "+ + "MyDate.prototype = new Date(); " + + "new MyDate().toString()", + "error", + new MyDate().toString() ); - test(); +test(); diff --git a/mozilla/js/tests/js1_4/Regress/function-001.js b/mozilla/js/tests/js1_4/Regress/function-001.js index 969fc9ee645..097e9a10ab5 100644 --- a/mozilla/js/tests/js1_4/Regress/function-001.js +++ b/mozilla/js/tests/js1_4/Regress/function-001.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -47,48 +48,46 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "function-001.js"; - var VERSION = "JS1_4"; - var TITLE = "Regression test case for 325843"; - var BUGNUMBER="3258435"; - startTest(); +var SECTION = "function-001.js"; +var VERSION = "JS1_4"; +var TITLE = "Regression test case for 325843"; +var BUGNUMBER="3258435"; +startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +eval("function f1 (a){ var a,b; }"); - eval("function f1 (a){ var a,b; }"); +function f2( a ) { var a, b; }; - function f2( a ) { var a, b; }; +new TestCase( + SECTION, + "eval(\"function f1 (a){ var a,b; }\"); "+ + "function f2( a ) { var a, b; }; typeof f1", + "function", + typeof f1 ); - testcases[tc++] = new TestCase( - SECTION, - "eval(\"function f1 (a){ var a,b; }\"); "+ - "function f2( a ) { var a, b; }; typeof f1", - "function", - typeof f1 ); +// force a function decompilation - // force a function decompilation +new TestCase( + SECTION, + "typeof f1.toString()", + "string", + typeof f1.toString() ); - testcases[tc++] = new TestCase( - SECTION, - "typeof f1.toString()", - "string", - typeof f1.toString() ); +new TestCase( + SECTION, + "typeof f2", + "function", + typeof f2 ); - testcases[tc++] = new TestCase( - SECTION, - "typeof f2", - "function", - typeof f2 ); +// force a function decompilation - // force a function decompilation +new TestCase( + SECTION, + "typeof f2.toString()", + "string", + typeof f2.toString() ); - testcases[tc++] = new TestCase( - SECTION, - "typeof f2.toString()", - "string", - typeof f2.toString() ); - - test(); +test(); diff --git a/mozilla/js/tests/js1_4/Regress/function-002.js b/mozilla/js/tests/js1_4/Regress/function-002.js index 6f0df97d4e8..f6881a1bc84 100644 --- a/mozilla/js/tests/js1_4/Regress/function-002.js +++ b/mozilla/js/tests/js1_4/Regress/function-002.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -61,78 +62,76 @@ * 1,2, giving function f2(){}. This should be legal by the testsuite's lights." * */ - var SECTION = "function-002.js"; - var VERSION = "JS1_4"; - var TITLE = "Regression test case for 325843"; - var BUGNUMBER="330462"; +var SECTION = "function-002.js"; +var VERSION = "JS1_4"; +var TITLE = "Regression test case for 325843"; +var BUGNUMBER="330462"; - startTest(); +startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +dec1 = "function f1(x,y){++x, --y}"; +dec2 = "function f2(){var y; f1(1,2); y=new Date(); writeLineToLog(y.toString())}"; - dec1 = "function f1(x,y){++x, --y}"; - dec2 = "function f2(){var y; f1(1,2); y=new Date(); print(y.toString())}"; +eval(dec1); +eval(dec2); - eval(dec1); - eval(dec2); - - testcases[tc++] = new TestCase( - SECTION, - "typeof f1", - "function", - typeof f1 ); +new TestCase( + SECTION, + "typeof f1", + "function", + typeof f1 ); - // force a function decompilation - testcases[tc++] = new TestCase( - SECTION, - "f1.toString() == dec1", - true, - StripSpaces(f1.toString()) == StripSpaces(dec1)); +// force a function decompilation +new TestCase( + SECTION, + "f1.toString() == dec1", + true, + StripSpaces(f1.toString()) == StripSpaces(dec1)); - testcases[tc++] = new TestCase( - SECTION, - "typeof f2", - "function", - typeof f2 ); +new TestCase( + SECTION, + "typeof f2", + "function", + typeof f2 ); - // force a function decompilation +// force a function decompilation - testcases[tc++] = new TestCase( - SECTION, - "f2.toString() == dec2", - true, - StripSpaces(f2.toString()) == StripSpaces(dec2)); +new TestCase( + SECTION, + "f2.toString() == dec2", + true, + StripSpaces(f2.toString()) == StripSpaces(dec2)); - test(); +test(); - function StripSpaces( s ) { - var strippedString = ""; - for ( var currentChar = 0; currentChar < s.length; currentChar++ ) { - if (!IsWhiteSpace(s.charAt(currentChar))) { - strippedString += s.charAt(currentChar); - } - } - return strippedString; +function StripSpaces( s ) { + var strippedString = ""; + for ( var currentChar = 0; currentChar < s.length; currentChar++ ) { + if (!IsWhiteSpace(s.charAt(currentChar))) { + strippedString += s.charAt(currentChar); + } } + return strippedString; +} - function IsWhiteSpace( string ) { - var cc = string.charCodeAt(0); +function IsWhiteSpace( string ) { + var cc = string.charCodeAt(0); - switch (cc) { - case (0x0009): - case (0x000B): - case (0x000C): - case (0x0020): - case (0x000A): - case (0x000D): - case ( 59 ): // let's strip out semicolons, too - return true; - break; - default: - return false; - } + switch (cc) { + case (0x0009): + case (0x000B): + case (0x000C): + case (0x0020): + case (0x000A): + case (0x000D): + case ( 59 ): // let's strip out semicolons, too + return true; + break; + default: + return false; } +} diff --git a/mozilla/js/tests/js1_4/Regress/function-003.js b/mozilla/js/tests/js1_4/Regress/function-003.js index c7d79cda73d..0c505a60cc2 100644 --- a/mozilla/js/tests/js1_4/Regress/function-003.js +++ b/mozilla/js/tests/js1_4/Regress/function-003.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -43,50 +44,48 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "toString-001.js"; - var VERSION = "JS1_4"; - var TITLE = "Regression test case for 104766"; - var BUGNUMBER="310514"; +var SECTION = "toString-001.js"; +var VERSION = "JS1_4"; +var TITLE = "Regression test case for 104766"; +var BUGNUMBER="310514"; - startTest(); +startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +new TestCase( + SECTION, + "StripSpaces(Array.prototype.concat.toString()).substring(0,17)", + "functionconcat(){", + StripSpaces(Array.prototype.concat.toString()).substring(0,17)); - testcases[tc++] = new TestCase( - SECTION, - "StripSpaces(Array.prototype.concat.toString()).substring(0,17)", - "functionconcat(){", - StripSpaces(Array.prototype.concat.toString()).substring(0,17)); +test(); - test(); - - function StripSpaces( s ) { - for ( var currentChar = 0, strippedString=""; - currentChar < s.length; currentChar++ ) - { - if (!IsWhiteSpace(s.charAt(currentChar))) { - strippedString += s.charAt(currentChar); - } - } - return strippedString; +function StripSpaces( s ) { + for ( var currentChar = 0, strippedString=""; + currentChar < s.length; currentChar++ ) + { + if (!IsWhiteSpace(s.charAt(currentChar))) { + strippedString += s.charAt(currentChar); } + } + return strippedString; +} - function IsWhiteSpace( string ) { - var cc = string.charCodeAt(0); - switch (cc) { - case (0x0009): - case (0x000B): - case (0x000C): - case (0x0020): - case (0x000A): - case (0x000D): - case ( 59 ): // let's strip out semicolons, too - return true; - break; - default: - return false; - } - } +function IsWhiteSpace( string ) { + var cc = string.charCodeAt(0); + switch (cc) { + case (0x0009): + case (0x000B): + case (0x000C): + case (0x0020): + case (0x000A): + case (0x000D): + case ( 59 ): // let's strip out semicolons, too + return true; + break; + default: + return false; + } +} diff --git a/mozilla/js/tests/js1_4/Regress/function-004-n.js b/mozilla/js/tests/js1_4/Regress/function-004-n.js index d4ab8b7ae9a..5a646be88db 100644 --- a/mozilla/js/tests/js1_4/Regress/function-004-n.js +++ b/mozilla/js/tests/js1_4/Regress/function-004-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -43,24 +44,25 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "funtion-004-n.js"; - var VERSION = "JS1_4"; - var TITLE = "Regression test case for 310502"; - var BUGNUMBER="310502"; +var SECTION = "funtion-004-n.js"; +var VERSION = "JS1_4"; +var TITLE = "Regression test case for 310502"; +var BUGNUMBER="310502"; - startTest(); +startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var o = {}; +o.call = Function.prototype.call; - var o = {}; - o.call = Function.prototype.call; +DESCRIPTION = "var o = {}; o.call = Function.prototype.call; o.call()"; +EXPECTED = "error"; - testcases[tc++] = new TestCase( - SECTION, - "var o = {}; o.call = Function.prototype.call; o.call()", - "error", - o.call() ); +new TestCase( + SECTION, + "var o = {}; o.call = Function.prototype.call; o.call()", + "error", + o.call() ); - test(); +test(); diff --git a/mozilla/js/tests/js1_4/Regress/regress-7224.js b/mozilla/js/tests/js1_4/Regress/regress-7224.js index 9c30020cb18..1897f75256f 100644 --- a/mozilla/js/tests/js1_4/Regress/regress-7224.js +++ b/mozilla/js/tests/js1_4/Regress/regress-7224.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -41,47 +42,47 @@ * Author: ** replace with your e-mail address ** */ - var SECTION = "regress"; // provide a document reference (ie, ECMA section) - var VERSION = "JS1_4"; // Version of JavaScript or ECMA - var TITLE = "Regression test for bugzilla #7224"; // Provide ECMA section title or a description - var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7224"; // Provide URL to bugsplat or bugzilla report +var SECTION = "regress"; // provide a document reference (ie, ECMA section) +var VERSION = "JS1_4"; // Version of JavaScript or ECMA +var TITLE = "Regression test for bugzilla #7224"; // Provide ECMA section title or a description +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7224"; // Provide URL to bugsplat or bugzilla report - startTest(); // leave this alone +startTest(); // leave this alone - /* - * Calls to AddTestCase here. AddTestCase is a function that is defined - * in shell.js and takes three arguments: - * - a string representation of what is being tested - * - the expected result - * - the actual result - * - * For example, a test might look like this: - * - * var zip = /[\d]{5}$/; - * - * AddTestCase( - * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test - * "02134", // expected result - * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result - * - */ +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ - var f = new Function( "return arguments.caller" ); - var o = {}; +var f = new Function( "return arguments.caller" ); +var o = {}; - o.foo = f; - o.foo("a", "b", "c") +o.foo = f; +o.foo("a", "b", "c"); - AddTestCase( - "var f = new Function( 'return arguments.caller' ); f()", - undefined, - f() ); +AddTestCase( + "var f = new Function( 'return arguments.caller' ); f()", + undefined, + f() ); - AddTestCase( - "var o = {}; o.foo = f; o.foo('a')", - undefined, - o.foo('a') ); +AddTestCase( + "var o = {}; o.foo = f; o.foo('a')", + undefined, + o.foo('a') ); - test(); // leave this alone. this executes the test cases and - // displays results. +test(); // leave this alone. this executes the test cases and +// displays results. diff --git a/mozilla/js/tests/js1_4/Regress/shell.js b/mozilla/js/tests/js1_4/Regress/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_4/Regress/toString-001-n.js b/mozilla/js/tests/js1_4/Regress/toString-001-n.js index 22e94027cce..a8f6979a41f 100644 --- a/mozilla/js/tests/js1_4/Regress/toString-001-n.js +++ b/mozilla/js/tests/js1_4/Regress/toString-001-n.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -43,26 +44,25 @@ * Author: christine@netscape.com * Date: 11 August 1998 */ - var SECTION = "toString-001.js"; - var VERSION = "JS1_4"; - var TITLE = "Regression test case for 310514"; - var BUGNUMBER="310514"; +var SECTION = "toString-001.js"; +var VERSION = "JS1_4"; +var TITLE = "Regression test case for 310514"; +var BUGNUMBER="310514"; - startTest(); +startTest(); - writeHeaderToLog( SECTION + " "+ TITLE); +writeHeaderToLog( SECTION + " "+ TITLE); - var testcases = new Array(); +var o = {}; +o.toString = Function.prototype.toString; +DESCRIPTION = "var o = {}; o.toString = Function.prototype.toString; o.toString();"; +EXPECTED = "error"; - var o = {}; - o.toString = Function.prototype.toString; +new TestCase( + SECTION, + "var o = {}; o.toString = Function.prototype.toString; o.toString();", + "error", + o.toString() ); - - testcases[tc++] = new TestCase( - SECTION, - "var o = {}; o.toString = Function.prototype.toString; o.toString();", - "error", - o.toString() ); - - test(); +test(); diff --git a/mozilla/js/tests/js1_4/browser.js b/mozilla/js/tests/js1_4/browser.js index 922fb136e05..cec0213096f 100644 --- a/mozilla/js/tests/js1_4/browser.js +++ b/mozilla/js/tests/js1_4/browser.js @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -49,47 +50,76 @@ * <script src="./mytest.js"></script> */ -onerror = err; - -function startTest() { - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; -} +GLOBAL = "[object Window]"; function writeLineToLog( string ) { - document.write( string + "<br>\n"); + document.write( string + "<br>\n"); } function writeHeaderToLog( string ) { - document.write( "<h2>" + string + "</h2>" ); + document.write( "<h2>" + string + "</h2>" ); } -function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } - document.write( "<hr>" ); -} -function writeFormattedResult( expect, actual, string, passed ) { - var s = "<tt>"+ string ; - s += "<b>" ; - s += ( passed ) ? "<font color=#009900>  " + PASSED - : "<font color=#aa0000> " + FAILED + expect + "</tt>"; - writeLineToLog( s + "</font></b></tt>" ); - return passed; -} -function err( msg, page, line ) { - writeLineToLog( "Test failed with the message: " + msg ); - testcases[tc].actual = "error"; - testcases[tc].reason = msg; - writeTestCaseResult( testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ testcases[tc].actual + - ": " + testcases[tc].reason ); - stopTest(); - return true; +function writeFormattedResult( expect, actual, string, passed ) { + var s = "<tt>"+ string ; + s += "<b>" ; + s += ( passed ) ? "<font color=#009900>  " + PASSED + : "<font color=#aa0000> " + FAILED + expect + "</tt>"; + writeLineToLog( s + "</font></b></tt>" ); + return passed; +} + +/* + * The earlier versions of the test code used exceptions + * to terminate the test script in "negative" test cases + * before the failure reporting code could run. In order + * to be able to capture errors for the "negative" case + * where the exception is a sign the test actually passed, + * the err online handler will assume that any error is a + * failure unless gExceptionExpected is true. + */ +window.onerror = err; +var gExceptionExpected = false; + +function err( msg, page, line ) { + var testcase; + + if (typeof(EXPECTED) == "undefined" || EXPECTED != "error") { +/* + * an unexpected exception occured + */ + writeLineToLog( "Test failed with the message: " + msg ); + testcase = new TestCase(SECTION, "unknown", "unknown", "unknown"); + testcase.passed = false; + testcase.reason = "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + return; + } + + if (typeof SECTION == 'undefined') + { + SECTION = 'Unknown'; + } + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + + testcase = new TestCase(SECTION, DESCRIPTION, EXPECTED, "error"); + testcase.reason += "Error: " + msg + + " Source File: " + page + " Line: " + line + "."; + stopTest(); +} + +var gVersion = 0; + +function version(v) +{ + if (v) { + gVersion = v; + } + return gVersion; } diff --git a/mozilla/js/tests/js1_4/shell.js b/mozilla/js/tests/js1_4/shell.js index 3afdc787c64..4725fb172ec 100644 --- a/mozilla/js/tests/js1_4/shell.js +++ b/mozilla/js/tests/js1_4/shell.js @@ -1,108 +1,179 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + + +/* + * JavaScript shared functions file for running the tests in either + * stand-alone JavaScript engine. To run a test, first load this file, + * then load the test script. + */ + var completed = false; -var testcases; -var tc = 0; +var testcases = new Array(); +var tc = testcases.length; -SECTION = ""; -VERSION = ""; -BUGNUMBER = ""; +var SECTION = ""; +var VERSION = ""; +var BUGNUMBER = ""; + +/* + * constant strings + */ var GLOBAL = "[object global]"; var PASSED = " PASSED!" var FAILED = " FAILED! expected: "; -function test() { - for ( tc=0; tc < testcases.length; tc++ ) { - testcases[tc].passed = writeTestCaseResult( - testcases[tc].expect, - testcases[tc].actual, - testcases[tc].description +" = "+ - testcases[tc].actual ); +var DEBUG = false; - testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; - } - stopTest(); - return ( testcases ); -} -/* wrapper for test cas constructor that doesn't require the SECTION + +/* + * wrapper for test case constructor that doesn't require the SECTION * argument. */ function AddTestCase( description, expect, actual ) { - testcases[tc++] = new TestCase( SECTION, description, expect, actual ); + new TestCase( SECTION, description, expect, actual ); } + +/* + * TestCase constructor + * + */ function TestCase( n, d, e, a ) { - this.name = n; - this.description = d; - this.expect = e; - this.actual = a; - this.passed = true; - this.reason = ""; + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; - this.passed = getTestCaseResult( this.expect, this.actual ); + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } + /* + * testcases are solely maintained in the TestCase + * constructor. tc will _always_ point to one past the + * last testcase. If an exception occurs during the call + * to the constructor, then we are assured that the tc + * index has not been incremented. + */ + + testcases[tc++] = this; } + +/* + * Set up test environment. + * + */ function startTest() { /* - // JavaScript 1.3 is supposed to be compliant ecma version 1.0 - if ( VERSION == "ECMA_1" ) { - version ( 130 ); - } - if ( VERSION == "JS_1.3" ) { - version ( 130 ); - } - if ( VERSION == "JS_1.2" ) { - version ( 120 ); - } - if ( VERSION == "JS_1.1" ) { - version ( 110 ); - } - // for ecma version 2.0, we will leave the javascript version to - // the default ( for now ). +// JavaScript 1.3 is supposed to be compliant ecma version 1.0 +if ( VERSION == "ECMA_1" ) { +version ( 130 ); +} +if ( VERSION == "JS_1.3" ) { +version ( 130 ); +} +if ( VERSION == "JS_1.2" ) { +version ( 120 ); +} +if ( VERSION == "JS_1.1" ) { +version ( 110 ); +} +// for ecma version 2.0, we will leave the javascript version to +// the default ( for now ). */ - if ( BUGNUMBER ) { - writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); - } - - testcases = new Array(); - tc = 0; + writeHeaderToLog( SECTION + " "+ TITLE); + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } } + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + try + { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + catch(e) + { + writeLineToLog('test(): empty testcase for tc = ' + tc + ' ' + e); + } + } + stopTest(); + return ( testcases ); +} + +/* + * Compare expected result to the actual result and figure out whether + * the test case passed. + */ function getTestCaseResult( expect, actual ) { - // because ( NaN == NaN ) always returns false, need to do - // a special compare to see if we got the right result. - if ( actual != actual ) { - if ( typeof actual == "object" ) { - actual = "NaN object"; - } else { - actual = "NaN number"; - } - } - if ( expect != expect ) { - if ( typeof expect == "object" ) { - expect = "NaN object"; - } else { - expect = "NaN number"; - } - } + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } - var passed = ( expect == actual ) ? true : false; + var passed = ( expect == actual ) ? true : false; - // if both objects are numbers, give a little leeway for rounding. - if ( !passed - && typeof(actual) == "number" - && typeof(expect) == "number" - ) { - if ( Math.abs(actual-expect) < 0.0000001 ) { - passed = true; - } - } + // if both objects are numbers, give a little leeway for rounding. + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } - // verify type is the same - if ( typeof(expect) != typeof(actual) ) { - passed = false; - } + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } - return passed; + return passed; } /* * Begin printing functions. These functions use the shell's @@ -112,15 +183,15 @@ function getTestCaseResult( expect, actual ) { */ function writeTestCaseResult( expect, actual, string ) { - var passed = getTestCaseResult( expect, actual ); - writeFormattedResult( expect, actual, string, passed ); - return passed; + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; } function writeFormattedResult( expect, actual, string, passed ) { - var s = string ; - s += ( passed ) ? PASSED : FAILED + expect; - writeLineToLog( s); - return passed; + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; } function writeLineToLog( string ) { print( string ); @@ -130,9 +201,28 @@ function writeHeaderToLog( string ) { } /* end of print functions */ +/* + * When running in the shell, run the garbage collector after the + * test has completed. + */ + function stopTest() { - var gc; - if ( gc != undefined ) { - gc(); - } + var gc; + if ( gc != undefined ) { + gc(); + } } + +/* + * Convenience function for displaying failed test cases. Useful + * when running tests manually. + * + */ +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + writeLineToLog( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} + diff --git a/mozilla/js/tests/js1_5/Array/browser.js b/mozilla/js/tests/js1_5/Array/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Array/shell.js b/mozilla/js/tests/js1_5/Array/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Exceptions/browser.js b/mozilla/js/tests/js1_5/Exceptions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Exceptions/catchguard-001-n.js b/mozilla/js/tests/js1_5/Exceptions/catchguard-001-n.js index 61241aac121..43e606c4e6d 100644 --- a/mozilla/js/tests/js1_5/Exceptions/catchguard-001-n.js +++ b/mozilla/js/tests/js1_5/Exceptions/catchguard-001-n.js @@ -38,6 +38,9 @@ * * ***** END LICENSE BLOCK ***** */ +DESCRIPTION = " the non-guarded catch should HAVE to appear last"; +EXPECTED = "error"; + test(); function test() diff --git a/mozilla/js/tests/js1_5/Exceptions/catchguard-002-n.js b/mozilla/js/tests/js1_5/Exceptions/catchguard-002-n.js index 711bf7c61c6..7d520f8b0dd 100644 --- a/mozilla/js/tests/js1_5/Exceptions/catchguard-002-n.js +++ b/mozilla/js/tests/js1_5/Exceptions/catchguard-002-n.js @@ -38,6 +38,11 @@ * * ***** END LICENSE BLOCK ***** */ +DESCRIPTION = "var in catch clause should have caused an error."; +EXPECTED = "error"; + +test(); + function test() { enterFunc ("test"); diff --git a/mozilla/js/tests/js1_5/Exceptions/catchguard-003-n.js b/mozilla/js/tests/js1_5/Exceptions/catchguard-003-n.js index e8e2998a085..c69859cebc5 100644 --- a/mozilla/js/tests/js1_5/Exceptions/catchguard-003-n.js +++ b/mozilla/js/tests/js1_5/Exceptions/catchguard-003-n.js @@ -38,6 +38,9 @@ * * ***** END LICENSE BLOCK ***** */ +DESCRIPTION = "Illegally constructed catchguard should have thrown an exception."; +EXPECTED = "error"; + test(); function test() diff --git a/mozilla/js/tests/js1_5/Exceptions/shell.js b/mozilla/js/tests/js1_5/Exceptions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Expressions/browser.js b/mozilla/js/tests/js1_5/Expressions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Expressions/shell.js b/mozilla/js/tests/js1_5/Expressions/shell.js index 09eaeb56ada..a3dfec3652f 100644 --- a/mozilla/js/tests/js1_5/Expressions/shell.js +++ b/mozilla/js/tests/js1_5/Expressions/shell.js @@ -129,3 +129,4 @@ function singleQuote(text) { return CHAR_QT + text + CHAR_QT; } + diff --git a/mozilla/js/tests/js1_5/Function/browser.js b/mozilla/js/tests/js1_5/Function/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Function/shell.js b/mozilla/js/tests/js1_5/Function/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/GetSet/browser.js b/mozilla/js/tests/js1_5/GetSet/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/GetSet/shell.js b/mozilla/js/tests/js1_5/GetSet/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/LexicalConventions/browser.js b/mozilla/js/tests/js1_5/LexicalConventions/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/LexicalConventions/shell.js b/mozilla/js/tests/js1_5/LexicalConventions/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Object/browser.js b/mozilla/js/tests/js1_5/Object/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Object/shell.js b/mozilla/js/tests/js1_5/Object/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/README b/mozilla/js/tests/js1_5/README new file mode 100755 index 00000000000..e2b340416bd --- /dev/null +++ b/mozilla/js/tests/js1_5/README @@ -0,0 +1 @@ +JavaScript 1.5 diff --git a/mozilla/js/tests/js1_5/Regress/browser.js b/mozilla/js/tests/js1_5/Regress/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Regress/regress-104077.js b/mozilla/js/tests/js1_5/Regress/regress-104077.js index c85c8460066..db91d85d686 100644 --- a/mozilla/js/tests/js1_5/Regress/regress-104077.js +++ b/mozilla/js/tests/js1_5/Regress/regress-104077.js @@ -109,7 +109,7 @@ function tryThis() } finally { - print("In finally case of tryThis() function"); + writeLineToLog("In finally case of tryThis() function"); } } return i; @@ -130,7 +130,7 @@ function myTest(x) with (obj) { msg = (x != null) ? "NO" : "YES"; - print("Is the provided argument to myTest() null? : " + msg); + writeLineToLog("Is the provided argument to myTest() null? : " + msg); try { @@ -138,7 +138,7 @@ function myTest(x) } catch(e) { - print("Caught thrown exception = " + e); + writeLineToLog("Caught thrown exception = " + e); } } @@ -172,7 +172,7 @@ function addValues_2(obj) } catch(e) { - print('Caught an exception in addValues_2() function: ' + e); + writeLineToLog('Caught an exception in addValues_2() function: ' + e); } } } @@ -337,7 +337,7 @@ function addValues_3(obj) catch (e) { sum += 1; - print(e); + writeLineToLog(e); } } } @@ -347,17 +347,17 @@ function addValues_3(obj) try { sum +=1; - print("In finally block of addValues_3() function: sum = " + sum); + writeLineToLog("In finally block of addValues_3() function: sum = " + sum); } catch (e if e == 42) { sum +=1; - print('In finally catch block of addValues_3() function: sum = ' + sum + ', e = ' + e); + writeLineToLog('In finally catch block of addValues_3() function: sum = ' + sum + ', e = ' + e); } finally { sum +=1; - print("In finally finally block of addValues_3() function: sum = " + sum); + writeLineToLog("In finally finally block of addValues_3() function: sum = " + sum); return sum; } } @@ -400,7 +400,7 @@ function addValues_4(obj) catch (e) { sum += 1; - print(e); + writeLineToLog(e); } } } @@ -410,22 +410,22 @@ function addValues_4(obj) try { sum += 1; - print("In finally block of addValues_4() function: sum = " + sum); + writeLineToLog("In finally block of addValues_4() function: sum = " + sum); } catch (e if e == 42) { sum += 1; - print("In 1st finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); + writeLineToLog("In 1st finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); } catch (e if e == 43) { sum += 1; - print("In 2nd finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); + writeLineToLog("In 2nd finally catch block of addValues_4() function: sum = " + sum + ", e = " + e); } finally { sum += 1; - print("In finally finally block of addValues_4() function: sum = " + sum); + writeLineToLog("In finally finally block of addValues_4() function: sum = " + sum); return sum; } } @@ -468,7 +468,7 @@ function addValues_5(obj) catch (e) { sum += 1; - print(e); + writeLineToLog(e); } } } @@ -478,17 +478,17 @@ function addValues_5(obj) try { sum += 1; - print("In finally block of addValues_5() function: sum = " + sum); + writeLineToLog("In finally block of addValues_5() function: sum = " + sum); } catch (e) { sum += 1; - print("In finally catch block of addValues_5() function: sum = " + sum + ", e = " + e); + writeLineToLog("In finally catch block of addValues_5() function: sum = " + sum + ", e = " + e); } finally { sum += 1; - print("In finally finally block of addValues_5() function: sum = " + sum); + writeLineToLog("In finally finally block of addValues_5() function: sum = " + sum); return sum; } } @@ -524,7 +524,7 @@ function testObj(obj) } finally { - print("in finally block of testObj() function"); + writeLineToLog("in finally block of testObj() function"); return 999; } } @@ -555,7 +555,7 @@ function a120571() } // this caused a crash! Test to see that it doesn't now. -print(a120571); +writeLineToLog(a120571); // Now test that we have a non-null value for a120571.toString() status = inSection(13); @@ -588,7 +588,7 @@ function b() } // this caused a crash!!! Test to see that it doesn't now. -print(b); +writeLineToLog(b); // Now test that we have a non-null value for b.toString() status = inSection(14); diff --git a/mozilla/js/tests/js1_5/Regress/regress-168347.js b/mozilla/js/tests/js1_5/Regress/regress-168347.js index 069580cc88d..4dcfd3564e5 100644 --- a/mozilla/js/tests/js1_5/Regress/regress-168347.js +++ b/mozilla/js/tests/js1_5/Regress/regress-168347.js @@ -62,51 +62,51 @@ sFunc += ''; sFunc += ' try'; sFunc += ' {'; sFunc += ' f.i = f.i + 1;'; -sFunc += ' print("i = i+1 succeeded \ti = " + f.i);'; +sFunc += ' writeLineToLog("i = i+1 succeeded \ti = " + f.i);'; sFunc += ' }'; sFunc += ' catch(e)'; sFunc += ' {'; -sFunc += ' print("i = i+1 failed with " + e + "\ti = " + f.i);'; +sFunc += ' writeLineToLog("i = i+1 failed with " + e + "\ti = " + f.i);'; sFunc += ' }'; sFunc += ''; sFunc += ' try'; sFunc += ' {'; sFunc += ' ++f.i;'; -sFunc += ' print("++i succeeded \t\ti = " + f.i);'; +sFunc += ' writeLineToLog("++i succeeded \t\ti = " + f.i);'; sFunc += ' }'; sFunc += ' catch(e)'; sFunc += ' {'; -sFunc += ' print("++i failed with " + e + "\ti = " + f.i);'; +sFunc += ' writeLineToLog("++i failed with " + e + "\ti = " + f.i);'; sFunc += ' }'; sFunc += ''; sFunc += ' try'; sFunc += ' {'; sFunc += ' f.i++;'; -sFunc += ' print("i++ succeeded \t\ti = " + f.i);'; +sFunc += ' writeLineToLog("i++ succeeded \t\ti = " + f.i);'; sFunc += ' }'; sFunc += ' catch(e)'; sFunc += ' {'; -sFunc += ' print("i++ failed with " + e + "\ti = " + f.i);'; +sFunc += ' writeLineToLog("i++ failed with " + e + "\ti = " + f.i);'; sFunc += ' }'; sFunc += ''; sFunc += ' try'; sFunc += ' {'; sFunc += ' --f.i;'; -sFunc += ' print("--i succeeded \t\ti = " + f.i);'; +sFunc += ' writeLineToLog("--i succeeded \t\ti = " + f.i);'; sFunc += ' }'; sFunc += ' catch(e)'; sFunc += ' {'; -sFunc += ' print("--i failed with " + e + "\ti = " + f.i);'; +sFunc += ' writeLineToLog("--i failed with " + e + "\ti = " + f.i);'; sFunc += ' }'; sFunc += ''; sFunc += ' try'; sFunc += ' {'; sFunc += ' f.i--;'; -sFunc += ' print("i-- succeeded \t\ti = " + f.i);'; +sFunc += ' writeLineToLog("i-- succeeded \t\ti = " + f.i);'; sFunc += ' }'; sFunc += ' catch(e)'; sFunc += ' {'; -sFunc += ' print("i-- failed with " + e + "\ti = " + f.i);'; +sFunc += ' writeLineToLog("i-- failed with " + e + "\ti = " + f.i);'; sFunc += ' }'; sFunc += '}'; diff --git a/mozilla/js/tests/js1_5/Regress/regress-68498-001.js b/mozilla/js/tests/js1_5/Regress/regress-68498-001.js index f4f2104e642..1102ab97292 100644 --- a/mozilla/js/tests/js1_5/Regress/regress-68498-001.js +++ b/mozilla/js/tests/js1_5/Regress/regress-68498-001.js @@ -54,8 +54,9 @@ var summary ='Testing that variable statement outside any eval creates' + // To be pedantic, use a variable named 'self' to capture the global object - -var self = this; -var actual = (delete self); +// conflicts with window.self in browsers +var _self = this; +var actual = (delete _self); var expect =false; diff --git a/mozilla/js/tests/js1_5/Regress/regress-80981.js b/mozilla/js/tests/js1_5/Regress/regress-80981.js index 30770e8afa3..fad76231382 100644 --- a/mozilla/js/tests/js1_5/Regress/regress-80981.js +++ b/mozilla/js/tests/js1_5/Regress/regress-80981.js @@ -72,7 +72,7 @@ function test() { b (); b4 (); - print('Number of errors = ' + err_num); + writeLineToLog('Number of errors = ' + err_num); } @@ -3109,16 +3109,16 @@ function b() function check(status) { - print('k = ' + k + ' j = ' + j + ' ' + status); + writeLineToLog('k = ' + k + ' j = ' + j + ' ' + status); for (i = 0; i < i2; i++) { if (n[i] != 1) { - print('n[' + i + '] = ' + n[i]); + writeLineToLog('n[' + i + '] = ' + n[i]); if (i != j) { - print('Test failed'); + writeLineToLog('Test failed'); err_num++; break; } @@ -3129,11 +3129,11 @@ function check(status) function b4() { - print('Visited b4'); + writeLineToLog('Visited b4'); } function b_after() { - print('Visited b_after'); + writeLineToLog('Visited b_after'); } diff --git a/mozilla/js/tests/js1_5/Regress/regress-96526-003.js b/mozilla/js/tests/js1_5/Regress/regress-96526-003.js index d80cd1b957f..7bffb528964 100644 --- a/mozilla/js/tests/js1_5/Regress/regress-96526-003.js +++ b/mozilla/js/tests/js1_5/Regress/regress-96526-003.js @@ -55,7 +55,7 @@ function validId(IDtext) var res = ""; if(IDText.value==""){ - print("You must enter a valid battery #") + writeLineToLog("You must enter a valid battery #") return false } else if(IDText.value=="x522"){ @@ -1653,1851 +1653,1851 @@ else if(IDText.value=="erd300"){ else if(IDText.value=="164"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="201"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="216"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="226"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="228"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="311"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="314"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="313"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="323"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="325"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="333cz"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="343"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="354"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="355"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="387"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="388"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="417"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="420"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="457"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="460"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="477"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="479"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="482"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="484"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="487"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="490"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="491"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="496"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="509"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="510f"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="520"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="523"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="531"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="532"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="537"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="538"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="544"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="560"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="561"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="563"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="564"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="565"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="646"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="703"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="706"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="714"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="715"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="716"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="717"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="724"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="731"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="735"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="736"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="738"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="742"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="744"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="750"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="762s"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="773"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="778"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="781"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="812"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="815"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="835"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="850"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="904"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="912"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="915"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="935"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="950"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1015"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1035"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1050"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1150"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1231"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1461"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1463"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1562"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="1862"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="2356n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="2709n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="2744n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="2745n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="2746n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="2780n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ac41e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cc1096"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ccm1460"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ccm2460"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ccm4060a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ccm4060m"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cdc100"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ch12"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ch15"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ch2aa"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ch22"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ch35"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ch4"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ch50"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cm1060"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cm1560"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cm2360"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cm4160"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cm6036"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cm9072"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cm9172"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp2360"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp3336"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp3536"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp3736"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp5036"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp5160"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp5648"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp5960"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp6072"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp6172"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7049"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7072"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7148"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7149"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7160"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7172"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7248"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7261"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7348"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7548"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7661"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp7960"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8049"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8136"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8160"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8172"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8248"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8661"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8748"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8948"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp8960"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp9061"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp9148"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp9161"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cp9360"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs3336"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs5036"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs5460"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7048"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7072"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7148"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7149"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7160"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7248"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7261"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7348"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7448"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7548"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs7661"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs8136"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs8648"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs9061"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs9148"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cs9161"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cv2012"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cv2096"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cv3010s"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cv3012"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cv3060"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cv3112"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="cv3212"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e1"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e1n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e3"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e4"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e9"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e12"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e12n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e13e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e41e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e42"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e42n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e89"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e115"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e115n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e126"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e132"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e132n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e133"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e133n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e134"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e134n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e135"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e135n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e136"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e137"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e137n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e146x"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e152"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e163"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e164"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e164n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e165"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e169"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e177"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e233"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e233n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e235n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e236n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e286"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e289"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e312e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e340e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e400"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e400n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e401e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e401n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e450"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e502"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e601"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e625"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e630"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e640"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e640n"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e675e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302157"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302250"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302358"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302435"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302462"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302465"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302478"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302642"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302651"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302702"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302904"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302905"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e302908"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e303145"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e303236"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e303314"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e303394"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e303496"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="e303996"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ea6"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ea6f"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ea6ft"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ea6st"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en1a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en132a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en133a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en134a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en135a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en136a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en164a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en165a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en175a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en177a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="en640a"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ep175"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ep401e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ep675e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx1"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx4"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx13"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx14"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx23"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx25"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx27"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx29"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx30"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx625"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx640"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx675"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="epx825"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev6"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev9"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev10s"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev15"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev22"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev31"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev35"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev50"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev90"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="ev90hp"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="fcc2"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs6"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs10s"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs15"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs31"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs35"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs50"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs90"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs95"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs150"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="hs6571"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="if6"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="is6"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="is6t"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="p2321m"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="p2322"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="p2326m"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="p7307"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="p7507"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="qcc4"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="s13e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="s312e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="s41e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="s76e"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="t35"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="t50"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } else if(IDText.value=="w353"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/contents/discontinued_battery_index.htm" return true } @@ -4142,283 +4142,283 @@ else if(IDText.value=="LED"){ else if(IDText.value=="108"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="209"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="330"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="330y"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="331"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="331y"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="1251bk"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="2253"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="3233"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="3253"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="3415"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="3452"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="4220"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="4453"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="5154"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="5251"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="7369"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="8115"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="8415"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="b170"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="bkc1"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="d620"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="d820"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="e100"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="e252"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="e350"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="e420"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="em290"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="em420"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="f100"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="f215"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="f250"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="f415"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="h100"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="h250"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="h350"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="in25t"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="kcdb"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="kcsg"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="kctw"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="rc100"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="rc251"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="rc290"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="t430"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="v235"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="x250"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } else if(IDText.value=="x350"){ //Checks for id entry - print("You have entered a Discontinued Product Number") + writeLineToLog("You have entered a Discontinued Product Number") res="../datasheets/flashlights/discontinued_flashlight_index.htm" return true } @@ -4426,7 +4426,7 @@ else if(IDText.value=="x350"){ else { - print("You have entered an Invalid Product Number...Please try 'Select Product Group' search.") + writeLineToLog("You have entered an Invalid Product Number...Please try 'Select Product Group' search.") return false } diff --git a/mozilla/js/tests/js1_5/Regress/shell.js b/mozilla/js/tests/js1_5/Regress/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Scope/browser.js b/mozilla/js/tests/js1_5/Scope/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/Scope/shell.js b/mozilla/js/tests/js1_5/Scope/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/String/browser.js b/mozilla/js/tests/js1_5/String/browser.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/String/shell.js b/mozilla/js/tests/js1_5/String/shell.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mozilla/js/tests/js1_5/browser.js b/mozilla/js/tests/js1_5/browser.js new file mode 100755 index 00000000000..262d32a3594 --- /dev/null +++ b/mozilla/js/tests/js1_5/browser.js @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * <script src="./../shell.js"></script> + * <script src="./../browser.js"></script> + * <script src="./mytest.js"></script> + */ +function writeLineToLog( string ) { + document.write( string + "<br>\n"); +} + +var testcases = new Array(); +var tc = testcases.length; +var bug = ''; +var summary = ''; +var description = ''; +var expected = ''; +var actual = ''; +var msg = ''; + + +function TestCase(n, d, e, a) +{ + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = ( e == a ); + this.reason = ''; + this.bugnumber = typeof(bug) != 'undefined' ? bug : ''; + testcases[tc++] = this; +} + +var gInReportCompare = false; + +var _reportCompare = reportCompare; + +reportCompare = function(expected, actual, description) +{ + gInReportCompare = true; + + var testcase = new TestCase(gTestName, description, expected, actual); + testcase.passed = _reportCompare(expected, actual, description); + + gInReportCompare = false; +}; + +var _reportFailure = reportFailure; +reportFailure = function (msg, page, line) +{ + var testcase; + + if (gInReportCompare) + { + testcase = testcases[tc - 1]; + testcase.passed = false; + } + else + { + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + testcase = new TestCase(gTestName, DESCRIPTION, EXPECTED, "error"); + } + + testcase.reason += msg; + + if (typeof(page) != 'undefined') + { + testcase.reason += ' Page: ' + page; + } + if (typeof(line) != 'undefined') + { + testcase.reason += ' Line: ' + line; + } + _reportFailure(msg); + +}; + +function gc() +{ +} + +function quit() +{ +} + +window.onerror = reportFailure; diff --git a/mozilla/js/tests/js1_5/shell.js b/mozilla/js/tests/js1_5/shell.js index c50815919b8..ed0b91e9f14 100644 --- a/mozilla/js/tests/js1_5/shell.js +++ b/mozilla/js/tests/js1_5/shell.js @@ -46,6 +46,9 @@ var SECT_PREFIX = 'Section '; var SECT_SUFFIX = ' of test -'; var callStack = new Array(); +function writeLineToLog( string ) { + print( string + "\n"); +} /* * The test driver searches for such a phrase in the test output. * If such phrase exists, it will set n as the expected exit code. @@ -53,7 +56,7 @@ var callStack = new Array(); function expectExitCode(n) { - print('--- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE ' + n + ' ---'); + writeLineToLog('--- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE ' + n + ' ---'); } @@ -72,7 +75,7 @@ function inSection(x) */ function inRhino() { - return (typeof defineClass == "function"); + return (typeof defineClass == "function"); } /* @@ -86,7 +89,7 @@ function reportFailure (msg) var prefix = (funcName) ? "[reported from " + funcName + "] ": ""; for (var i=0; i<lines.length; i++) - print (FAILED + prefix + lines[i]); + writeLineToLog (FAILED + prefix + lines[i]); } @@ -99,7 +102,7 @@ function printStatus (msg) var l; for (var i=0; i<lines.length; i++) - print (STATUS + lines[i]); + writeLineToLog (STATUS + lines[i]); } @@ -109,7 +112,7 @@ function printStatus (msg) function printBugNumber (num) { - print (BUGNUMBER + num); + writeLineToLog (BUGNUMBER + num); } @@ -147,7 +150,7 @@ function reportCompare (expected, actual, description) reportFailure (description); reportFailure (output); } - + return (output == ""); // true if passed } /* @@ -194,3 +197,4 @@ function currentFunc() return callStack[callStack.length - 1]; } + diff --git a/mozilla/js/tests/js1_5/template.js b/mozilla/js/tests/js1_5/template.js new file mode 100755 index 00000000000..dede37962f4 --- /dev/null +++ b/mozilla/js/tests/js1_5/template.js @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +//----------------------------------------------------------------------------- +var bug = 99999; +var summary = ''; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/mozilla/js/tests/jsDriver.pl b/mozilla/js/tests/jsDriver.pl index f7984dadab5..f04c952fbfc 100755 --- a/mozilla/js/tests/jsDriver.pl +++ b/mozilla/js/tests/jsDriver.pl @@ -65,7 +65,7 @@ my @opt_test_list_files; my @opt_neg_list_files; my $opt_shell_path = ""; my $opt_java_path = ""; -my $opt_bug_url = "http://bugzilla.mozilla.org/show_bug.cgi?id="; +my $opt_bug_url = "https://bugzilla.mozilla.org/show_bug.cgi?id="; my $opt_console_failures = 0; my $opt_lxr_url = "http://lxr.mozilla.org/mozilla/source/js/tests/"; my $opt_exit_munge = ($os_type ne "MAC") ? 1 : 0; @@ -235,7 +235,8 @@ sub execute_tests { # XXX This only allows 1 bugnumber per testfile, should be # XXX modified to allow for multiple. if ($line =~ /bugnumber\s*\:?\s*(.*)/i) { - $1 =~ /(\n+)/; + my $bugline = $1; + $bugline =~ /(\d+)/; $bug_number = $1; } @@ -328,7 +329,7 @@ sub write_results { print OUTPUT ("[ <a href='#fail_detail'>Failure Details</a> | " . "<a href='#retest_list'>Retest List</a> | " . - "<a href='menu.html'>Test Selection Page</a> ]<br>\n" . + "<a href='$opt_lxr_url" . "menu.html'>Test Selection Page</a> ]<br>\n" . "<hr>\n" . "<a name='fail_detail'></a>\n" . "<h2>Failure Details</h2><br>\n<dl>" . @@ -895,6 +896,12 @@ sub get_test_list { # Don't run any shell.js files as tests; they are only utility files @test_list = grep (!/shell\.js$/, @test_list); + # Don't run any browser.js files as tests; they are only utility files + @test_list = grep (!/browser\.js$/, @test_list); + + # Don't run any jsref.js files as tests; they are only utility files + @test_list = grep (!/jsref\.js$/, @test_list); + return @test_list; } @@ -1216,6 +1223,9 @@ sub report_failure { $failures_reported++; $message =~ s/\n+/\n/g; + $message =~ s/&/&/g; + $message =~ s/</</g; + $message =~ s/>/>/g; $test =~ s/\:/\//g; if ($opt_console_failures) { diff --git a/mozilla/js/tests/menuhead.html b/mozilla/js/tests/menuhead.html index 827dc43375c..6530f36c704 100644 --- a/mozilla/js/tests/menuhead.html +++ b/mozilla/js/tests/menuhead.html @@ -1,138 +1,50 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <title>Core JavaScript Tests - + +

Core JavaScript Tests

-
+ + +

Browser Test Options

+

+ <script + > + DOCTYPE + + Output Format + + Failures only + +

\ No newline at end of file diff --git a/mozilla/js/tests/menuhead.js b/mozilla/js/tests/menuhead.js new file mode 100644 index 00000000000..ecc8bbf9e89 --- /dev/null +++ b/mozilla/js/tests/menuhead.js @@ -0,0 +1,748 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Bob Clary + */ + +var gTotalCount = 0; +var gTotalSelected = 0; + +function setCursor(aCursor) +{ + if (document.body && document.body.style) + { + document.body.style.cursor = aCursor; + } +} + +function selectAll(suiteName, testDirName) +{ + setCursor('wait'); + + suiteName = suiteName || ''; + testDirName = testDirName || ''; + + setTimeout('_selectAll("' + suiteName + '", "' + testDirName + '")', 200); +} + +function _selectAll(suiteName, testDirName) +{ + if (!suiteName) + { + for (suiteName in suites) + { + setAllDirs(suiteName, true); + } + } + else if (!testDirName) + { + setAllDirs(suiteName, true); + } + else + { + setAllTests(suiteName, testDirName, true); + } + + setCursor('auto'); +} + +function selectNone(suiteName, testDirName) +{ + setCursor('wait'); + + suiteName = suiteName || ''; + testDirName = testDirName || ''; + + setTimeout('_selectNone("' + suiteName + '", "' + testDirName + '")', 200); +} + +function _selectNone(suiteName, testDirName) +{ + if (!suiteName) + { + for (suiteName in suites) + { + setAllDirs(suiteName, false); + } + } + else if (!testDirName) + { + setAllDirs(suiteName, false); + } + else + { + setAllTests(suiteName, testDirName, false); + } + + setCursor('auto'); +} + +function updateCounts(suiteName) +{ + var suite = suites[suiteName]; + var pct = parseInt((suite.selected / suite.count) * 100); + if (isNaN(pct)) + pct = 0; + + document.forms.testCases.elements['SUMMARY_' + suiteName].value = + suite.selected + '/' + suite.count + + ' (' + pct + '%) selected'; + + pct = parseInt((gTotalSelected / gTotalCount) * 100); + if (isNaN(pct)) + pct = 0; + + document.forms.testCases.elements['TOTAL'].value = + gTotalSelected + '/' + gTotalCount + ' (' + + pct + '%) selected'; +} + +function onRadioClick(radio) +{ + var info = radio.id.split(':'); + var suiteName = info[0]; + var suite = suites[suiteName]; + var incr = (radio.checked ? 1 : -1); + suite.selected += incr; + gTotalSelected += incr; + + updateCounts(suiteName); + + return true; +} + +function updateTotals() +{ + setCursor('wait'); + + setTimeout('_updateTotals()', 200); +} + +function _updateTotals() +{ + gTotalCount = 0; + gTotalSelected = 0; + + for (var suiteName in suites) + { + gTotalCount += suites[suiteName].count; + } + for (suiteName in suites) + { + updateCounts(suiteName); + } + setCursor('auto'); +} + +function setAllDirs(suiteName, value) +{ + var testDirs = suites[suiteName].testDirs; + + for (var testDirName in testDirs) + { + setAllTests(suiteName, testDirName, value); + } +} + +function setAllTests(suiteName, testDirName, value) +{ + var suite = suites[suiteName]; + var tests = suite.testDirs[testDirName].tests; + var elements = document.forms['testCases'].elements; + var incr = 0; + + for (var testName in tests) + { + var radioName = tests[testName].id; + var radio = elements[radioName]; + if (radio.checked && !value) + { + incr--; + } + else if (!radio.checked && value) + { + incr++; + } + radio.checked = value; + } + + suite.selected += incr; + gTotalSelected += incr; + + updateCounts(suiteName); +} + +function createList() +{ + var suiteName; + var elements = document.forms['testCases'].elements; + var win = window.open('about:blank', 'other_window'); + var writer = new CachedWriter(win.document); + + win.document.open(); + writer.writeln('
');
+    
+  writer.writeln('# Created ' + new Date());
+
+  for (suiteName in suites)
+  {
+    writer.writeln('# ' + suiteName + ': ' + 
+                   elements['SUMMARY_' + suiteName].value);
+  }
+
+  writer.writeln('# TOTAL: ' + elements['TOTAL'].value);
+
+  for (suiteName in suites)
+  {
+    var testDirs = suites[suiteName].testDirs;
+    for (var testDirName in testDirs)
+    {
+      var tests = testDirs[testDirName].tests;
+      for (var testName in tests) 
+      {  
+        var radioName = tests[testName].id;
+        var radio     = elements[radioName];
+        if (radio.checked)
+          writer.writeln(suiteName + '/' + testDirName + '/' + radio.value);
+      }
+    }
+  }
+  writer.writeln('<\/pre>');
+    
+  writer.close();
+}
+
+var gTests;
+var gTestNumber;
+var gWindow;
+
+function executeList()
+{
+  var elements = document.forms['testCases'].elements;
+
+  gTests = [];
+  gTestNumber = -1;
+
+  for (var suiteName in suites)
+  {
+    var testDirs = suites[suiteName].testDirs;
+    for (var testDirName in testDirs)
+    {
+      var tests = testDirs[testDirName].tests;
+      for (var testName in tests)
+      {  
+        var test      = tests[testName];
+        var radioName = test.id;
+        var radio     = elements[radioName];
+        delete test.testCases;
+        if (radio.checked)
+        {
+          gTests[gTests.length] = test;
+          test.path = suiteName + '/' + testDirName + '/' + radio.value;
+        }
+      }
+    }
+  }
+  runNextTest();
+}
+
+function runNextTest()
+{
+  var iTestCase;
+
+  if (gTestNumber != -1)
+  {
+    // tests have already run in gWindow, collect the results
+    // for later reporting.
+
+    var e;
+    try
+    {
+      var test  = gTests[gTestNumber];
+      test.testCases = [];
+      //test.testCases = test.testCases.concat(gWindow.testcases);
+      // note MSIE6 has a bug where instead of concating the new arrays
+      // it concats them to the first element. work around...
+      var origtestcases = gWindow.testcases;
+      for (iTestCase = 0; iTestCase < origtestcases.length; iTestCase++)
+      {
+//        test.testCases[test.testCases.length] = origtestcases[iTestCase];
+        var origtestcase = origtestcases[iTestCase];
+        var testCase = test.testCases[test.testCases.length] = {};
+        testCase.name = new String(origtestcase.name);
+        testCase.description = new String(origtestcase.description);
+        testCase.expect = new String(origtestcase.expect);
+        testCase.actual = new String(origtestcase.actual);
+        testCase.passed = origtestcase.passed ? true : false;
+        testCase.reason = new String(origtestcase.reason);
+        testCase.bugnumber = new String(origtestcase.bugnumber?origtestcase.bugnumber:'');
+      }
+      origtestcases = origtestcase = null;
+    }
+    catch(e)
+    {
+      ;
+    }
+  }
+
+  ++gTestNumber;
+
+  if (gTestNumber < gTests.length)
+  {
+    // run test
+    test      = gTests[gTestNumber];
+
+    gWindow = window.open('js-test-driver-' + 
+                          document.forms.testCases.doctype.value + 
+                          '.html?test=' + 
+                          test.path + 
+                          ';language=' + 
+                          document.forms.testCases.language.value, 
+                          'output');
+    if (!gWindow)
+    {
+      alert('This test suite requires popup windows.\n' + 
+            'Please enable them for this site.');
+    }
+  }
+  else if (document.forms.testCases.outputformat.value == 'html')
+  {
+    // all tests completed, display report
+    reportHTML();
+  }
+  else if (document.forms.testCases.outputformat.value == 'javascript')
+  {
+    // all tests completed, display report
+    reportJavaScript();
+  }
+
+}
+
+function reportHTML()
+{
+  var errorsOnly = document.forms.testCases.failures.checked;
+  var totalTestCases = 0;
+  var totalTestCasesPassed = 0;
+  var totalTestCasesFailed = 0;
+
+  gWindow.document.close();
+
+  var writer = new CachedWriter(gWindow.document);
+
+  writer.writeln('');
+
+  writer.writeln('');
+  writer.writeln('');
+  writer.writeln('JavaScript Tests Browser: ' + 
+                 navigator.userAgent + ' Language: ' + 
+                 document.forms.testCases.language.value + 
+                 '<\/title>');
+  writer.writeln('<style type="text/css">');
+  writer.writeln(' .passed { } .failed { background-color: red; }');
+  writer.writeln('table {}');
+  writer.writeln('th.description, th.actual, th.expect { width: 30em;}');
+  writer.writeln('<\/style>');
+
+  writer.writeln('<\/head>');
+  writer.writeln('<body>');
+  writer.writeln('<h2>JavaScript Tests Browser: ' + 
+                 navigator.userAgent + ' Language: ' + 
+                 document.forms.testCases.language.value + 
+                 '<\/h2>');
+
+  writer.writeln('<table border="1">');
+  writer.writeln('<thead>');
+  writer.writeln('<tr>');
+  writer.writeln('<th>Suite<\/th>');
+  writer.writeln('<th>Directory<\/th>');
+  writer.writeln('<th>Test<\/th>');
+  writer.writeln('<th>Passed<\/th>');
+  writer.writeln('<th class="description">Description<\/th>');
+  writer.writeln('<th class="actual">Actual<\/th>');
+  writer.writeln('<th class="expect">Expect<\/th>');
+  writer.writeln('<th>BugNumber<\/th>');
+  writer.writeln('<th>Reason<\/th>');
+  writer.writeln('<\/tr>');
+  writer.writeln('<\/thead>');
+  writer.writeln('<tbody>');
+
+  writer.writeln('<\/tr>');
+
+  for (var suiteName in suites)
+  {
+    var suiteTotals = {passed: 0, failed: 0};
+    var testDirs = suites[suiteName].testDirs;
+
+    for (var testDirName in testDirs)
+    {
+      var dirTotals   = {passed: 0, failed: 0};
+      var tests = testDirs[testDirName].tests;
+
+      for (var testName in tests)
+      {
+        var nameTotals  = {passed: 0, failed: 0};
+        var test = tests[testName];
+
+        if (! ('testCases' in test) )
+        {
+          // test not run
+          continue;
+        }
+
+        var testCases = test.testCases;
+
+        for (var iTestCase = 0; iTestCase < testCases.length; iTestCase++)
+        {
+          var testCase = testCases[iTestCase];
+          ++totalTestCases;
+          if (testCase.passed)
+          {
+            ++totalTestCasesPassed;
+            ++nameTotals.passed;
+            ++dirTotals.passed;
+            ++suiteTotals.passed;
+          }
+          else
+          {
+            ++totalTestCasesFailed;
+            ++nameTotals.failed;
+            ++dirTotals.failed;
+            ++suiteTotals.failed;
+          }
+
+          if (errorsOnly && testCase.passed)
+          {
+            continue;
+          }
+
+          writer.writeln('<tr class="' + 
+                         (testCase.passed ? 'passed' : 'failed') + '">' +
+                         '<td title="Suite">' + suiteName + '<\/td>' +
+                         '<td title="Directory">' + testDirName   + '<\/td>' +
+                         '<td title="Test">' + testName + '<\/td>' +
+                         '<td title="Status">' + 
+                         (testCase.passed ? 'Test Passed':'Test Failed') + 
+                         '<\/td>' +
+                         '<td title="Description">' + 
+                         splitString(testCase.description, '<br>', 30) + 
+                         '<\/td>' +
+                         '<td title="Actual">' + 
+                         splitString(testCase.actual, '<br>', 30) + 
+                         '<\/td>' +
+                         '<td title="Expected">' + 
+                         splitString(testCase.expect, '<br>', 30) + 
+                         '<\/td>' +
+                         '<td title="Bug">' + 
+                         (testCase.bugnumber?testCase.bugnumber:'') + 
+                         '<\/td>' +
+                         '<td title="Reason">' + testCase.reason + '<\/td>' +
+                         '<\/tr>');
+        } // for iTestCase
+
+        if (!errorsOnly && nameTotals.passed + nameTotals.failed > 0)
+        {
+          writer.writeln('<tr>' +
+                         '<td>' + suiteName + '<\/td>' +
+                         '<td>' + testDirName   + '<\/td>' +
+                         '<td colspan="7" style="font-weight:bold;">' + 
+                         testName + ' ' +
+                         'Passed = ' + nameTotals.passed.toString() + ' ' +
+                         'Failed = ' + nameTotals.failed.toString() +
+                         '<\/td>' +
+                         '<\/tr>');
+        }
+
+      } // for (var testName in tests)
+
+      if (!errorsOnly && dirTotals.passed + dirTotals.failed > 0)
+      {
+        writer.writeln('<tr>' +
+                       '<td>' + suiteName + '<\/td>' +
+                       '<td colspan="8" style="font-weight:bold;">' + 
+                       testDirName  + ' ' +
+                       'Passed = ' + dirTotals.passed.toString() + ' ' +
+                       'Failed = ' + dirTotals.failed.toString() +
+                       '<\/td>' +
+                       '<\/tr>');
+      }
+
+    } // for (var testDirName in testDirs)
+
+    if (!errorsOnly && suiteTotals.passed + suiteTotals.failed > 0)
+    {
+      writer.writeln('<tr>' +
+                     '<td colspan="9" style="font-weight:bold;">' + 
+                     suiteName + ' ' +
+                     'Passed = ' + suiteTotals.passed.toString() + ' ' +
+                     'Failed = ' + suiteTotals.failed.toString() +
+                     '<\/td>' +
+                     '<\/tr>');
+    }
+
+  } // for (var suiteName in suites)
+
+  writer.writeln('<\/tbody>');
+  writer.writeln('<\/table>');
+    
+  writer.writeln('<p>Total TestCases = ' + totalTestCases + 
+                 ', Passed = ' + totalTestCasesPassed + 
+                 ', Failed = ' + totalTestCasesFailed + 
+                 '<\/p>');
+  writer.writeln('<\/body>');
+  writer.writeln('<\/html>');
+
+  writer.close();
+}
+
+// return a string with delim inserted every pos characters
+// if there are no spaces to break the line
+function splitString(str, delim, pos)
+{
+  var newstr = '';
+  var length = str.length;
+
+  if (str.indexOf(' ') != -1)
+  {
+    return str;
+  }
+  for (var i = 0; i < length; i += pos)
+  {
+    newstr += str.substr(i, pos) + delim;
+  }
+  return newstr;
+}
+function reportJavaScript()
+{
+  gWindow.document.close();
+
+  var errorsOnly = document.forms.testCases.failures.checked;
+  var writer = new CachedWriter(gWindow.document);
+
+  writer.writeln('<html>');
+  writer.writeln('<head>');
+  writer.writeln('<title>JavaScript Tests Browser: ' + 
+                 navigator.userAgent + ' Language: ' + 
+                 document.forms.testCases.language.value + 
+                 '<\/title>');
+  writer.writeln('<script type="text/javascript">');
+  writer.writeln('var global = window.parent;');
+  writer.writeln('if (!global.gUAHash) {');
+  writer.writeln('  global.gUAHash = {};');
+  writer.writeln('  global.gUAList = {};');
+  writer.writeln('  global.gUA_id = -1;');
+  writer.writeln('  global.gTestResults = {};');
+  writer.writeln('}');
+  writer.writeln('var gUA = "' + navigator.userAgent + '";');
+  writer.writeln('var gUA_id = global.gUAHash[gUA];');
+  writer.writeln('if (typeof(gUA_id) != "number") {');
+  writer.writeln('  gUA_id = global.gUAHash[gUA] = ++global.gUA_id;');
+  writer.writeln('  global.gUAList[gUA_id] = gUA;');
+  writer.writeln('}');
+  writer.writeln('var gTestResults = global.gTestResults;');
+  writer.writeln('var gLanguage = \'' + document.forms.testCases.language.value + '\';');
+  writer.writeln('var gResult;');
+  writer.writeln('var gResultId;');
+  writer.writeln('var gUAResult;');
+  writer.writeln('var gJSResult;');
+  writer.writeln('var gSuiteId;');
+  writer.writeln('var gSuite;');
+  writer.writeln('var gDirId;');
+  writer.writeln('var gDir;');
+  writer.writeln('var gTestId;');
+  writer.writeln('var gTest;');
+
+  writer.writeln('gUAResult = gTestResults[gUA_id];');
+  writer.writeln('if (!gUAResult) {');
+  writer.writeln('  gUAResult = gTestResults[gUA_id] = {};');
+  writer.writeln('}');
+  writer.writeln('gJSResult = gUAResult[gLanguage];');
+  writer.writeln('if (!gJSResult) {');
+  writer.writeln('  gJSResult = gUAResult[gLanguage] = {};');
+  writer.writeln('}');
+
+
+  for (var suiteName in suites)
+  {
+    var suiteheader = '';
+
+    suiteheader += 'gSuiteId = "' + suiteName + '";\n';
+    suiteheader += 'gSuite = gJSResult[gSuiteId];\n';
+    suiteheader += 'if (!gSuite) {\n';
+    suiteheader += '  gSuite = gJSResult[gSuiteId] = {};\n';
+    suiteheader += '}\n';
+
+    var testDirs = suites[suiteName].testDirs;
+
+    for (var testDirName in testDirs)
+    {
+      var dirheader = '';
+
+      dirheader += 'gDirId = "' + testDirName + '";\n';
+      dirheader += 'gDir = gSuite[gDirId];\n';
+      dirheader += 'if (!gDir) {\n';
+      dirheader += '  gDir = gSuite[gDirId] = {};\n';
+      dirheader += '}\n';
+
+      var tests = testDirs[testDirName].tests;
+
+      for (var testName in tests)
+      {
+        var test = tests[testName];
+
+        if (! ('testCases' in test) )
+        {
+          // test not run
+          continue;
+        }
+
+        var testCases = test.testCases;
+        var resultId = suiteName + '/' + testDirName + '/' + testName;
+
+        var testheader = '';
+        testheader += 'gTestId = "' + testName + '";\n';
+        testheader += 'gTest  = gDir[gTestId];\n';
+        testheader += 'if (!gTest) {\n';
+        testheader += '  gTest = gDir[gTestId] = [];\n';
+        testheader += '}\n';
+
+        for (var iTestCase = 0; iTestCase < testCases.length; iTestCase++)
+        {
+          var testCase = testCases[iTestCase];
+          if (errorsOnly && testCase.passed)
+          {
+            continue;
+          }
+
+          if (suiteheader)
+          {
+            writer.writeln(suiteheader);
+            suiteheader = '';
+          }
+          if (dirheader)
+          {
+            writer.writeln(dirheader);
+            dirheader = '';
+          }
+          if (testheader)
+          {
+            writer.writeln(testheader);
+            testheader = '';
+          }
+
+          var name   = escape(testCase.name);
+          var desc   = escape(testCase.description);
+          var actual = escape(testCase.actual);
+          var expect = escape(testCase.expect);
+          var reason = escape(testCase.reason);
+          
+          var buffer = '';
+
+          buffer += 'gTest[gTest.length] = \n';
+          buffer += '{\n';
+          buffer += 'name: "' + name + '",\n';
+          buffer += 'description: "' + desc +  '",\n';
+          buffer += 'expect: "' + expect + '",\n';
+          buffer += 'actual: "' + actual + '",\n';
+          buffer += 'passed: ' + testCase.passed + ',\n';
+          buffer += 'reason: "' + reason + '",\n';
+          buffer += 'bugnumber: "' + (testCase.bugnumber ? 
+                                      testCase.bugnumber : '') + '"\n';
+          buffer += '};\n';
+
+          writer.writeln(buffer);
+          buffer = '';
+
+        } // for iTestCase
+ 
+      }  // for testName
+
+    } // for testDirName
+
+  } // for (var suiteName in suites)
+
+  writer.writeln('<\/script>');
+  writer.writeln('<\/head>');
+  writer.writeln('<body>');
+  writer.writeln('<p>JavaScript Tests Browser: ' + 
+                 navigator.userAgent + ' Language: ' + 
+                 document.forms.testCases.language.value + 
+                 '<\/p>');
+  writer.writeln('<\/body>')
+  writer.writeln('<\/html>');
+  writer.close();
+}
+   
+// improve IE's performance. Mozilla's is fine. ;-)
+function CachedWriter(doc, limit)
+{
+  this.document     = doc;
+  this.pendingCount = 0;
+  this.pendingLimit = limit ? limit : 100;
+  this.lines        = [];
+}
+
+CachedWriter.prototype.destroy = function _cachedWriterDestroy()
+{
+  this.document     = null;
+  this.pendingCount = 0;
+  this.pendingLimit = 0;
+  this.lines        = null;
+}
+
+CachedWriter.prototype.writeln = function _cachedWriterWriteLine(s)
+{
+  this.lines[this.lines.length] = s;
+  if (++this.pendingCount >= this.pendingLimit)
+  {
+    this.flush();
+  }
+}
+
+CachedWriter.prototype.flush = function _cachedWriterFlush()
+{
+  var s = this.lines.join('\n');
+  this.pendingCount = 0;
+  this.lines = [];
+  if (!window.opera)
+  {
+    for (var ibadchar = 0; ibadchar < 32; ++ibadchar)
+    {
+      if (ibadchar != 10 && ibadchar != 13)
+      {
+        var badchar = String.fromCharCode(ibadchar);
+        var badregx = new RegExp(badchar, 'mg');
+        var escchar = '\\0x' + ibadchar.toString(16);
+        s = s.replace(badregx, escchar);
+      }
+    }
+  }
+  this.document.writeln(s);
+}
+
+CachedWriter.prototype.close = function _cachedWriterClose()
+{
+  this.flush();
+  this.document.close();
+  this.destroy();
+}
diff --git a/mozilla/js/tests/mklistpage.pl b/mozilla/js/tests/mklistpage.pl
index 70bb34f9784..592c229e9cf 100644
--- a/mozilla/js/tests/mklistpage.pl
+++ b/mozilla/js/tests/mklistpage.pl
@@ -22,6 +22,7 @@
 #
 # Contributor(s):
 #   Robert Ginda
+#   Bob Clary
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -61,45 +62,59 @@ sub main {
 
     @suite_list = sort(&get_subdirs ($suite_path));
 
-    $javascript .= "suites = new Object();\n";
+    $javascript .= "\n";
+    $javascript .= "var suites = {};\n";
+    $javascript .= "function populateSuites()\n";
+    $javascript .= "{\n";
+    $javascript .= "var currSuite;\n";
+    $javascript .= "var currDirectory;\n";
+    $javascript .= "var currTestDirs;\n";
+    $javascript .= "var currTests;\n";
 
     $html .= "<h3>Test Suites:</h3>\n";
     $html .= "<center>\n";
-    $html .= "  <input type='button' value='Select All' " .
-      "onclick='selectAll();'> ";
-    $html .= "  <input type='button' value='Select None' " .
-      "onclick='selectNone();'> ";
+    $html .= "<input type='button' value='Select All' " .
+      "onclick='selectAll();'> \n";
+    $html .= "<input type='button' value='Select None' " .
+      "onclick='selectNone();'> \n";
 
     # suite menu
-    $html .= "<table border='1'>\n";
+    $html .= "<table border='1' summary='suite menu'>\n";
     foreach $suite (@suite_list) {
 	local @readme_text = ("No description available.");
 	if (open (README, $suite_path . $suite . "/README")) {
 	    @readme_text = <README>;
 	    close (README);
 	}
-	$html .= "<tr><td><a href='\#SUITE_$suite'>$suite</a></td>" .
-	  "<td>@readme_text</td>";
-	$html .= "<td><input type='button' value='Select All' " .
-	  "onclick='selectAll(\"$suite\");'> ";
+	$html .= "<tr>\n";
+	$html .= "<td>\n";
+	$html .= "<a href='\#SUITE_$suite'>$suite</a>\n";
+	$html .= "</td>\n";
+	$html .= "<td>@readme_text</td>\n";
+	$html .= "<td>\n";
+	$html .= "<input type='button' value='Select All' " .
+	  "onclick='selectAll(\"$suite\");'> \n";
 	$html .= "<input type='button' value='Select None' " .
-	  "onclick='selectNone(\"$suite\");'></td>";
+	  "onclick='selectNone(\"$suite\");'>\n";
+	$html .= "</td>\n";
 	$html .= "<td><input readonly name='SUMMARY_$suite'></td>";
 	$html .= "</tr>";
     }
     $html .= "</table>\n";
-    $html .= "<td><input readonly name='TOTAL'></td>";
-    $html .= "</center>";
-    $html .= "<dl>\n";
+    $html .= "<div><input readonly name='TOTAL'></div>\n";
+    $html .= "</center>\n";
 
+    $html .= "<dl>\n";
     foreach $i (0 .. $#suite_list) {
 	local $prev_href = ($i > 0) ? "\#SUITE_" . $suite_list[$i - 1] : "";
-	local $next_href = ($i < $#suite_list) ? "\#SUITE_" . $suite_list[$i + 1] : "";
+	local $next_href = ($i < $#suite_list) ? "\#SUITE_" . 
+	    $suite_list[$i + 1] : "";
 	&process_suite ($suite_path, $suite_list[$i], $prev_href, $next_href);
     }
-
     $html .= "</dl>\n";
 
+    $javascript .= "}\n";
+    $javascript .= "populateSuites();\n";
 }
 
 #
@@ -109,60 +124,76 @@ sub main {
 sub process_suite {
     local ($suite_path, $suite, $prev_href, $next_href) = @_;
     local $i, @test_dir_list;    
+    local $suite_count = 0;
 
     # suite js object
-    $javascript .= "suites[\"$suite\"] = {testDirs: {}};\n";
+    $javascript .= "currSuite = suites[\"$suite\"] = " .
+	"{testDirs:{}, count:0, selected:0};\n";
+    $javascript .= "currTestDirs = currSuite.testDirs;\n";
 
     @test_dir_list = sort(&get_subdirs ($test_home . $suite));
 
     # suite header
-    $html .= "  <a name='SUITE_$suite'></a><hr><dt><big><big><b>$suite " .
-      "(" . ($#test_dir_list + 1) . " Sub-Categories)</b></big></big><br>\n";
-    $html .= "  <input type='button' value='Select All' " .
-      "onclick='selectAll(\"$suite\");'>\n";
-    $html .= "  <input type='button' value='Select None' " .
-      "onclick='selectNone(\"$suite\");'> " .
-	"[ <a href='\#top_of_page'>Top of page</a> ";
+
+    $html .= "<dt>\n";
+    $html .= "<a name='SUITE_$suite'></a>$suite " .
+      "(" . ($#test_dir_list + 1) . " Sub-Categories)\n";
+    $html .= "<input type='button' value='Select All' " .
+	"onclick='selectAll(\"$suite\");'>\n";
+    $html .= "<input type='button' value='Select None' " .
+	"onclick='selectNone(\"$suite\");'> \n";
+    $html .= "[ ";
+    $html .= "<a href='\#top_of_page'>Top of page</a> \n";
     if ($prev_href) {
-	$html .= " | <a href='$prev_href'>Previous Suite</a> ";
+	$html .= " | ";
+        $html .= "<a href='$prev_href'>Previous Suite</a> \n";
     }
     if ($next_href) {
-	$html .= " | <a href='$next_href'>Next Suite</a> ";
+	$html .= " | ";
+        $html .= "<a href='$next_href'>Next Suite</a> \n";
     }
     $html .= "]\n";
+    $html .= "</dt>\n";
+    $html .= "<dd>\n";
 
-    $html .= "  <dd>\n  <dl>\n";
-    
     foreach $i (0 .. $#test_dir_list) {
-	local $prev_href = ($i > 0) ? "\#TESTDIR_" . $suite . $test_dir_list[$i - 1] :
-	  "";
+	local $prev_href = ($i > 0) ? "\#TESTDIR_" . $suite . 
+	    $test_dir_list[$i - 1] :
+	    "";
 	local $next_href = ($i < $#test_dir_list) ?
 	  "\#TESTDIR_" . $suite . $test_dir_list[$i + 1] : "";
-	&process_test_dir ($suite_path . $suite . "/", $test_dir_list[$i], $suite, 
+	&process_test_dir ($suite_path . $suite . "/", $test_dir_list[$i], 
+			   $suite, 
 			   $prev_href, $next_href);
     }
+    $javascript .= "currSuite.count = $suite_count;\n";
 
-    $html .= "  </dl>\n";
-
+    $html .= "</dd>\n";
 }
 
 #
-# Append detail from a test directory, calling process_test for subordinate js files
+# Append detail from a test directory, 
+# calling process_test for subordinate js files
 #
 sub process_test_dir {
     local ($test_dir_path, $test_dir, $suite, $prev_href, $next_href) = @_;
 
     @test_list = sort(&get_js_files ($test_dir_path . $test_dir));
 
-    $javascript .= "suites[\"$suite\"].testDirs[\"$test_dir\"] = {tests: {}};\n";
+    $suite_count += @test_list;
 
-    $html .= "    <a name='TESTDIR_$suite$test_dir'></a>\n";
-    $html .= "    <dt><big><b>$test_dir (" . ($#test_list + 1) .
-      " tests)</b></big><br>\n";
-    $html .= "      <input type='button' value='Select All' " .
-      "onclick='selectAll(\"$suite\", \"$test_dir\");'>\n";
-    $html .= "      <input type='button' value='Select None' " .
-      "onclick='selectNone(\"$suite\", \"$test_dir\");'> ";
+    $javascript .= "currDirectory = currTestDirs[\"$test_dir\"] = " . 
+	"{tests:{}};\n";
+    $javascript .= "currTests = currDirectory.tests;\n";
+
+    $html .= "<dl>\n";
+    $html .= "<dt>\n";
+    $html .= "<a name='TESTDIR_$suite$test_dir'></a>\n";
+    $html .= "$test_dir (" . ($#test_list + 1) . " tests)\n";
+    $html .= "<input type='button' value='Select All' " .
+	"onclick='selectAll(\"$suite\", \"$test_dir\");'>\n";
+    $html .= "<input type='button' value='Select None' " .
+	"onclick='selectNone(\"$suite\", \"$test_dir\");'> ";
     $html .= "[ <a href='\#SUITE_$suite'>Top of $suite Suite</a> ";
     if ($prev_href) {
 	$html .= "| <a href='$prev_href'>Previous Category</a> ";
@@ -170,16 +201,16 @@ sub process_test_dir {
     if ($next_href) {
 	$html .= " | <a href='$next_href'>Next Category</a> ";
     }
-    $html .= "]<br>\n";
-    $html .= "    </dt>\n";
+    $html .= "]\n";
+    $html .= "</dt>\n";
 
-    $html .= "    <dl>\n";
+    $html .= "<dd>\n";
 
     foreach $test (@test_list) {
 	&process_test ($test_dir_path . $test_dir, $test);
     }
     
-    $html .= "    </dl>\n";
+    $html .= "</dl>\n";
 }
 
 
@@ -196,25 +227,32 @@ sub process_test {
       die ("Error opening " . $test_dir_path . "/" . $test);
 
     while (<TESTCASE>) {
-	if (/.*TITLE\s+\=\s+\"(.*)\"/) {
+	if (/.*(TITLE|summary)\s+\=\s+[\"\'](.*)[\"\']/i) {
+	    $title = $2;
+	    break;
+	}
+	if (/.*START\([\"\'](.*)[\"\']\);/)
+        {
 	    $title = $1;
 	    break;
 	}
     }
     close (TESTCASE);
 
-    $javascript .= "suites[\"$suite\"].testDirs[\"$test_dir\"].tests" .
-      "[\"$test\"] = \"radio$uid\"\n";
-    $html .= "      <input type='radio' value='$test' name='radio$uid' ".
-      "onclick='return onRadioClick(\"radio$uid\");'>" .
-	"<a href='$lxr_url$suite/$test_dir/$test' target='other_window'>" .
-	  "$test</a> $title<br>\n";
+    $javascript .= "currTests[\"$test\"] = {id:\"t$uid\"}\n";
+    $html .= "<dd>\n";
+    $html .= " <input type='checkbox' value='$test' name='t$uid' " .
+        "id='$suite:$test_dir:$test' ".
+	"onclick='return onRadioClick(this);'>\n";
+    $html .= "<a href='$lxr_url$suite/$test_dir/$test' target='other_window'>" .
+	"$test</a> $title\n";
+    $html .= "</dd>\n";
 
 }
 
 sub scriptTag {
 
-    return ("<script langugage='JavaScript'>@_</script>");
+    return ("<script type='text/javascript' language='JavaScript'>@_</script>");
 
 }
 
@@ -255,7 +293,7 @@ sub get_js_files {
     closedir( TEST_SUBDIR );
 
     foreach ( @subdir_files ) {
-        if ( $_ =~ /\.js$/ ) {
+        if ( ($_ =~ /\.js$/) && ($_ ne 'shell.js') && ($_ ne 'browser.js') ) {
             $js_file_array[$#js_file_array+1] = $_;
         }
     }
diff --git a/mozilla/js/tests/runRhinoTests.pl b/mozilla/js/tests/runRhinoTests.pl
index e80ef9251bc..906323cab33 100644
--- a/mozilla/js/tests/runRhinoTests.pl
+++ b/mozilla/js/tests/runRhinoTests.pl
@@ -1,4 +1,4 @@
-#!/tools/ns/bin/perl5
+#!/usr/bin/perl5
 #
 # simple script that executes JavaScript tests.  you have to build the
 # stand-alone, js shell executable (which is not the same as the dll that gets
diff --git a/mozilla/js/tests/runtests.pl b/mozilla/js/tests/runtests.pl
index f6f05fb238f..7a4b2aefca9 100644
--- a/mozilla/js/tests/runtests.pl
+++ b/mozilla/js/tests/runtests.pl
@@ -1,4 +1,4 @@
-#!/tools/ns/bin/perl5
+#!/usr/bin/perl5
 #
 # simple script that executes JavaScript tests.  you have to build the
 # stand-alone, js shell executable (which is not the same as the dll that gets