From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- js/src/tests/ecma_3/Array/15.4.4.11-01.js | 28 + js/src/tests/ecma_3/Array/15.4.4.3-1.js | 54 + js/src/tests/ecma_3/Array/15.4.4.4-001.js | 119 + js/src/tests/ecma_3/Array/15.4.5.1-01.js | 60 + js/src/tests/ecma_3/Array/15.5.4.8-01.js | 43 + js/src/tests/ecma_3/Array/browser.js | 0 js/src/tests/ecma_3/Array/regress-101488.js | 138 + js/src/tests/ecma_3/Array/regress-130451.js | 185 + js/src/tests/ecma_3/Array/regress-322135-01.js | 39 + js/src/tests/ecma_3/Array/regress-322135-02.js | 32 + js/src/tests/ecma_3/Array/regress-322135-03.js | 40 + js/src/tests/ecma_3/Array/regress-322135-04.js | 38 + js/src/tests/ecma_3/Array/regress-387501.js | 51 + js/src/tests/ecma_3/Array/regress-390598.js | 40 + js/src/tests/ecma_3/Array/regress-421325.js | 34 + js/src/tests/ecma_3/Array/regress-430717.js | 32 + js/src/tests/ecma_3/Array/regress-488989.js | 35 + js/src/tests/ecma_3/Array/regress-619970.js | 8 + js/src/tests/ecma_3/Array/shell.js | 0 js/src/tests/ecma_3/Date/15.9.1.2-01.js | 29 + js/src/tests/ecma_3/Date/15.9.4.3.js | 200 + js/src/tests/ecma_3/Date/15.9.5.3.js | 118 + js/src/tests/ecma_3/Date/15.9.5.4.js | 151 + js/src/tests/ecma_3/Date/15.9.5.5-02.js | 66 + js/src/tests/ecma_3/Date/15.9.5.5.js | 111 + js/src/tests/ecma_3/Date/15.9.5.6.js | 119 + js/src/tests/ecma_3/Date/15.9.5.7.js | 108 + js/src/tests/ecma_3/Date/browser.js | 0 js/src/tests/ecma_3/Date/regress-452786.js | 33 + js/src/tests/ecma_3/Date/shell.js | 530 ++ js/src/tests/ecma_3/Exceptions/15.11.1.1.js | 103 + js/src/tests/ecma_3/Exceptions/15.11.4.4-1.js | 140 + js/src/tests/ecma_3/Exceptions/15.11.5.js | 36 + js/src/tests/ecma_3/Exceptions/15.11.7.6-001.js | 96 + js/src/tests/ecma_3/Exceptions/15.11.7.6-002.js | 98 + js/src/tests/ecma_3/Exceptions/15.11.7.6-003.js | 98 + js/src/tests/ecma_3/Exceptions/binding-001.js | 94 + js/src/tests/ecma_3/Exceptions/browser.js | 0 js/src/tests/ecma_3/Exceptions/regress-181654.js | 121 + js/src/tests/ecma_3/Exceptions/regress-181914.js | 160 + js/src/tests/ecma_3/Exceptions/regress-58946.js | 36 + js/src/tests/ecma_3/Exceptions/regress-95101.js | 84 + js/src/tests/ecma_3/Exceptions/shell.js | 0 js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js | 167 + js/src/tests/ecma_3/ExecutionContexts/10.1.3-2.js | 37 + js/src/tests/ecma_3/ExecutionContexts/10.1.3.js | 37 + js/src/tests/ecma_3/ExecutionContexts/10.1.4-1.js | 49 + js/src/tests/ecma_3/ExecutionContexts/10.6.1-01.js | 103 + js/src/tests/ecma_3/ExecutionContexts/browser.js | 0 .../ecma_3/ExecutionContexts/regress-23346.js | 35 + .../ecma_3/ExecutionContexts/regress-448595-01.js | 58 + js/src/tests/ecma_3/ExecutionContexts/shell.js | 0 js/src/tests/ecma_3/Expressions/11.10-01.js | 43 + js/src/tests/ecma_3/Expressions/11.10-02.js | 43 + js/src/tests/ecma_3/Expressions/11.10-03.js | 43 + js/src/tests/ecma_3/Expressions/11.6.1-1.js | 142 + js/src/tests/ecma_3/Expressions/11.7.1-01.js | 43 + js/src/tests/ecma_3/Expressions/11.7.2-01.js | 43 + js/src/tests/ecma_3/Expressions/11.7.3-01.js | 43 + js/src/tests/ecma_3/Expressions/11.9.6-1.js | 179 + js/src/tests/ecma_3/Expressions/browser.js | 0 js/src/tests/ecma_3/Expressions/shell.js | 0 js/src/tests/ecma_3/FunExpr/browser.js | 0 js/src/tests/ecma_3/FunExpr/fe-001-n.js | 22 + js/src/tests/ecma_3/FunExpr/fe-001.js | 21 + js/src/tests/ecma_3/FunExpr/fe-002.js | 25 + js/src/tests/ecma_3/FunExpr/regress-518103.js | 27 + js/src/tests/ecma_3/FunExpr/regress-524826.js | 28 + js/src/tests/ecma_3/FunExpr/regress-528082.js | 20 + js/src/tests/ecma_3/FunExpr/regress-533254.js | 28 + js/src/tests/ecma_3/FunExpr/regress-545980.js | 41 + js/src/tests/ecma_3/FunExpr/shell.js | 0 js/src/tests/ecma_3/Function/15.3.4.3-1.js | 176 + js/src/tests/ecma_3/Function/15.3.4.4-1.js | 162 + js/src/tests/ecma_3/Function/arguments-001.js | 135 + js/src/tests/ecma_3/Function/arguments-002.js | 40 + js/src/tests/ecma_3/Function/browser.js | 0 js/src/tests/ecma_3/Function/call-001.js | 119 + js/src/tests/ecma_3/Function/regress-131964.js | 162 + js/src/tests/ecma_3/Function/regress-137181.js | 79 + js/src/tests/ecma_3/Function/regress-193555.js | 102 + js/src/tests/ecma_3/Function/regress-313570.js | 30 + js/src/tests/ecma_3/Function/regress-49286.js | 103 + js/src/tests/ecma_3/Function/regress-58274.js | 192 + js/src/tests/ecma_3/Function/regress-85880.js | 139 + js/src/tests/ecma_3/Function/regress-94506.js | 129 + js/src/tests/ecma_3/Function/regress-97921.js | 118 + js/src/tests/ecma_3/Function/scope-001.js | 231 + js/src/tests/ecma_3/Function/scope-002.js | 211 + js/src/tests/ecma_3/Function/shell.js | 0 js/src/tests/ecma_3/LexicalConventions/7.4-01.js | 40 + js/src/tests/ecma_3/LexicalConventions/7.8.3-01.js | 23 + js/src/tests/ecma_3/LexicalConventions/7.9.1.js | 124 + js/src/tests/ecma_3/LexicalConventions/browser.js | 0 js/src/tests/ecma_3/LexicalConventions/shell.js | 0 js/src/tests/ecma_3/Number/15.7.4.2-01.js | 44 + js/src/tests/ecma_3/Number/15.7.4.3-01.js | 36 + js/src/tests/ecma_3/Number/15.7.4.5-1.js | 111 + js/src/tests/ecma_3/Number/15.7.4.5-2.js | 29 + js/src/tests/ecma_3/Number/15.7.4.6-1.js | 115 + js/src/tests/ecma_3/Number/15.7.4.7-1.js | 120 + js/src/tests/ecma_3/Number/15.7.4.7-2.js | 39 + js/src/tests/ecma_3/Number/browser.js | 0 js/src/tests/ecma_3/Number/regress-442242-01.js | 29 + js/src/tests/ecma_3/Number/shell.js | 0 js/src/tests/ecma_3/NumberFormatting/browser.js | 0 js/src/tests/ecma_3/NumberFormatting/shell.js | 0 .../tests/ecma_3/NumberFormatting/tostring-001.js | 24 + js/src/tests/ecma_3/Object/8.6.1-01.js | 80 + js/src/tests/ecma_3/Object/8.6.2.6-001.js | 79 + js/src/tests/ecma_3/Object/8.6.2.6-002.js | 46 + js/src/tests/ecma_3/Object/browser.js | 7 + js/src/tests/ecma_3/Object/class-001.js | 122 + js/src/tests/ecma_3/Object/class-002.js | 112 + js/src/tests/ecma_3/Object/class-003.js | 105 + js/src/tests/ecma_3/Object/class-004.js | 105 + js/src/tests/ecma_3/Object/class-005.js | 90 + js/src/tests/ecma_3/Object/regress-361274.js | 33 + js/src/tests/ecma_3/Object/regress-385393-07.js | 34 + js/src/tests/ecma_3/Object/regress-459405.js | 40 + js/src/tests/ecma_3/Object/regress-72773.js | 63 + js/src/tests/ecma_3/Object/regress-79129-001.js | 46 + js/src/tests/ecma_3/Object/shell.js | 71 + js/src/tests/ecma_3/Operators/11.13.1-001.js | 118 + js/src/tests/ecma_3/Operators/11.13.1-002.js | 24 + js/src/tests/ecma_3/Operators/11.4.1-001.js | 86 + js/src/tests/ecma_3/Operators/11.4.1-002.js | 39 + js/src/tests/ecma_3/Operators/browser.js | 0 js/src/tests/ecma_3/Operators/order-01.js | 75 + js/src/tests/ecma_3/Operators/shell.js | 0 js/src/tests/ecma_3/README | 1 + js/src/tests/ecma_3/RegExp/15.10.2-1.js | 147 + js/src/tests/ecma_3/RegExp/15.10.2.12.js | 29 + js/src/tests/ecma_3/RegExp/15.10.3.1-1.js | 102 + js/src/tests/ecma_3/RegExp/15.10.3.1-2.js | 110 + js/src/tests/ecma_3/RegExp/15.10.4.1-1.js | 93 + js/src/tests/ecma_3/RegExp/15.10.4.1-2.js | 99 + js/src/tests/ecma_3/RegExp/15.10.4.1-3.js | 105 + js/src/tests/ecma_3/RegExp/15.10.4.1-4.js | 112 + js/src/tests/ecma_3/RegExp/15.10.4.1-6.js | 62 + js/src/tests/ecma_3/RegExp/15.10.6.2-1.js | 106 + js/src/tests/ecma_3/RegExp/15.10.6.2-2.js | 294 + js/src/tests/ecma_3/RegExp/browser.js | 0 js/src/tests/ecma_3/RegExp/octal-001.js | 102 + js/src/tests/ecma_3/RegExp/octal-002.js | 184 + js/src/tests/ecma_3/RegExp/perlstress-001.js | 3196 +++++++ js/src/tests/ecma_3/RegExp/perlstress-002.js | 1808 ++++ js/src/tests/ecma_3/RegExp/regress-100199.js | 273 + js/src/tests/ecma_3/RegExp/regress-105972.js | 123 + js/src/tests/ecma_3/RegExp/regress-119909.js | 58 + js/src/tests/ecma_3/RegExp/regress-122076.js | 76 + js/src/tests/ecma_3/RegExp/regress-123437.js | 78 + js/src/tests/ecma_3/RegExp/regress-165353.js | 88 + js/src/tests/ecma_3/RegExp/regress-169497.js | 71 + js/src/tests/ecma_3/RegExp/regress-169534.js | 61 + js/src/tests/ecma_3/RegExp/regress-187133.js | 108 + js/src/tests/ecma_3/RegExp/regress-188206.js | 185 + js/src/tests/ecma_3/RegExp/regress-191479.js | 164 + js/src/tests/ecma_3/RegExp/regress-202564.js | 67 + js/src/tests/ecma_3/RegExp/regress-209067.js | 1072 +++ js/src/tests/ecma_3/RegExp/regress-209919.js | 140 + js/src/tests/ecma_3/RegExp/regress-216591.js | 83 + js/src/tests/ecma_3/RegExp/regress-220367-001.js | 70 + js/src/tests/ecma_3/RegExp/regress-223273.js | 245 + js/src/tests/ecma_3/RegExp/regress-223535.js | 99 + js/src/tests/ecma_3/RegExp/regress-224676.js | 192 + js/src/tests/ecma_3/RegExp/regress-225289.js | 142 + js/src/tests/ecma_3/RegExp/regress-225343.js | 91 + js/src/tests/ecma_3/RegExp/regress-24712.js | 23 + js/src/tests/ecma_3/RegExp/regress-285219.js | 18 + js/src/tests/ecma_3/RegExp/regress-28686.js | 21 + js/src/tests/ecma_3/RegExp/regress-307456.js | 22 + js/src/tests/ecma_3/RegExp/regress-309840.js | 24 + js/src/tests/ecma_3/RegExp/regress-312351.js | 17 + js/src/tests/ecma_3/RegExp/regress-31316.js | 62 + js/src/tests/ecma_3/RegExp/regress-330684.js | 21 + js/src/tests/ecma_3/RegExp/regress-334158.js | 25 + js/src/tests/ecma_3/RegExp/regress-346090.js | 29 + js/src/tests/ecma_3/RegExp/regress-367888.js | 29 + js/src/tests/ecma_3/RegExp/regress-375642.js | 28 + js/src/tests/ecma_3/RegExp/regress-375651.js | 29 + js/src/tests/ecma_3/RegExp/regress-375711.js | 85 + js/src/tests/ecma_3/RegExp/regress-375715-01-n.js | 30 + js/src/tests/ecma_3/RegExp/regress-375715-02.js | 27 + js/src/tests/ecma_3/RegExp/regress-375715-03.js | 27 + js/src/tests/ecma_3/RegExp/regress-375715-04.js | 35 + js/src/tests/ecma_3/RegExp/regress-436700.js | 34 + js/src/tests/ecma_3/RegExp/regress-465862.js | 82 + js/src/tests/ecma_3/RegExp/regress-57572.js | 116 + js/src/tests/ecma_3/RegExp/regress-57631.js | 118 + js/src/tests/ecma_3/RegExp/regress-67773.js | 177 + js/src/tests/ecma_3/RegExp/regress-72964.js | 87 + js/src/tests/ecma_3/RegExp/regress-76683.js | 80 + js/src/tests/ecma_3/RegExp/regress-78156.js | 89 + js/src/tests/ecma_3/RegExp/regress-85721.js | 243 + js/src/tests/ecma_3/RegExp/regress-87231.js | 111 + js/src/tests/ecma_3/RegExp/regress-98306.js | 65 + js/src/tests/ecma_3/RegExp/shell.js | 232 + js/src/tests/ecma_3/Regress/browser.js | 0 js/src/tests/ecma_3/Regress/regress-385393-04.js | 33 + js/src/tests/ecma_3/Regress/regress-419152.js | 57 + js/src/tests/ecma_3/Regress/regress-420087.js | 31 + js/src/tests/ecma_3/Regress/regress-420610.js | 17 + js/src/tests/ecma_3/Regress/regress-441477-01.js | 42 + js/src/tests/ecma_3/Regress/regress-469937.js | 27 + js/src/tests/ecma_3/Regress/regress-580544.js | 30 + js/src/tests/ecma_3/Regress/shell.js | 0 js/src/tests/ecma_3/Statements/12.10-01.js | 35 + js/src/tests/ecma_3/Statements/12.6.3.js | 47 + js/src/tests/ecma_3/Statements/browser.js | 0 js/src/tests/ecma_3/Statements/regress-121744.js | 184 + js/src/tests/ecma_3/Statements/regress-131348.js | 150 + js/src/tests/ecma_3/Statements/regress-157509.js | 77 + js/src/tests/ecma_3/Statements/regress-194364.js | 118 + js/src/tests/ecma_3/Statements/regress-226517.js | 78 + js/src/tests/ecma_3/Statements/regress-302439.js | 1335 +++ js/src/tests/ecma_3/Statements/regress-324650.js | 5427 ++++++++++++ js/src/tests/ecma_3/Statements/regress-444979.js | 43 + js/src/tests/ecma_3/Statements/regress-642975.js | 30 + .../tests/ecma_3/Statements/regress-74474-001.js | 105 + .../tests/ecma_3/Statements/regress-74474-002.js | 9063 +++++++++++++++++++ .../tests/ecma_3/Statements/regress-74474-003.js | 9065 ++++++++++++++++++++ .../tests/ecma_3/Statements/regress-83532-001.js | 37 + .../tests/ecma_3/Statements/regress-83532-002.js | 40 + js/src/tests/ecma_3/Statements/shell.js | 0 js/src/tests/ecma_3/Statements/switch-001.js | 109 + js/src/tests/ecma_3/Statements/switch-002.js | 19 + js/src/tests/ecma_3/String/15.5.4.11.js | 498 ++ js/src/tests/ecma_3/String/15.5.4.14.js | 17 + js/src/tests/ecma_3/String/browser.js | 0 js/src/tests/ecma_3/String/regress-104375.js | 82 + js/src/tests/ecma_3/String/regress-189898.js | 123 + js/src/tests/ecma_3/String/regress-304376.js | 34 + js/src/tests/ecma_3/String/regress-313567.js | 23 + js/src/tests/ecma_3/String/regress-369778.js | 29 + js/src/tests/ecma_3/String/regress-392378.js | 44 + js/src/tests/ecma_3/String/regress-83293.js | 182 + js/src/tests/ecma_3/String/shell.js | 0 js/src/tests/ecma_3/Unicode/browser.js | 0 js/src/tests/ecma_3/Unicode/regress-352044-01.js | 39 + js/src/tests/ecma_3/Unicode/regress-352044-02-n.js | 39 + js/src/tests/ecma_3/Unicode/shell.js | 0 js/src/tests/ecma_3/Unicode/uc-001-n.js | 26 + js/src/tests/ecma_3/Unicode/uc-001.js | 21 + js/src/tests/ecma_3/Unicode/uc-002-n.js | 19 + js/src/tests/ecma_3/Unicode/uc-002.js | 24 + js/src/tests/ecma_3/Unicode/uc-003.js | 30 + js/src/tests/ecma_3/Unicode/uc-004.js | 29 + js/src/tests/ecma_3/Unicode/uc-005.js | 242 + js/src/tests/ecma_3/browser.js | 0 js/src/tests/ecma_3/extensions/10.1.3-2.js | 128 + js/src/tests/ecma_3/extensions/7.9.1.js | 47 + js/src/tests/ecma_3/extensions/browser.js | 0 js/src/tests/ecma_3/extensions/regress-103087.js | 144 + .../tests/ecma_3/extensions/regress-188206-01.js | 74 + .../tests/ecma_3/extensions/regress-188206-02.js | 124 + .../tests/ecma_3/extensions/regress-220367-002.js | 78 + js/src/tests/ecma_3/extensions/regress-228087.js | 318 + js/src/tests/ecma_3/extensions/regress-274152.js | 48 + js/src/tests/ecma_3/extensions/regress-320854.js | 20 + js/src/tests/ecma_3/extensions/regress-327170.js | 25 + js/src/tests/ecma_3/extensions/regress-368516.js | 45 + .../tests/ecma_3/extensions/regress-385393-03.js | 30 + js/src/tests/ecma_3/extensions/regress-430740.js | 39 + js/src/tests/ecma_3/extensions/shell.js | 232 + js/src/tests/ecma_3/shell.js | 0 js/src/tests/ecma_3/template.js | 28 + 267 files changed, 50123 insertions(+) create mode 100644 js/src/tests/ecma_3/Array/15.4.4.11-01.js create mode 100644 js/src/tests/ecma_3/Array/15.4.4.3-1.js create mode 100644 js/src/tests/ecma_3/Array/15.4.4.4-001.js create mode 100644 js/src/tests/ecma_3/Array/15.4.5.1-01.js create mode 100644 js/src/tests/ecma_3/Array/15.5.4.8-01.js create mode 100644 js/src/tests/ecma_3/Array/browser.js create mode 100644 js/src/tests/ecma_3/Array/regress-101488.js create mode 100644 js/src/tests/ecma_3/Array/regress-130451.js create mode 100644 js/src/tests/ecma_3/Array/regress-322135-01.js create mode 100644 js/src/tests/ecma_3/Array/regress-322135-02.js create mode 100644 js/src/tests/ecma_3/Array/regress-322135-03.js create mode 100644 js/src/tests/ecma_3/Array/regress-322135-04.js create mode 100644 js/src/tests/ecma_3/Array/regress-387501.js create mode 100644 js/src/tests/ecma_3/Array/regress-390598.js create mode 100644 js/src/tests/ecma_3/Array/regress-421325.js create mode 100644 js/src/tests/ecma_3/Array/regress-430717.js create mode 100644 js/src/tests/ecma_3/Array/regress-488989.js create mode 100644 js/src/tests/ecma_3/Array/regress-619970.js create mode 100644 js/src/tests/ecma_3/Array/shell.js create mode 100644 js/src/tests/ecma_3/Date/15.9.1.2-01.js create mode 100644 js/src/tests/ecma_3/Date/15.9.4.3.js create mode 100644 js/src/tests/ecma_3/Date/15.9.5.3.js create mode 100644 js/src/tests/ecma_3/Date/15.9.5.4.js create mode 100644 js/src/tests/ecma_3/Date/15.9.5.5-02.js create mode 100644 js/src/tests/ecma_3/Date/15.9.5.5.js create mode 100644 js/src/tests/ecma_3/Date/15.9.5.6.js create mode 100644 js/src/tests/ecma_3/Date/15.9.5.7.js create mode 100644 js/src/tests/ecma_3/Date/browser.js create mode 100644 js/src/tests/ecma_3/Date/regress-452786.js create mode 100644 js/src/tests/ecma_3/Date/shell.js create mode 100644 js/src/tests/ecma_3/Exceptions/15.11.1.1.js create mode 100644 js/src/tests/ecma_3/Exceptions/15.11.4.4-1.js create mode 100644 js/src/tests/ecma_3/Exceptions/15.11.5.js create mode 100644 js/src/tests/ecma_3/Exceptions/15.11.7.6-001.js create mode 100644 js/src/tests/ecma_3/Exceptions/15.11.7.6-002.js create mode 100644 js/src/tests/ecma_3/Exceptions/15.11.7.6-003.js create mode 100644 js/src/tests/ecma_3/Exceptions/binding-001.js create mode 100644 js/src/tests/ecma_3/Exceptions/browser.js create mode 100644 js/src/tests/ecma_3/Exceptions/regress-181654.js create mode 100644 js/src/tests/ecma_3/Exceptions/regress-181914.js create mode 100644 js/src/tests/ecma_3/Exceptions/regress-58946.js create mode 100644 js/src/tests/ecma_3/Exceptions/regress-95101.js create mode 100644 js/src/tests/ecma_3/Exceptions/shell.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/10.1.3-2.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/10.1.3.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/10.1.4-1.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/10.6.1-01.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/browser.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/regress-23346.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/regress-448595-01.js create mode 100644 js/src/tests/ecma_3/ExecutionContexts/shell.js create mode 100644 js/src/tests/ecma_3/Expressions/11.10-01.js create mode 100644 js/src/tests/ecma_3/Expressions/11.10-02.js create mode 100644 js/src/tests/ecma_3/Expressions/11.10-03.js create mode 100644 js/src/tests/ecma_3/Expressions/11.6.1-1.js create mode 100644 js/src/tests/ecma_3/Expressions/11.7.1-01.js create mode 100644 js/src/tests/ecma_3/Expressions/11.7.2-01.js create mode 100644 js/src/tests/ecma_3/Expressions/11.7.3-01.js create mode 100644 js/src/tests/ecma_3/Expressions/11.9.6-1.js create mode 100644 js/src/tests/ecma_3/Expressions/browser.js create mode 100644 js/src/tests/ecma_3/Expressions/shell.js create mode 100644 js/src/tests/ecma_3/FunExpr/browser.js create mode 100644 js/src/tests/ecma_3/FunExpr/fe-001-n.js create mode 100644 js/src/tests/ecma_3/FunExpr/fe-001.js create mode 100644 js/src/tests/ecma_3/FunExpr/fe-002.js create mode 100644 js/src/tests/ecma_3/FunExpr/regress-518103.js create mode 100644 js/src/tests/ecma_3/FunExpr/regress-524826.js create mode 100644 js/src/tests/ecma_3/FunExpr/regress-528082.js create mode 100644 js/src/tests/ecma_3/FunExpr/regress-533254.js create mode 100644 js/src/tests/ecma_3/FunExpr/regress-545980.js create mode 100644 js/src/tests/ecma_3/FunExpr/shell.js create mode 100644 js/src/tests/ecma_3/Function/15.3.4.3-1.js create mode 100644 js/src/tests/ecma_3/Function/15.3.4.4-1.js create mode 100644 js/src/tests/ecma_3/Function/arguments-001.js create mode 100644 js/src/tests/ecma_3/Function/arguments-002.js create mode 100644 js/src/tests/ecma_3/Function/browser.js create mode 100644 js/src/tests/ecma_3/Function/call-001.js create mode 100644 js/src/tests/ecma_3/Function/regress-131964.js create mode 100644 js/src/tests/ecma_3/Function/regress-137181.js create mode 100644 js/src/tests/ecma_3/Function/regress-193555.js create mode 100644 js/src/tests/ecma_3/Function/regress-313570.js create mode 100644 js/src/tests/ecma_3/Function/regress-49286.js create mode 100644 js/src/tests/ecma_3/Function/regress-58274.js create mode 100644 js/src/tests/ecma_3/Function/regress-85880.js create mode 100644 js/src/tests/ecma_3/Function/regress-94506.js create mode 100644 js/src/tests/ecma_3/Function/regress-97921.js create mode 100644 js/src/tests/ecma_3/Function/scope-001.js create mode 100644 js/src/tests/ecma_3/Function/scope-002.js create mode 100644 js/src/tests/ecma_3/Function/shell.js create mode 100644 js/src/tests/ecma_3/LexicalConventions/7.4-01.js create mode 100644 js/src/tests/ecma_3/LexicalConventions/7.8.3-01.js create mode 100644 js/src/tests/ecma_3/LexicalConventions/7.9.1.js create mode 100644 js/src/tests/ecma_3/LexicalConventions/browser.js create mode 100644 js/src/tests/ecma_3/LexicalConventions/shell.js create mode 100644 js/src/tests/ecma_3/Number/15.7.4.2-01.js create mode 100644 js/src/tests/ecma_3/Number/15.7.4.3-01.js create mode 100644 js/src/tests/ecma_3/Number/15.7.4.5-1.js create mode 100644 js/src/tests/ecma_3/Number/15.7.4.5-2.js create mode 100644 js/src/tests/ecma_3/Number/15.7.4.6-1.js create mode 100644 js/src/tests/ecma_3/Number/15.7.4.7-1.js create mode 100644 js/src/tests/ecma_3/Number/15.7.4.7-2.js create mode 100644 js/src/tests/ecma_3/Number/browser.js create mode 100644 js/src/tests/ecma_3/Number/regress-442242-01.js create mode 100644 js/src/tests/ecma_3/Number/shell.js create mode 100644 js/src/tests/ecma_3/NumberFormatting/browser.js create mode 100644 js/src/tests/ecma_3/NumberFormatting/shell.js create mode 100644 js/src/tests/ecma_3/NumberFormatting/tostring-001.js create mode 100644 js/src/tests/ecma_3/Object/8.6.1-01.js create mode 100644 js/src/tests/ecma_3/Object/8.6.2.6-001.js create mode 100644 js/src/tests/ecma_3/Object/8.6.2.6-002.js create mode 100644 js/src/tests/ecma_3/Object/browser.js create mode 100644 js/src/tests/ecma_3/Object/class-001.js create mode 100644 js/src/tests/ecma_3/Object/class-002.js create mode 100644 js/src/tests/ecma_3/Object/class-003.js create mode 100644 js/src/tests/ecma_3/Object/class-004.js create mode 100644 js/src/tests/ecma_3/Object/class-005.js create mode 100644 js/src/tests/ecma_3/Object/regress-361274.js create mode 100644 js/src/tests/ecma_3/Object/regress-385393-07.js create mode 100644 js/src/tests/ecma_3/Object/regress-459405.js create mode 100644 js/src/tests/ecma_3/Object/regress-72773.js create mode 100644 js/src/tests/ecma_3/Object/regress-79129-001.js create mode 100644 js/src/tests/ecma_3/Object/shell.js create mode 100644 js/src/tests/ecma_3/Operators/11.13.1-001.js create mode 100644 js/src/tests/ecma_3/Operators/11.13.1-002.js create mode 100644 js/src/tests/ecma_3/Operators/11.4.1-001.js create mode 100644 js/src/tests/ecma_3/Operators/11.4.1-002.js create mode 100644 js/src/tests/ecma_3/Operators/browser.js create mode 100644 js/src/tests/ecma_3/Operators/order-01.js create mode 100644 js/src/tests/ecma_3/Operators/shell.js create mode 100644 js/src/tests/ecma_3/README create mode 100644 js/src/tests/ecma_3/RegExp/15.10.2-1.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.2.12.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.3.1-1.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.3.1-2.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.4.1-1.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.4.1-2.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.4.1-3.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.4.1-4.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.4.1-6.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.6.2-1.js create mode 100644 js/src/tests/ecma_3/RegExp/15.10.6.2-2.js create mode 100644 js/src/tests/ecma_3/RegExp/browser.js create mode 100644 js/src/tests/ecma_3/RegExp/octal-001.js create mode 100644 js/src/tests/ecma_3/RegExp/octal-002.js create mode 100644 js/src/tests/ecma_3/RegExp/perlstress-001.js create mode 100644 js/src/tests/ecma_3/RegExp/perlstress-002.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-100199.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-105972.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-119909.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-122076.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-123437.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-165353.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-169497.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-169534.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-187133.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-188206.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-191479.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-202564.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-209067.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-209919.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-216591.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-220367-001.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-223273.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-223535.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-224676.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-225289.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-225343.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-24712.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-285219.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-28686.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-307456.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-309840.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-312351.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-31316.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-330684.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-334158.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-346090.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-367888.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-375642.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-375651.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-375711.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-375715-01-n.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-375715-02.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-375715-03.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-375715-04.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-436700.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-465862.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-57572.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-57631.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-67773.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-72964.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-76683.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-78156.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-85721.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-87231.js create mode 100644 js/src/tests/ecma_3/RegExp/regress-98306.js create mode 100644 js/src/tests/ecma_3/RegExp/shell.js create mode 100644 js/src/tests/ecma_3/Regress/browser.js create mode 100644 js/src/tests/ecma_3/Regress/regress-385393-04.js create mode 100644 js/src/tests/ecma_3/Regress/regress-419152.js create mode 100644 js/src/tests/ecma_3/Regress/regress-420087.js create mode 100644 js/src/tests/ecma_3/Regress/regress-420610.js create mode 100644 js/src/tests/ecma_3/Regress/regress-441477-01.js create mode 100644 js/src/tests/ecma_3/Regress/regress-469937.js create mode 100644 js/src/tests/ecma_3/Regress/regress-580544.js create mode 100644 js/src/tests/ecma_3/Regress/shell.js create mode 100644 js/src/tests/ecma_3/Statements/12.10-01.js create mode 100644 js/src/tests/ecma_3/Statements/12.6.3.js create mode 100644 js/src/tests/ecma_3/Statements/browser.js create mode 100644 js/src/tests/ecma_3/Statements/regress-121744.js create mode 100644 js/src/tests/ecma_3/Statements/regress-131348.js create mode 100644 js/src/tests/ecma_3/Statements/regress-157509.js create mode 100644 js/src/tests/ecma_3/Statements/regress-194364.js create mode 100644 js/src/tests/ecma_3/Statements/regress-226517.js create mode 100644 js/src/tests/ecma_3/Statements/regress-302439.js create mode 100644 js/src/tests/ecma_3/Statements/regress-324650.js create mode 100644 js/src/tests/ecma_3/Statements/regress-444979.js create mode 100644 js/src/tests/ecma_3/Statements/regress-642975.js create mode 100644 js/src/tests/ecma_3/Statements/regress-74474-001.js create mode 100644 js/src/tests/ecma_3/Statements/regress-74474-002.js create mode 100644 js/src/tests/ecma_3/Statements/regress-74474-003.js create mode 100644 js/src/tests/ecma_3/Statements/regress-83532-001.js create mode 100644 js/src/tests/ecma_3/Statements/regress-83532-002.js create mode 100644 js/src/tests/ecma_3/Statements/shell.js create mode 100644 js/src/tests/ecma_3/Statements/switch-001.js create mode 100644 js/src/tests/ecma_3/Statements/switch-002.js create mode 100644 js/src/tests/ecma_3/String/15.5.4.11.js create mode 100644 js/src/tests/ecma_3/String/15.5.4.14.js create mode 100644 js/src/tests/ecma_3/String/browser.js create mode 100644 js/src/tests/ecma_3/String/regress-104375.js create mode 100644 js/src/tests/ecma_3/String/regress-189898.js create mode 100644 js/src/tests/ecma_3/String/regress-304376.js create mode 100644 js/src/tests/ecma_3/String/regress-313567.js create mode 100644 js/src/tests/ecma_3/String/regress-369778.js create mode 100644 js/src/tests/ecma_3/String/regress-392378.js create mode 100644 js/src/tests/ecma_3/String/regress-83293.js create mode 100644 js/src/tests/ecma_3/String/shell.js create mode 100644 js/src/tests/ecma_3/Unicode/browser.js create mode 100644 js/src/tests/ecma_3/Unicode/regress-352044-01.js create mode 100644 js/src/tests/ecma_3/Unicode/regress-352044-02-n.js create mode 100644 js/src/tests/ecma_3/Unicode/shell.js create mode 100644 js/src/tests/ecma_3/Unicode/uc-001-n.js create mode 100644 js/src/tests/ecma_3/Unicode/uc-001.js create mode 100644 js/src/tests/ecma_3/Unicode/uc-002-n.js create mode 100644 js/src/tests/ecma_3/Unicode/uc-002.js create mode 100644 js/src/tests/ecma_3/Unicode/uc-003.js create mode 100644 js/src/tests/ecma_3/Unicode/uc-004.js create mode 100644 js/src/tests/ecma_3/Unicode/uc-005.js create mode 100644 js/src/tests/ecma_3/browser.js create mode 100644 js/src/tests/ecma_3/extensions/10.1.3-2.js create mode 100644 js/src/tests/ecma_3/extensions/7.9.1.js create mode 100644 js/src/tests/ecma_3/extensions/browser.js create mode 100644 js/src/tests/ecma_3/extensions/regress-103087.js create mode 100644 js/src/tests/ecma_3/extensions/regress-188206-01.js create mode 100644 js/src/tests/ecma_3/extensions/regress-188206-02.js create mode 100644 js/src/tests/ecma_3/extensions/regress-220367-002.js create mode 100644 js/src/tests/ecma_3/extensions/regress-228087.js create mode 100644 js/src/tests/ecma_3/extensions/regress-274152.js create mode 100644 js/src/tests/ecma_3/extensions/regress-320854.js create mode 100644 js/src/tests/ecma_3/extensions/regress-327170.js create mode 100644 js/src/tests/ecma_3/extensions/regress-368516.js create mode 100644 js/src/tests/ecma_3/extensions/regress-385393-03.js create mode 100644 js/src/tests/ecma_3/extensions/regress-430740.js create mode 100644 js/src/tests/ecma_3/extensions/shell.js create mode 100644 js/src/tests/ecma_3/shell.js create mode 100644 js/src/tests/ecma_3/template.js (limited to 'js/src/tests/ecma_3') diff --git a/js/src/tests/ecma_3/Array/15.4.4.11-01.js b/js/src/tests/ecma_3/Array/15.4.4.11-01.js new file mode 100644 index 000000000..d92ad5fce --- /dev/null +++ b/js/src/tests/ecma_3/Array/15.4.4.11-01.js @@ -0,0 +1,28 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 312138; +var summary = 'Array.sort should not eat exceptions'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expect = "e=1 N=1"; + +var N = 0; +var array = [4,3,2,1]; + +try { + array.sort(function() { + throw ++N; + }); +} catch (e) { + actual = ("e="+e+" N="+N); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/Array/15.4.4.3-1.js b/js/src/tests/ecma_3/Array/15.4.4.3-1.js new file mode 100644 index 000000000..f42834310 --- /dev/null +++ b/js/src/tests/ecma_3/Array/15.4.4.3-1.js @@ -0,0 +1,54 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 12 Mar 2001 + * + * + * SUMMARY: Testing Array.prototype.toLocaleString() + * See http://bugzilla.mozilla.org/show_bug.cgi?id=56883 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=58031 + * + * By ECMA3 15.4.4.3, myArray.toLocaleString() means that toLocaleString() + * should be applied to each element of the array, and the results should be + * concatenated with an implementation-specific delimiter. For example: + * + * myArray[0].toLocaleString() + ',' + myArray[1].toLocaleString() + etc. + * + * In this testcase toLocaleString is a user-defined property of each + * array element; therefore it is the function that should be + * invoked. This function increments a global variable. Therefore the + * end value of this variable should be myArray.length. + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = 56883; +var summary = 'Testing Array.prototype.toLocaleString() -'; +var actual = ''; +var expect = ''; +var n = 0; +var obj = {toLocaleString: function() {n++}}; +var myArray = [obj, obj, obj]; + + +myArray.toLocaleString(); +actual = n; +expect = 3; // (see explanation above) + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Array/15.4.4.4-001.js b/js/src/tests/ecma_3/Array/15.4.4.4-001.js new file mode 100644 index 000000000..602624951 --- /dev/null +++ b/js/src/tests/ecma_3/Array/15.4.4.4-001.js @@ -0,0 +1,119 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 19 September 2002 + * SUMMARY: Testing Array.prototype.concat() + * See http://bugzilla.mozilla.org/show_bug.cgi?id=169795 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 169795; +var summary = 'Testing Array.prototype.concat()'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var x; + + +status = inSection(1); +x = "Hello"; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(2); +x = 999; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(3); +x = /Hello/g; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(4); +x = new Error("Hello"); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(5); +x = function() {return "Hello";}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(6); +x = [function() {return "Hello";}]; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(7); +x = [1,2,3].concat([4,5,6]); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(8); +x = eval('this'); +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +/* + * The next two sections are by igor@icesoft.no; see + * http://bugzilla.mozilla.org/show_bug.cgi?id=169795#c3 + */ +status = inSection(9); +x={length:0}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + +status = inSection(10); +x={length:2, 0:0, 1:1}; +actual = [].concat(x).toString(); +expect = x.toString(); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i + * See http://bugzilla.mozilla.org/show_bug.cgi?id=101488 + * + * Without the "new" keyword, assigning arr.length = Number(n) worked. + * But with it, Rhino was giving an error "Inappropriate array length" + * and SpiderMonkey was exiting without giving any error or return value - + * + * Comments on the Rhino code by igor@icesoft.no: + * + * jsSet_length requires that the new length value should be an instance + * of Number. But according to Ecma 15.4.5.1, item 12-13, an error should + * be thrown only if ToUint32(length_value) != ToNumber(length_value) + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 101488; +var summary = 'Try assigning arr.length = new Number(n)'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var arr = []; + + +status = inSection(1); +arr = Array(); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(2); +arr = Array(5); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(3); +arr = Array(); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + +status = inSection(4); +arr = Array(5); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + + +/* + * Also try the above with the "new" keyword before Array(). + * Array() and new Array() should be equivalent, by ECMA 15.4.1.1 + */ +status = inSection(5); +arr = new Array(); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +status = inSection(6); +arr = new Array(5); +tryThis('arr.length = new Number(1);'); +actual = arr.length; +expect = 1; +addThis(); + +arr = new Array(); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + +status = inSection(7); +arr = new Array(5); +tryThis('arr.length = new Number(17);'); +actual = arr.length; +expect = 17; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function tryThis(s) +{ + try + { + eval(s); + } + catch(e) + { + // keep going + } +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i=0; i= dst_start && t < dst_end ) + return msPerHour; + + return 0; +} + +function GetFirstSundayInMonth( t, m ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + +// month m 0..11 +// april == 3 +// march == 2 + + // set time to first day of month m + var time = TimeFromYear(year); + for (var i = 0; i < m; ++i) + { + time += TimeInMonth(i, leap); + } + + for ( var first_sunday = time; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} + +function GetLastSundayInMonth( t, m ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + +// month m 0..11 +// april == 3 +// march == 2 + + // first day of following month + var time = TimeFromYear(year); + for (var i = 0; i <= m; ++i) + { + time += TimeInMonth(i, leap); + } + // prev day == last day of month + time -= msPerDay; + + for ( var last_sunday = time; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +/* + 15.9.1.9 Daylight Saving Time Adjustment + + The implementation of ECMAScript should not try to determine whether + the exact time was subject to daylight saving time, but just whether + daylight saving time would have been in effect if the current + daylight saving time algorithm had been used at the time. This avoids + complications such as taking into account the years that the locale + observed daylight saving time year round. +*/ + +/* + US DST algorithm + + Before 2007, DST starts first Sunday in April at 2 AM and ends last + Sunday in October at 2 AM + + Starting in 2007, DST starts second Sunday in March at 2 AM and ends + first Sunday in November at 2 AM + + Note that different operating systems behave differently. + + Fully patched Windows XP uses the 2007 algorithm for all dates while + fully patched Fedora Core 6 and RHEL 4 Linux use the algorithm in + effect at the time. + + Since pre-2007 DST is a subset of 2007 DST rules, this only affects + tests that occur in the period Mar-Apr and Oct-Nov where the two + algorithms do not agree. + +*/ + +function GetDSTStart( t ) +{ + return (GetFirstSundayInMonth(t, 2) + 7*msPerDay + 2*msPerHour - LocalTZA()); +} + +function GetDSTEnd( t ) +{ + return (GetFirstSundayInMonth(t, 10) + 2*msPerHour - LocalTZA()); +} + +function GetOldDSTStart( t ) +{ + return (GetFirstSundayInMonth(t, 3) + 2*msPerHour - LocalTZA()); +} + +function GetOldDSTEnd( t ) +{ + return (GetLastSundayInMonth(t, 9) + 2*msPerHour - LocalTZA()); +} + +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; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( 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 ); + + 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; + + 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 ); + + 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; + } + + 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 + + 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 ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.NEGATIVE_INFINITY ) { + 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 ); + } + + return ( 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 ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var p; + for ( p in o ) { + print( p +": " + o[p] ); + } +} + diff --git a/js/src/tests/ecma_3/Exceptions/15.11.1.1.js b/js/src/tests/ecma_3/Exceptions/15.11.1.1.js new file mode 100644 index 000000000..bcba1613a --- /dev/null +++ b/js/src/tests/ecma_3/Exceptions/15.11.1.1.js @@ -0,0 +1,103 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 27 Nov 2002 + * SUMMARY: Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1). + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = ''; +var summary = 'Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1)'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +function otherScope(msg) +{ + return Error(msg); +} + + +status = inSection(1); +var err1 = Error('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = otherScope('msg2'); +actual = examineThis(err2, 'msg2'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = otherScope(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = eval("Error('msg4')"); +actual = examineThis(err4, 'msg4'); +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Exceptions/15.11.4.4-1.js b/js/src/tests/ecma_3/Exceptions/15.11.4.4-1.js new file mode 100644 index 000000000..333460137 --- /dev/null +++ b/js/src/tests/ecma_3/Exceptions/15.11.4.4-1.js @@ -0,0 +1,140 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 22 Jan 2002 + * SUMMARY: Testing Error.prototype.toString() + * + * Revised: 25 Nov 2002 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=181909 + * + * Note that ECMA-262 3rd Edition Final, Section 15.11.4.4 states that + * Error.prototype.toString() returns an implementation-dependent string. + * Therefore any testcase on this property is somewhat arbitrary. + * + * However, d-russo@ti.com pointed out that Rhino was returning this: + * + * js> err = new Error() + * undefined: undefined + * + * js> err = new Error("msg") + * undefined: msg + * + * + * We expect Rhino to return what SpiderMonkey currently does: + * + * js> err = new Error() + * Error + * + * js> err = new Error("msg") + * Error: msg + * + * + * i.e. we expect err.toString() === err.name if err.message is not defined; + * otherwise, we expect err.toString() === err.name + ': ' + err.message. + * + * See also ECMA 15.11.4.2, 15.11.4.3 + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing Error.prototype.toString()'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +status = inSection(1); +var err1 = new Error('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new Error(err1); +actual = examineThis(err2, err1); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = new Error(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = new Error(EMPTY_STRING); +actual = examineThis(err4, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +// now generate a run-time error - +status = inSection(5); +try +{ + eval('1=2'); +} +catch(err5) +{ + actual = examineThis(err5, '.*'); +} +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Exceptions/15.11.5.js b/js/src/tests/ecma_3/Exceptions/15.11.5.js new file mode 100644 index 000000000..f61d74ecd --- /dev/null +++ b/js/src/tests/ecma_3/Exceptions/15.11.5.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 4 Oct 2010 + * SUMMARY: Error instances have no special properties beyond those inherited + * from the Error prototype object + */ +//----------------------------------------------------------------------------- +var summary = 'Error instances have no special properties beyond those inherited the Error prototype object'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printStatus (summary); + + var actual = { name: "no error", message: "no message" }; + try { + new Error.prototype; + } catch (e) { + actual = e; + } + + reportCompare("TypeError", actual.name, "must be a TypeError"); + reportCompare(true, /not a constructor/.test(actual.message), + "message must indicate not a constructor"); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Exceptions/15.11.7.6-001.js b/js/src/tests/ecma_3/Exceptions/15.11.7.6-001.js new file mode 100644 index 000000000..4c7dfb862 --- /dev/null +++ b/js/src/tests/ecma_3/Exceptions/15.11.7.6-001.js @@ -0,0 +1,96 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 14 April 2003 + * SUMMARY: Prototype of predefined error objects should be DontEnum + * See http://bugzilla.mozilla.org/show_bug.cgi?id=201989 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 201989; +var summary = 'Prototype of predefined error objects should be DontEnum'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Tests that |F.prototype| is not enumerable in |F| + */ +function testDontEnum(F) +{ + var proto = F.prototype; + + for (var prop in F) + { + if (F[prop] === proto) + return false; + } + return true; +} + + +var list = [ + "Error", + "ConversionError", + "EvalError", + "RangeError", + "ReferenceError", + "SyntaxError", + "TypeError", + "URIError" + ]; + + +for (i in list) +{ + var F = this[list[i]]; + + // Test for |F|; e.g. Rhino defines |ConversionError| while SM does not. + if (F) + { + status = 'Testing DontEnum attribute of |' + list[i] + '.prototype|'; + actual = testDontEnum(F); + expect = true; + addThis(); + } +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i -1); + expect = true; + addThis(); +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = isReferenceError(actual); + expectedvalues[UBound] = isReferenceError(expect); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +// converts a Boolean result into a textual result - +function isReferenceError(bResult) +{ + return bResult? ERR_REF_YES : ERR_REF_NO; +} diff --git a/js/src/tests/ecma_3/Exceptions/browser.js b/js/src/tests/ecma_3/Exceptions/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/Exceptions/regress-181654.js b/js/src/tests/ecma_3/Exceptions/regress-181654.js new file mode 100644 index 000000000..2dbbd0705 --- /dev/null +++ b/js/src/tests/ecma_3/Exceptions/regress-181654.js @@ -0,0 +1,121 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 23 Nov 2002 + * SUMMARY: Calling toString for an object derived from the Error class + * results in an TypeError (Rhino only) + * See http://bugzilla.mozilla.org/show_bug.cgi?id=181654 + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '181654'; +var summary = 'Calling toString for an object derived from the Error class should be possible.'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +// derive MyError from Error +function MyError( msg ) +{ + this.message = msg; +} +MyError.prototype = new Error(); +MyError.prototype.name = "MyError"; + + +status = inSection(1); +var err1 = new MyError('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new MyError(String(err1)); +actual = examineThis(err2, err1); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = new MyError(); +actual = examineThis(err3, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = new MyError(EMPTY_STRING); +actual = examineThis(err4, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +// now generate an error - +status = inSection(5); +try +{ + throw new MyError("thrown"); +} +catch(err5) +{ + actual = examineThis(err5, "thrown"); +} +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Searches err.toString() for err.name + ':' + err.message, + * with possible whitespace on each side of the colon sign. + * + * We allow for no colon in case err.message was not provided by the user. + * In such a case, SpiderMonkey and Rhino currently set err.message = '', + * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case. + * + * If this is ever changed to a non-empty string, e.g. 'undefined', + * you may have to modify |pattern| to take that into account - + * + */ +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Exceptions/regress-181914.js b/js/src/tests/ecma_3/Exceptions/regress-181914.js new file mode 100644 index 000000000..88934ee73 --- /dev/null +++ b/js/src/tests/ecma_3/Exceptions/regress-181914.js @@ -0,0 +1,160 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 25 Nov 2002 + * SUMMARY: Calling a user-defined superconstructor + * See http://bugzilla.mozilla.org/show_bug.cgi?id=181914, esp. Comment 10. + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = '181914'; +var summary = 'Calling a user-defined superconstructor'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var EMPTY_STRING = ''; +var EXPECTED_FORMAT = 0; + + +// make a user-defined version of the Error constructor +function _Error(msg) +{ + this.message = msg; +} +_Error.prototype = new Error(); +_Error.prototype.name = '_Error'; + + +// derive MyApplyError from _Error +function MyApplyError(msg) +{ + if(this instanceof MyApplyError) + _Error.apply(this, arguments); + else + return new MyApplyError(msg); +} +MyApplyError.prototype = new _Error(); +MyApplyError.prototype.name = "MyApplyError"; + + +// derive MyCallError from _Error +function MyCallError(msg) +{ + if(this instanceof MyCallError) + _Error.call(this, msg); + else + return new MyCallError(msg); +} +MyCallError.prototype = new _Error(); +MyCallError.prototype.name = "MyCallError"; + + +function otherScope(msg) +{ + return MyApplyError(msg); +} + + +status = inSection(1); +var err1 = new MyApplyError('msg1'); +actual = examineThis(err1, 'msg1'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(2); +var err2 = new MyCallError('msg2'); +actual = examineThis(err2, 'msg2'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(3); +var err3 = MyApplyError('msg3'); +actual = examineThis(err3, 'msg3'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(4); +var err4 = MyCallError('msg4'); +actual = examineThis(err4, 'msg4'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(5); +var err5 = otherScope('msg5'); +actual = examineThis(err5, 'msg5'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(6); +var err6 = otherScope(); +actual = examineThis(err6, EMPTY_STRING); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(7); +var err7 = eval("MyApplyError('msg7')"); +actual = examineThis(err7, 'msg7'); +expect = EXPECTED_FORMAT; +addThis(); + +status = inSection(8); +var err8; +try +{ + throw MyApplyError('msg8'); +} +catch(e) +{ + if(e instanceof Error) + err8 = e; +} +actual = examineThis(err8, 'msg8'); +expect = EXPECTED_FORMAT; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +// Searches |err.toString()| for |err.name + ':' + err.message| +function examineThis(err, msg) +{ + var pattern = err.name + '\\s*:?\\s*' + msg; + return err.toString().search(RegExp(pattern)); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Exceptions/regress-58946.js b/js/src/tests/ecma_3/Exceptions/regress-58946.js new file mode 100644 index 000000000..e24ccc77e --- /dev/null +++ b/js/src/tests/ecma_3/Exceptions/regress-58946.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//------------------------------------------------------------------------------------------------- +var BUGNUMBER = '58946'; +var stat = 'Testing a return statement inside a catch statement inside a function'; + +test(); + +function test() { + enterFunc ("test"); + printBugNumber(BUGNUMBER); + printStatus (stat); + + expect = 'PASS'; + + function f() + { + try + { + throw 'PASS'; + } + catch(e) + { + return e; + } + } + + actual = f(); + + reportCompare(expect, actual, stat); + + exitFunc ("test"); +} diff --git a/js/src/tests/ecma_3/Exceptions/regress-95101.js b/js/src/tests/ecma_3/Exceptions/regress-95101.js new file mode 100644 index 000000000..5585ae04f --- /dev/null +++ b/js/src/tests/ecma_3/Exceptions/regress-95101.js @@ -0,0 +1,84 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 13 August 2001 + * + * SUMMARY: Invoking an undefined function should produce a ReferenceError + * See http://bugzilla.mozilla.org/show_bug.cgi?id=95101 + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 95101; +var summary = 'Invoking an undefined function should produce a ReferenceError'; +var msgERR_REF_YES = 'ReferenceError'; +var msgERR_REF_NO = 'did NOT generate a ReferenceError'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +try +{ + xxxyyyzzz(); +} +catch (e) +{ + status = 'Section 1 of test'; + actual = e instanceof ReferenceError; + expect = true; + addThis(); + + + /* + * This test is more literal, and may one day be invalid. + * Searching for literal string "ReferenceError" in e.toString() + */ + status = 'Section 2 of test'; + var match = e.toString().search(/ReferenceError/); + actual = (match > -1); + expect = true; + addThis(); +} + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = isReferenceError(actual); + expectedvalues[UBound] = isReferenceError(expect); + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} + + +// converts a Boolean result into a textual result - +function isReferenceError(bResult) +{ + return bResult? msgERR_REF_YES : msgERR_REF_NO; +} diff --git a/js/src/tests/ecma_3/Exceptions/shell.js b/js/src/tests/ecma_3/Exceptions/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js b/js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js new file mode 100644 index 000000000..eb29e55e5 --- /dev/null +++ b/js/src/tests/ecma_3/ExecutionContexts/10.1.3-1.js @@ -0,0 +1,167 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 11 Feb 2002 + * SUMMARY: Testing functions having duplicate formal parameter names + * + * Note: given function f(x,x,x,x) {return x;}; f(1,2,3,4) should return 4. + * See ECMA-262 3rd Edition Final Section 10.1.3: Variable Instantiation + * + * Also see http://bugzilla.mozilla.org/show_bug.cgi?id=124900 + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 124900; +var summary = 'Testing functions having duplicate formal parameter names'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +function f1(x,x) +{ + return x; +} +status = inSection(1); +actual = f1(1,2); +expect = 2; +addThis(); + + +function f2(x,x,x) +{ + return x*x*x; +} +status = inSection(2); +actual = f2(1,2,3); +expect = 27; +addThis(); + + +function f3(x,x,x,x) +{ + return 'a' + x + 'b' + x + 'c' + x ; +} +status = inSection(3); +actual = f3(1,2,3,4); +expect = 'a4b4c4'; +addThis(); + + +/* + * If the value of the last duplicate parameter is not provided by + * the function caller, the value of this parameter is undefined + */ +function f4(x,a,b,x,z) +{ + return x; +} +status = inSection(4); +actual = f4(1,2); +expect = undefined; +addThis(); + + +/* + * f.toString() should preserve any duplicate formal parameter names that exist + */ +function f5(x,x,x,x) +{ +} +status = inSection(5); +actual = f5.toString().match(/\((.*)\)/)[1]; +actual = actual.replace(/\s/g, ''); // for definiteness, remove any white space +expect = 'x,x,x,x'; +addThis(); + + +function f6(x,x,x,x) +{ + var ret = []; + + for (var i=0; i> p); + + reportCompare(expectval, actualval, summary + ': value'); + reportCompare(expect, actual, summary + ': order'); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Expressions/11.7.3-01.js b/js/src/tests/ecma_3/Expressions/11.7.3-01.js new file mode 100644 index 000000000..75227e242 --- /dev/null +++ b/js/src/tests/ecma_3/Expressions/11.7.3-01.js @@ -0,0 +1,43 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 396969; +var summary = '11.7.3 - >>> should evaluate operands in order'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'o.valueOf, p.valueOf'; + var actualval; + var expectval = 10; + + var o = { + valueOf: (function (){ actual += 'o.valueOf'; return this.value}), + value:42 + }; + + var p = { + valueOf: (function (){ actual += ', p.valueOf'; return this.value}), + value:2 + }; + + actualval = (o >>> p); + + reportCompare(expectval, actualval, summary + ': value'); + reportCompare(expect, actual, summary + ': order'); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Expressions/11.9.6-1.js b/js/src/tests/ecma_3/Expressions/11.9.6-1.js new file mode 100644 index 000000000..ccf9e7b64 --- /dev/null +++ b/js/src/tests/ecma_3/Expressions/11.9.6-1.js @@ -0,0 +1,179 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 20 Feb 2002 + * SUMMARY: Testing the comparison |undefined === null| + * See http://bugzilla.mozilla.org/show_bug.cgi?id=126722 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 126722; +var summary = 'Testing the comparison |undefined === null|'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +status = inSection(1); +if (undefined === null) + actual = true; +else + actual = false; +expect = false; +addThis(); + + + +status = inSection(2); +switch(true) +{ +case (undefined === null) : + actual = true; + break; + +default: + actual = false; +} +expect = false; +addThis(); + + + +status = inSection(3); +function f3(x) +{ + var res = false; + + switch(true) + { + case (x === null) : + res = true; + break; + + default: + // do nothing + } + + return res; +} + +actual = f3(undefined); +expect = false; +addThis(); + + + +status = inSection(4); +function f4(arr) +{ + var elt = ''; + var res = false; + + for (i=0; i function f\u02B1 () {} + * + * js> f\u02B1.toSource(); + * function f¦() {} + * + * js> f\u02B1.toSource().toSource(); + * (new String("function f\xB1() {}")) + * + * + * See how the high-byte information (the 02) has been lost? + * The same thing was happening with the toString() method: + * + * js> f\u02B1.toString(); + * + * function f¦() { + * } + * + * js> f\u02B1.toString().toSource(); + * (new String("\nfunction f\xB1() {\n}\n")) + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 58274; +var summary = 'Testing functions with double-byte names'; +var ERR = 'UNEXPECTED ERROR! \n'; +var ERR_MALFORMED_NAME = ERR + 'Could not find function name in: \n\n'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; +var sEval; +var sName; + + +sEval = "function f\u02B2() {return 42;}"; +eval(sEval); +sName = getFunctionName(f\u02B2); + +// Test function call - +status = inSection(1); +actual = f\u02B2(); +expect = 42; +addThis(); + +// Test both characters of function name - +status = inSection(2); +actual = sName[0]; +expect = sEval[9]; +addThis(); + +status = inSection(3); +actual = sName[1]; +expect = sEval[10]; +addThis(); + + + +sEval = "function f\u02B2\u0AAA () {return 84;}"; +eval(sEval); +sName = getFunctionName(f\u02B2\u0AAA); + +// Test function call - +status = inSection(4); +actual = f\u02B2\u0AAA(); +expect = 84; +addThis(); + +// Test all three characters of function name - +status = inSection(5); +actual = sName[0]; +expect = sEval[9]; +addThis(); + +status = inSection(6); +actual = sName[1]; +expect = sEval[10]; +addThis(); + +status = inSection(7); +actual = sName[2]; +expect = sEval[11]; +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Goal: test that f.toString() contains the proper function name. + * + * Note, however, f.toString() is implementation-independent. For example, + * it may begin with '\nfunction' instead of 'function'. Therefore we use + * a regexp to make sure we extract the name properly. + * + * Here we assume that f has been defined by means of a function statement, + * and not a function expression (where it wouldn't have to have a name). + * + * Rhino uses a Unicode representation for f.toString(); whereas + * SpiderMonkey uses an ASCII representation, putting escape sequences + * for non-ASCII characters. For example, if a function is called f\u02B1, + * then in Rhino the toString() method will present a 2-character Unicode + * string for its name, whereas SpiderMonkey will present a 7-character + * ASCII string for its name: the string literal 'f\u02B1'. + * + * So we force the lexer to condense the string before using it. + * This will give uniform results in Rhino and SpiderMonkey. + */ +function getFunctionName(f) +{ + var s = condenseStr(f.toString()); + var re = /\s*function\s+(\S+)\s*\(/; + var arr = s.match(re); + + if (!(arr && arr[1])) + return ERR_MALFORMED_NAME + s; + return arr[1]; +} + + +/* + * This function is the opposite of functions like escape(), which take + * Unicode characters and return escape sequences for them. Here, we force + * the lexer to turn escape sequences back into single characters. + * + * Note we can't simply do |eval(str)|, since in practice |str| will be an + * identifier somewhere in the program (e.g. a function name); thus |eval(str)| + * would return the object that the identifier represents: not what we want. + * + * So we surround |str| lexicographically with quotes to force the lexer to + * evaluate it as a string. Have to strip out any linefeeds first, however - + */ +function condenseStr(str) +{ + /* + * You won't be able to do the next step if |str| has + * any carriage returns or linefeeds in it. For example: + * + * js> eval("'" + '\nHello' + "'"); + * 1: SyntaxError: unterminated string literal: + * 1: ' + * 1: ^ + * + * So replace them with the empty string - + */ + str = str.replace(/[\r\n]/g, '') + return eval("'" + str + "'"); +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i>'}, + {section: '11.7.3', operator: '>>>'}, + {section: '11.8.1', operator: '<'}, + {section: '11.8.2', operator: '>'}, + {section: '11.8.3', operator: '<='}, + {section: '11.8.4', operator: '>='}, + {section: '11.10', operator: '&'}, + {section: '11.10', operator: '^'}, + {section: '11.10', operator: '|'}, + {section: '11.13.2', operator: '*='}, + {section: '11.13.2', operator: '/='}, + {section: '11.13.2', operator: '%='}, + {section: '11.13.2', operator: '+='}, + {section: '11.13.2', operator: '<<='}, + {section: '11.13.2', operator: '>>='}, + {section: '11.13.2', operator: '>>>='}, + {section: '11.13.2', operator: '&='}, + {section: '11.13.2', operator: '^='}, + {section: '11.13.2', operator: '|='}, + ]; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var i = 0; i < operators.length; i++) + { + expect = 'left valueOf, left toString, right valueOf, right toString, '; + actual = ''; + + var left = makeObject('left'); + var right = makeObject('right'); + + eval('left ' + operators[i].operator + ' right'); + + reportCompare(expect, actual, summary + ': ' + operators[i].section + ' ' + operators[i].operator); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Operators/shell.js b/js/src/tests/ecma_3/Operators/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/README b/js/src/tests/ecma_3/README new file mode 100644 index 000000000..eebd421c2 --- /dev/null +++ b/js/src/tests/ecma_3/README @@ -0,0 +1 @@ +ECMA 262 Edition 3 diff --git a/js/src/tests/ecma_3/RegExp/15.10.2-1.js b/js/src/tests/ecma_3/RegExp/15.10.2-1.js new file mode 100644 index 000000000..c2f414539 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.2-1.js @@ -0,0 +1,147 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 09 July 2002 + * SUMMARY: RegExp conformance test + * + * These testcases are derived from the examples in the ECMA-262 Ed.3 spec + * scattered through section 15.10.2. + * + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = '(none)'; +var summary = 'RegExp conformance test'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /a|ab/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(2); +pattern = /((a)|(ab))((c)|(bc))/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'a', 'a', undefined, 'bc', undefined, 'bc'); +addThis(); + +status = inSection(3); +pattern = /a[a-z]{2,4}/; +string = 'abcdefghi'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcde'); +addThis(); + +status = inSection(4); +pattern = /a[a-z]{2,4}?/; +string = 'abcdefghi'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(5); +pattern = /(aa|aabaac|ba|b|c)*/; +string = 'aabaac'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaba', 'ba'); +addThis(); + +status = inSection(6); +pattern = /^(a+)\1*,\1+$/; +string = 'aaaaaaaaaa,aaaaaaaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaaaa,aaaaaaaaaaaaaaa', 'aaaaa'); +addThis(); + +status = inSection(7); +pattern = /(z)((a+)?(b+)?(c))*/; +string = 'zaacbbbcac'; +actualmatch = string.match(pattern); +expectedmatch = Array('zaacbbbcac', 'z', 'ac', 'a', undefined, 'c'); +addThis(); + +status = inSection(8); +pattern = /(a*)*/; +string = 'b'; +actualmatch = string.match(pattern); +expectedmatch = Array('', undefined); +addThis(); + +status = inSection(9); +pattern = /(a*)b\1+/; +string = 'baaaac'; +actualmatch = string.match(pattern); +expectedmatch = Array('b', ''); +addThis(); + +status = inSection(10); +pattern = /(?=(a+))/; +string = 'baaabac'; +actualmatch = string.match(pattern); +expectedmatch = Array('', 'aaa'); +addThis(); + +status = inSection(11); +pattern = /(?=(a+))a*b\1/; +string = 'baaabac'; +actualmatch = string.match(pattern); +expectedmatch = Array('aba', 'a'); +addThis(); + +status = inSection(12); +pattern = /(.*?)a(?!(a+)b\2c)\2(.*)/; +string = 'baaabaac'; +actualmatch = string.match(pattern); +expectedmatch = Array('baaabaac', 'ba', undefined, 'abaac'); +addThis(); + +status = inSection(13); +pattern = /(?=(a+))/; +string = 'baaabac'; +actualmatch = string.match(pattern); +expectedmatch = Array('', 'aaa'); +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.2.12.js b/js/src/tests/ecma_3/RegExp/15.10.2.12.js new file mode 100644 index 000000000..c2adfdfb9 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.2.12.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 378738; +var summary = '15.10.2.12 - CharacterClassEscape \d'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = false; + actual = /\d/.test("\uFF11"); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.3.1-1.js b/js/src/tests/ecma_3/RegExp/15.10.3.1-1.js new file mode 100644 index 000000000..74ff25e4c --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.3.1-1.js @@ -0,0 +1,102 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 26 November 2000 + * + * + * SUMMARY: Passing (RegExp object, flag) to RegExp() function. + * This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.3 The RegExp Constructor Called as a Function + * + * 15.10.3.1 RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" + * and flags is undefined, then return R unchanged. Otherwise + * call the RegExp constructor (section 15.10.4.1), passing it the + * pattern and flags arguments and return the object constructed + * by that constructor. + * + * + * The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * The flags parameter will be undefined in the sense of not being + * provided. We check that RegExp(R) returns R - + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = '61266'; +var summary = 'Passing (RegExp object,flag) to RegExp() function'; +var statprefix = 'RegExp(new RegExp('; +var comma = ', '; var singlequote = "'"; var closeparens = '))'; +var cnSUCCESS = 'RegExp() returned the supplied RegExp object'; +var cnFAILURE = 'RegExp() did NOT return the supplied RegExp object'; +var i = -1; var j = -1; var s = ''; var f = ''; +var obj = {}; +var status = ''; var actual = ''; var expect = ''; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; +flags[3] = undefined; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + obj = new RegExp(s, f); + + actual = (obj == RegExp(obj))? cnSUCCESS : cnFAILURE; + expect = cnSUCCESS; + reportCompare (expect, actual, status); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + comma + flag + closeparens); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.3.1-2.js b/js/src/tests/ecma_3/RegExp/15.10.3.1-2.js new file mode 100644 index 000000000..777bb43d4 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.3.1-2.js @@ -0,0 +1,110 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 26 November 2000 + * + * + * SUMMARY: Passing (RegExp object, flag) to RegExp() function. + * This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.3 The RegExp Constructor Called as a Function + * + * 15.10.3.1 RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" + * and flags is undefined, then return R unchanged. Otherwise + * call the RegExp constructor (section 15.10.4.1), passing it the + * pattern and flags arguments and return the object constructed + * by that constructor. + * + * + * The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * This test is identical to test 15.10.3.1-1.js, except here we do: + * + * RegExp(R, undefined); + * + * instead of: + * + * RegExp(R); + * + * + * We check that RegExp(R, undefined) returns R - + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = '61266'; +var summary = 'Passing (RegExp object,flag) to RegExp() function'; +var statprefix = 'RegExp(new RegExp('; +var comma = ', '; var singlequote = "'"; var closeparens = '))'; +var cnSUCCESS = 'RegExp() returned the supplied RegExp object'; +var cnFAILURE = 'RegExp() did NOT return the supplied RegExp object'; +var i = -1; var j = -1; var s = ''; var f = ''; +var obj = {}; +var status = ''; var actual = ''; var expect = ''; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; +flags[3] = undefined; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + obj = new RegExp(s, f); + + actual = (obj == RegExp(obj, undefined))? cnSUCCESS : cnFAILURE ; + expect = cnSUCCESS; + reportCompare (expect, actual, status); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + comma + flag + closeparens); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.4.1-1.js b/js/src/tests/ecma_3/RegExp/15.10.4.1-1.js new file mode 100644 index 000000000..6a3ff20a7 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.4.1-1.js @@ -0,0 +1,93 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * We check that a new RegExp object obj2 defined from these parameters + * is morally the same as the original RegExp object obj1. Of course, they + * can't be equal as objects - so we check their enumerable properties... + * + * In this test, the initial RegExp object obj1 will not include a + * flag. The flags parameter for obj2 will be undefined in the sense + * of not being provided. + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = '61266'; +var summary = 'Passing a RegExp object to a RegExp() constructor'; +var statprefix = 'Applying RegExp() twice to pattern '; +var statsuffix = '; testing property '; +var singlequote = "'"; +var i = -1; var s = ''; +var obj1 = {}; var obj2 = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var patterns = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + status =getStatus(s); + obj1 = new RegExp(s); + obj2 = new RegExp(obj1); + + reportCompare (obj1 + '', obj2 + '', status); + } + + exitFunc ('test'); +} + + +function getStatus(regexp) +{ + return (statprefix + quote(regexp) + statsuffix); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.4.1-2.js b/js/src/tests/ecma_3/RegExp/15.10.4.1-2.js new file mode 100644 index 000000000..71fe58d19 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.4.1-2.js @@ -0,0 +1,99 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * We check that a new RegExp object obj2 defined from these parameters + * is morally the same as the original RegExp object obj1. Of course, they + * can't be equal as objects - so we check their enumerable properties... + * + * In this test, the initial RegExp object obj1 will not include a + * flag. This test is identical to test 15.10.4.1-1.js, except that + * here we use this syntax: + * + * obj2 = new RegExp(obj1, undefined); + * + * instead of: + * + * obj2 = new RegExp(obj1); + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = '61266'; +var summary = 'Passing a RegExp object to a RegExp() constructor'; +var statprefix = 'Applying RegExp() twice to pattern '; +var statsuffix = '; testing property '; +var singlequote = "'"; +var i = -1; var s = ''; +var obj1 = {}; var obj2 = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var patterns = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + status =getStatus(s); + obj1 = new RegExp(s); + obj2 = new RegExp(obj1, undefined); // see introduction to bug + + reportCompare (obj1 + '', obj2 + '', status); + } + + exitFunc ('test'); +} + + +function getStatus(regexp) +{ + return (statprefix + quote(regexp) + statsuffix); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.4.1-3.js b/js/src/tests/ecma_3/RegExp/15.10.4.1-3.js new file mode 100644 index 000000000..15959ef5e --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.4.1-3.js @@ -0,0 +1,105 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * We check that a new RegExp object obj2 defined from these parameters + * is morally the same as the original RegExp object obj1. Of course, they + * can't be equal as objects - so we check their enumerable properties... + * + * In this test, the initial RegExp obj1 will include a flag. The flags + * parameter for obj2 will be undefined in the sense of not being provided. + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = '61266'; +var summary = 'Passing a RegExp object to a RegExp() constructor'; +var statprefix = 'Applying RegExp() twice to pattern '; +var statmiddle = ' and flag '; +var statsuffix = '; testing property '; +var singlequote = "'"; +var i = -1; var j = -1; var s = ''; +var obj1 = {}; var obj2 = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; +flags[3] = undefined; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + obj1 = new RegExp(s, f); + obj2 = new RegExp(obj1); + + reportCompare (obj1 + '', obj2 + '', status); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + statmiddle + flag + statsuffix); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.4.1-4.js b/js/src/tests/ecma_3/RegExp/15.10.4.1-4.js new file mode 100644 index 000000000..455e1d248 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.4.1-4.js @@ -0,0 +1,112 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 26 November 2000 + * + * + *SUMMARY: Passing a RegExp object to a RegExp() constructor. + *This test arose from Bugzilla bug 61266. The ECMA3 section is: + * + * 15.10.4.1 new RegExp(pattern, flags) + * + * If pattern is an object R whose [[Class]] property is "RegExp" and + * flags is undefined, then let P be the pattern used to construct R + * and let F be the flags used to construct R. If pattern is an object R + * whose [[Class]] property is "RegExp" and flags is not undefined, + * then throw a TypeError exception. Otherwise, let P be the empty string + * if pattern is undefined and ToString(pattern) otherwise, and let F be + * the empty string if flags is undefined and ToString(flags) otherwise. + * + * + *The current test will check the first scenario outlined above: + * + * "pattern" is itself a RegExp object R + * "flags" is undefined + * + * We check that a new RegExp object obj2 defined from these parameters + * is morally the same as the original RegExp object obj1. Of course, they + * can't be equal as objects - so we check their enumerable properties... + * + * In this test, the initial RegExp object obj1 will include a + * flag. This test is identical to test 15.10.4.1-3.js, except that + * here we use this syntax: + * + * obj2 = new RegExp(obj1, undefined); + * + * instead of: + * + * obj2 = new RegExp(obj1); + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = '61266'; +var summary = 'Passing a RegExp object to a RegExp() constructor'; +var statprefix = 'Applying RegExp() twice to pattern '; +var statmiddle = ' and flag '; +var statsuffix = '; testing property '; +var singlequote = "'"; +var i = -1; var j = -1; var s = ''; +var obj1 = {}; var obj2 = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var patterns = new Array(); +var flags = new Array(); + + +// various regular expressions to try - +patterns[0] = ''; +patterns[1] = 'abc'; +patterns[2] = '(.*)(3-1)\s\w'; +patterns[3] = '(.*)(...)\\s\\w'; +patterns[4] = '[^A-Za-z0-9_]'; +patterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// various flags to try - +flags[0] = 'i'; +flags[1] = 'g'; +flags[2] = 'm'; +flags[3] = undefined; + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + obj1 = new RegExp(s, f); + obj2 = new RegExp(obj1, undefined); // see introduction to bug + + reportCompare (obj1 + '', obj2 + '', status); + } + } + + exitFunc ('test'); +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + statmiddle + flag + statsuffix); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.4.1-6.js b/js/src/tests/ecma_3/RegExp/15.10.4.1-6.js new file mode 100644 index 000000000..104e83ee6 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.4.1-6.js @@ -0,0 +1,62 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + 15.10.4.1 new RegExp(pattern, flags) + + If F contains any character other than "g", "i", or" m", or if it + contains the same one more than once, then throw a SyntaxError + exception. +*/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 476940; +var summary = 'Section 15.10.4.1 - RegExp with invalid flags'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var invalidflags = ['ii', 'gg', 'mm', 'a']; + + for (var i = 0; i < invalidflags.length; i++) + { + var flag = invalidflags[i]; + expect = 'SyntaxError: invalid regular expression flag ' + flag.charAt(0); + actual = ''; + try + { + new RegExp('bar', flag); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + + ': new RegExp("bar", "' + flag + '")'); + + actual = ''; + try + { + eval("/bar/" + flag); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': /bar/' + flag + ')'); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.6.2-1.js b/js/src/tests/ecma_3/RegExp/15.10.6.2-1.js new file mode 100644 index 000000000..9717ba217 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.6.2-1.js @@ -0,0 +1,106 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 23 October 2001 + * + * SUMMARY: Testing regexps with the global flag set. + * NOT every substring fitting the given pattern will be matched. + * The parent string is CONSUMED as successive matches are found. + * + * From the ECMA-262 Final spec: + * + * 15.10.6.2 RegExp.prototype.exec(string) + * Performs a regular expression match of string against the regular + * expression and returns an Array object containing the results of + * the match, or null if the string did not match. + * + * The string ToString(string) is searched for an occurrence of the + * regular expression pattern as follows: + * + * 1. Let S be the value of ToString(string). + * 2. Let length be the length of S. + * 3. Let lastIndex be the value of the lastIndex property. + * 4. Let i be the value of ToInteger(lastIndex). + * 5. If the global property is false, let i = 0. + * 6. If i < 0 or i > length then set lastIndex to 0 and return null. + * 7. Call [[Match]], giving it the arguments S and i. + * If [[Match]] returned failure, go to step 8; + * otherwise let r be its State result and go to step 10. + * 8. Let i = i+1. + * 9. Go to step 6. + * 10. Let e be r's endIndex value. + * 11. If the global property is true, set lastIndex to e. + * + * etc. + * + * + * So when the global flag is set, |lastIndex| is incremented every time + * there is a match; not from i to i+1, but from i to "endIndex" e: + * + * e = (index of last input character matched so far by the pattern) + 1 + * + * Thus in the example below, the first endIndex e occurs after the + * first match 'a b'. The next match will begin AFTER this, and so + * will NOT be 'b c', but rather 'c d'. Similarly, 'd e' won't be matched. + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing regexps with the global flag set'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +string = 'a b c d e'; +pattern = /\w\s\w/g; +actualmatch = string.match(pattern); +expectedmatch = ['a b','c d']; // see above explanation - +addThis(); + + +status = inSection(2); +string = '12345678'; +pattern = /\d\d\d/g; +actualmatch = string.match(pattern); +expectedmatch = ['123','456']; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/15.10.6.2-2.js b/js/src/tests/ecma_3/RegExp/15.10.6.2-2.js new file mode 100644 index 000000000..eb544cb35 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/15.10.6.2-2.js @@ -0,0 +1,294 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 18 Feb 2002 + * SUMMARY: Testing re.exec(str) when re.lastIndex is < 0 or > str.length + * + * Case 1: If re has the global flag set, then re(str) should be null + * Case 2: If re doesn't have this set, then re(str) should be unaffected + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=76717 + * + * + * From the ECMA-262 Final spec: + * + * 15.10.6.2 RegExp.prototype.exec(string) + * Performs a regular expression match of string against the regular + * expression and returns an Array object containing the results of + * the match, or null if the string did not match. + * + * The string ToString(string) is searched for an occurrence of the + * regular expression pattern as follows: + * + * 1. Let S be the value of ToString(string). + * 2. Let length be the length of S. + * 3. Let lastIndex be the value of the lastIndex property. + * 4. Let i be the value of ToInteger(lastIndex). + * 5. If the global property is false, let i = 0. + * 6. If i < 0 or i > length then set lastIndex to 0 and return null. + * 7. Call [[Match]], giving it the arguments S and i. + * If [[Match]] returned failure, go to step 8; + * otherwise let r be its State result and go to step 10. + * 8. Let i = i+1. + * 9. Go to step 6. + * 10. Let e be r's endIndex value. + * 11. If the global property is true, set lastIndex to e. + * + * etc. + * + * + * So: + * + * A. If the global flag is not set, |lastIndex| is set to 0 + * before the match is attempted; thus the match is unaffected. + * + * B. If the global flag IS set and re.lastIndex is >= 0 and <= str.length, + * |lastIndex| is incremented every time there is a match; not from + * i to i+1, but from i to "endIndex" e: + * + * e = (index of last input character matched so far by the pattern) + 1 + * + * The match is then attempted from this position in the string (Step 7). + * + * C. When the global flag IS set and re.lastIndex is < 0 or > str.length, + * |lastIndex| is set to 0 and the match returns null. + * + * + * Note the |lastIndex| property is writeable, and may be set arbitrarily + * by the programmer - and we will do that below. + * + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 76717; +var summary = 'Testing re.exec(str) when re.lastIndex is < 0 or > str.length'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/****************************************************************************** + * + * Case 1 : when the global flag is set - + * + *****************************************************************************/ +pattern = /abc/gi; +string = 'AbcaBcabC'; + +status = inSection(1); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc'); +addThis(); + +status = inSection(2); +actualmatch = pattern.exec(string); +expectedmatch = Array('aBc'); +addThis(); + +status = inSection(3); +actualmatch = pattern.exec(string); +expectedmatch = Array('abC'); +addThis(); + +/* + * At this point |lastIndex| is > string.length, so the match should be null - + */ +status = inSection(4); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +/* + * Now try some edge-case values. Thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, |lastIndex| + * is now stored as a double instead of a uint32_t (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + */ +status = inSection(6); +pattern.lastIndex = Math.pow(2,32); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(8); +pattern.lastIndex = Math.pow(2,32) + 1; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(10); +pattern.lastIndex = Math.pow(2,32) * 2; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(12); +pattern.lastIndex = Math.pow(2,40); +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + +status = inSection(14); +pattern.lastIndex = Number.MAX_VALUE; +actualmatch = pattern.exec(string); +expectedmatch = null; +addThis(); + + + +/****************************************************************************** + * + * Case 2: repeat all the above cases WITHOUT the global flag set. + * According to EMCA. |lastIndex| should get set to 0 before the match. + * + * Therefore re.exec(str) should be unaffected; thus our expected values + * below are now DIFFERENT when |lastIndex| is < 0 or > str.length + * + *****************************************************************************/ + +pattern = /abc/i; +string = 'AbcaBcabC'; + +status = inSection(16); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc'); +addThis(); + +status = inSection(17); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc'); // NOT Array('aBc') as before - +addThis(); + +status = inSection(18); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc'); // NOT Array('abC') as before - +addThis(); + +/* + * At this point above, |lastIndex| WAS > string.length, but not here - + */ +status = inSection(19); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +/* + * Now let's set |lastIndex| to -1 + */ +status = inSection(20); +pattern.lastIndex = -1; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +/* + * Now try some edge-case values. Thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, |lastIndex| + * is now stored as a double instead of a uint32_t (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + */ +status = inSection(21); +pattern.lastIndex = Math.pow(2,32); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(22); +pattern.lastIndex = -Math.pow(2,32); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(23); +pattern.lastIndex = Math.pow(2,32) + 1; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(24); +pattern.lastIndex = -(Math.pow(2,32) + 1); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(25); +pattern.lastIndex = Math.pow(2,32) * 2; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(26); +pattern.lastIndex = -Math.pow(2,32) * 2; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(27); +pattern.lastIndex = Math.pow(2,40); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before -; + addThis(); + +status = inSection(28); +pattern.lastIndex = -Math.pow(2,40); +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(29); +pattern.lastIndex = Number.MAX_VALUE; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + +status = inSection(30); +pattern.lastIndex = -Number.MAX_VALUE; +actualmatch = pattern.exec(string); +expectedmatch = Array('Abc') // NOT null as before - + addThis(); + + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/browser.js b/js/src/tests/ecma_3/RegExp/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/RegExp/octal-001.js b/js/src/tests/ecma_3/RegExp/octal-001.js new file mode 100644 index 000000000..449384b4b --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/octal-001.js @@ -0,0 +1,102 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 18 July 2002 + * SUMMARY: Testing octal sequences in regexps + * See http://bugzilla.mozilla.org/show_bug.cgi?id=141078 + * + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 141078; +var summary = 'Testing octal sequences in regexps'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /\240/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* + * In the following sections, we test the octal escape sequence '\052'. + * This is character code 42, representing the asterisk character '*'. + * The Unicode escape for it would be '\u002A', the hex escape '\x2A'. + */ +status = inSection(2); +pattern = /ab\052c/; +string = 'ab*c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab*c'); +addThis(); + +status = inSection(3); +pattern = /ab\052*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(4); +pattern = /ab(\052)+c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab****c', '*'); +addThis(); + +status = inSection(5); +pattern = /ab((\052)+)c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab****c', '****', '*'); +addThis(); + +status = inSection(6); +pattern = /(?:\052)c/; +string = 'ab****c'; +actualmatch = string.match(pattern); +expectedmatch = Array('*c'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/octal-002.js b/js/src/tests/ecma_3/RegExp/octal-002.js new file mode 100644 index 000000000..947031a94 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/octal-002.js @@ -0,0 +1,184 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 31 July 2002 + * SUMMARY: Testing regexps containing octal escape sequences + * This is an elaboration of mozilla/js/tests/ecma_2/RegExp/octal-003.js + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=141078 + * for a reference on octal escape sequences in regexps. + * + * NOTE: + * We will use the identities '\011' === '\u0009' === '\x09' === '\t' + * + * The first is an octal escape sequence (\(0-3)OO; O an octal digit). + * See ECMA-262 Edition 2, Section 7.7.4 "String Literals". These were + * dropped in Edition 3 but we support them for backward compatibility. + * + * The second is a Unicode escape sequence (\uHHHH; H a hex digit). + * Since octal 11 = hex 9, the two escapes define the same character. + * + * The third is a hex escape sequence (\xHH; H a hex digit). + * Since hex 09 = hex 0009, this defines the same character. + * + * The fourth is the familiar escape sequence for a horizontal tab, + * defined in the ECMA spec as having Unicode value \u0009. + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 141078; +var summary = 'Testing regexps containing octal escape sequences'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * Test a string containing the null character '\0' followed by the string '11' + * + * 'a' + String.fromCharCode(0) + '11'; + * + * Note we can't simply write 'a\011', because '\011' would be interpreted + * as the octal escape sequence for the tab character (see above). + * + * We should get no match from the regexp /.\011/, because it should be + * looking for the octal escape sequence \011, i.e. the tab character - + * + */ +status = inSection(1); +pattern = /.\011/; +string = 'a' + String.fromCharCode(0) + '11'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +/* + * Try same thing with 'xx' in place of '11'. + * + * Should get a match now, because the octal escape sequence in the regexp + * has been reduced from \011 to \0, and '\0' is present in the string - + */ +status = inSection(2); +pattern = /.\0xx/; +string = 'a' + String.fromCharCode(0) + 'xx'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same thing; don't use |String.fromCharCode(0)| this time. + * There is no ambiguity in '\0xx': it is the null character + * followed by two x's, no other interpretation is possible. + */ +status = inSection(3); +pattern = /.\0xx/; +string = 'a\0xx'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * This one should produce a match. The two-character string + * 'a' + '\011' is duplicated in the pattern and test string: + */ +status = inSection(4); +pattern = /.\011/; +string = 'a\011'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now, for the second character of the string, + * use the Unicode escape '\u0009' instead of the octal escape '\011' + */ +status = inSection(5); +pattern = /.\011/; +string = 'a\u0009'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now for the second character of the string, + * use the hex escape '\x09' instead of the octal escape '\011' + */ +status = inSection(6); +pattern = /.\011/; +string = 'a\x09'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Same as above, only now for the second character of the string, + * use the escape '\t' instead of the octal escape '\011' + */ +status = inSection(7); +pattern = /.\011/; +string = 'a\t'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Return to the string from Section 1. + * + * Unlike Section 1, use the RegExp() function to create the + * regexp pattern: null character followed by the string '11'. + * + * Since this is exactly what the string is, we should get a match - + */ +status = inSection(8); +string = 'a' + String.fromCharCode(0) + '11'; +pattern = RegExp(string); +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/perlstress-001.js b/js/src/tests/ecma_3/RegExp/perlstress-001.js new file mode 100644 index 000000000..ba23360da --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/perlstress-001.js @@ -0,0 +1,3196 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 2002-07-07 + * SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine. + * Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested. + * + * This test was created by running various patterns and strings through the + * Perl 5 RegExp engine. We saved the results below to test the JS engine. + * + * NOTE: ECMA/JS and Perl do differ on certain points. We have either commented + * out such sections altogether, or modified them to fit what we expect from JS. + * + * EXAMPLES: + * + * - In JS, regexp captures (/(a) etc./) must hold |undefined| if not used. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=123437. + * By contrast, in Perl, unmatched captures hold the empty string. + * We have modified such sections accordingly. Example: + + pattern = /^([^a-z])|(\^)$/; + string = '.'; + actualmatch = string.match(pattern); + //expectedmatch = Array('.', '.', ''); <<<--- Perl + expectedmatch = Array('.', '.', undefined); <<<--- JS + addThis(); + + + * - In JS, you can't refer to a capture before it's encountered & completed + * + * - Perl supports ] & ^] inside a [], ECMA does not + * + * - ECMA does support (?: (?= and (?! operators, but doesn't support (?< etc. + * + * - ECMA doesn't support (?imsx or (?-imsx + * + * - ECMA doesn't support (?(condition) + * + * - Perl has \Z has end-of-line, ECMA doesn't + * + * - In ECMA, ^ matches only the empty string before the first character + * + * - In ECMA, $ matches only the empty string at end of input (unless multiline) + * + * - ECMA spec says that each atom in a range must be a single character + * + * - ECMA doesn't support \A + * + * - ECMA doesn't have rules for [: + * + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 85721; +var summary = 'Testing regular expression edge cases'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); +var cnLBOUND = 1; +var cnUBOUND = 1000; + + +status = inSection(1); +pattern = /abc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(2); +pattern = /abc/; +string = 'xabcy'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(3); +pattern = /abc/; +string = 'ababc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(4); +pattern = /ab*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(5); +pattern = /ab*bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(6); +pattern = /ab*bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(7); +pattern = /ab*bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(8); +pattern = /.{1}/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(9); +pattern = /.{3,4}/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbb'); +addThis(); + +status = inSection(10); +pattern = /ab{0,}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(11); +pattern = /ab+bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(12); +pattern = /ab+bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(13); +pattern = /ab{1,}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(14); +pattern = /ab{1,3}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(15); +pattern = /ab{3,4}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbbc'); +addThis(); + +status = inSection(16); +pattern = /ab?bc/; +string = 'abbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbc'); +addThis(); + +status = inSection(17); +pattern = /ab?bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(18); +pattern = /ab{0,1}bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(19); +pattern = /ab?c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(20); +pattern = /ab{0,1}c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(21); +pattern = /^abc$/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(22); +pattern = /^abc/; +string = 'abcc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(23); +pattern = /abc$/; +string = 'aabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(24); +pattern = /^/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(25); +pattern = /$/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(26); +pattern = /a.c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(27); +pattern = /a.c/; +string = 'axc'; +actualmatch = string.match(pattern); +expectedmatch = Array('axc'); +addThis(); + +status = inSection(28); +pattern = /a.*c/; +string = 'axyzc'; +actualmatch = string.match(pattern); +expectedmatch = Array('axyzc'); +addThis(); + +status = inSection(29); +pattern = /a[bc]d/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abd'); +addThis(); + +status = inSection(30); +pattern = /a[b-d]e/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace'); +addThis(); + +status = inSection(31); +pattern = /a[b-d]/; +string = 'aac'; +actualmatch = string.match(pattern); +expectedmatch = Array('ac'); +addThis(); + +status = inSection(32); +pattern = /a[-b]/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-'); +addThis(); + +status = inSection(33); +pattern = /a[b-]/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-'); +addThis(); + +status = inSection(34); +pattern = /a]/; +string = 'a]'; +actualmatch = string.match(pattern); +expectedmatch = Array('a]'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not + pattern = /a[]]b/; + status = inSection(35); + string = 'a]b'; + actualmatch = string.match(pattern); + expectedmatch = Array('a]b'); + addThis(); +*/ + +status = inSection(36); +pattern = /a[^bc]d/; +string = 'aed'; +actualmatch = string.match(pattern); +expectedmatch = Array('aed'); +addThis(); + +status = inSection(37); +pattern = /a[^-b]c/; +string = 'adc'; +actualmatch = string.match(pattern); +expectedmatch = Array('adc'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not + status = inSection(38); + pattern = /a[^]b]c/; + string = 'adc'; + actualmatch = string.match(pattern); + expectedmatch = Array('adc'); + addThis(); +*/ + +status = inSection(39); +pattern = /\ba\b/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(40); +pattern = /\ba\b/; +string = '-a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(41); +pattern = /\ba\b/; +string = '-a-'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(42); +pattern = /\By\b/; +string = 'xy'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(43); +pattern = /\by\B/; +string = 'yz'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(44); +pattern = /\By\B/; +string = 'xyz'; +actualmatch = string.match(pattern); +expectedmatch = Array('y'); +addThis(); + +status = inSection(45); +pattern = /\w/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(46); +pattern = /\W/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(47); +pattern = /a\Sb/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-b'); +addThis(); + +status = inSection(48); +pattern = /\d/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = Array('1'); +addThis(); + +status = inSection(49); +pattern = /\D/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(50); +pattern = /[\w]/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(51); +pattern = /[\W]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(52); +pattern = /a[\S]b/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a-b'); +addThis(); + +status = inSection(53); +pattern = /[\d]/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = Array('1'); +addThis(); + +status = inSection(54); +pattern = /[\D]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = Array('-'); +addThis(); + +status = inSection(55); +pattern = /ab|cd/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(56); +pattern = /ab|cd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(57); +pattern = /()ef/; +string = 'def'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', ''); +addThis(); + +status = inSection(58); +pattern = /a\(b/; +string = 'a(b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a(b'); +addThis(); + +status = inSection(59); +pattern = /a\(*b/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(60); +pattern = /a\(*b/; +string = 'a((b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a((b'); +addThis(); + +status = inSection(61); +pattern = /a\\b/; +string = 'a\\b'; +actualmatch = string.match(pattern); +expectedmatch = Array('a\\b'); +addThis(); + +status = inSection(62); +pattern = /((a))/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a'); +addThis(); + +status = inSection(63); +pattern = /(a)b(c)/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'a', 'c'); +addThis(); + +status = inSection(64); +pattern = /a+b+c/; +string = 'aabbabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(65); +pattern = /a{1,}b{1,}c/; +string = 'aabbabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(66); +pattern = /a.+?c/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc'); +addThis(); + +status = inSection(67); +pattern = /(a+|b)*/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(68); +pattern = /(a+|b){0,}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(69); +pattern = /(a+|b)+/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(70); +pattern = /(a+|b){1,}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab', 'b'); +addThis(); + +status = inSection(71); +pattern = /(a+|b)?/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(72); +pattern = /(a+|b){0,1}/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(73); +pattern = /[^ab]*/; +string = 'cde'; +actualmatch = string.match(pattern); +expectedmatch = Array('cde'); +addThis(); + +status = inSection(74); +pattern = /([abc])*d/; +string = 'abbbcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abbbcd', 'c'); +addThis(); + +status = inSection(75); +pattern = /([abc])*bcd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'a'); +addThis(); + +status = inSection(76); +pattern = /a|b|c|d|e/; +string = 'e'; +actualmatch = string.match(pattern); +expectedmatch = Array('e'); +addThis(); + +status = inSection(77); +pattern = /(a|b|c|d|e)f/; +string = 'ef'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', 'e'); +addThis(); + +status = inSection(78); +pattern = /abcd*efg/; +string = 'abcdefg'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcdefg'); +addThis(); + +status = inSection(79); +pattern = /ab*/; +string = 'xabyabbbz'; +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +status = inSection(80); +pattern = /ab*/; +string = 'xayabbbz'; +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +status = inSection(81); +pattern = /(ab|cd)e/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('cde', 'cd'); +addThis(); + +status = inSection(82); +pattern = /[abhgefdc]ij/; +string = 'hij'; +actualmatch = string.match(pattern); +expectedmatch = Array('hij'); +addThis(); + +status = inSection(83); +pattern = /(abc|)ef/; +string = 'abcdef'; +actualmatch = string.match(pattern); +expectedmatch = Array('ef', ''); +addThis(); + +status = inSection(84); +pattern = /(a|b)c*d/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('bcd', 'b'); +addThis(); + +status = inSection(85); +pattern = /(ab|ab*)bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'a'); +addThis(); + +status = inSection(86); +pattern = /a([bc]*)c*/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'bc'); +addThis(); + +status = inSection(87); +pattern = /a([bc]*)(c*d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc', 'd'); +addThis(); + +status = inSection(88); +pattern = /a([bc]+)(c*d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc', 'd'); +addThis(); + +status = inSection(89); +pattern = /a([bc]*)(c+d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'b', 'cd'); +addThis(); + +status = inSection(90); +pattern = /a[bcd]*dcdcde/; +string = 'adcdcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('adcdcde'); +addThis(); + +status = inSection(91); +pattern = /(ab|a)b*c/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abc', 'ab'); +addThis(); + +status = inSection(92); +pattern = /((a)(b)c)(d)/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'abc', 'a', 'b', 'd'); +addThis(); + +status = inSection(93); +pattern = /[a-zA-Z_][a-zA-Z0-9_]*/; +string = 'alpha'; +actualmatch = string.match(pattern); +expectedmatch = Array('alpha'); +addThis(); + +status = inSection(94); +pattern = /^a(bc+|b[eh])g|.h$/; +string = 'abh'; +actualmatch = string.match(pattern); +expectedmatch = Array('bh', undefined); +addThis(); + +status = inSection(95); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'effgz'; +actualmatch = string.match(pattern); +expectedmatch = Array('effgz', 'effgz', undefined); +addThis(); + +status = inSection(96); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'ij'; +actualmatch = string.match(pattern); +expectedmatch = Array('ij', 'ij', 'j'); +addThis(); + +status = inSection(97); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'reffgz'; +actualmatch = string.match(pattern); +expectedmatch = Array('effgz', 'effgz', undefined); +addThis(); + +status = inSection(98); +pattern = /((((((((((a))))))))))/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(99); +pattern = /((((((((((a))))))))))\10/; +string = 'aa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aa', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(100); +pattern = /((((((((((a))))))))))/; +string = 'a!'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(101); +pattern = /(((((((((a)))))))))/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); +addThis(); + +status = inSection(102); +pattern = /(.*)c(.*)/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcde', 'ab', 'de'); +addThis(); + +status = inSection(103); +pattern = /abcd/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd'); +addThis(); + +status = inSection(104); +pattern = /a(bc)d/; +string = 'abcd'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcd', 'bc'); +addThis(); + +status = inSection(105); +pattern = /a[-]?c/; +string = 'ac'; +actualmatch = string.match(pattern); +expectedmatch = Array('ac'); +addThis(); + +status = inSection(106); +pattern = /(abc)\1/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcabc', 'abc'); +addThis(); + +status = inSection(107); +pattern = /([a-c]*)\1/; +string = 'abcabc'; +actualmatch = string.match(pattern); +expectedmatch = Array('abcabc', 'abc'); +addThis(); + +status = inSection(108); +pattern = /(a)|\1/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = Array('a', 'a'); +addThis(); + +status = inSection(109); +pattern = /(([a-c])b*?\2)*/; +string = 'ababbbcbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ababb', 'bb', 'b'); +addThis(); + +status = inSection(110); +pattern = /(([a-c])b*?\2){3}/; +string = 'ababbbcbc'; +actualmatch = string.match(pattern); +expectedmatch = Array('ababbbcbc', 'cbc', 'c'); +addThis(); + +/* Can't refer to a capture before it's encountered & completed + status = inSection(111); + pattern = /((\3|b)\2(a)x)+/; + string = 'aaaxabaxbaaxbbax'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbax', 'bbax', 'b', 'a'); + addThis(); + + status = inSection(112); + pattern = /((\3|b)\2(a)){2,}/; + string = 'bbaababbabaaaaabbaaaabba'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbaaaabba', 'bba', 'b', 'a'); + addThis(); +*/ + +status = inSection(113); +pattern = /abc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(114); +pattern = /abc/i; +string = 'XABCY'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(115); +pattern = /abc/i; +string = 'ABABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(116); +pattern = /ab*c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(117); +pattern = /ab*bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(118); +pattern = /ab*bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(119); +pattern = /ab*?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(120); +pattern = /ab{0,}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(121); +pattern = /ab+?bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(122); +pattern = /ab+bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(123); +pattern = /ab{1,}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(124); +pattern = /ab{1,3}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(125); +pattern = /ab{3,4}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBBC'); +addThis(); + +status = inSection(126); +pattern = /ab??bc/i; +string = 'ABBC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBC'); +addThis(); + +status = inSection(127); +pattern = /ab??bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(128); +pattern = /ab{0,1}?bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(129); +pattern = /ab??c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(130); +pattern = /ab{0,1}?c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(131); +pattern = /^abc$/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(132); +pattern = /^abc/i; +string = 'ABCC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(133); +pattern = /abc$/i; +string = 'AABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(134); +pattern = /^/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(135); +pattern = /$/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array(''); +addThis(); + +status = inSection(136); +pattern = /a.c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(137); +pattern = /a.c/i; +string = 'AXC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AXC'); +addThis(); + +status = inSection(138); +pattern = /a.*?c/i; +string = 'AXYZC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AXYZC'); +addThis(); + +status = inSection(139); +pattern = /a[bc]d/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABD'); +addThis(); + +status = inSection(140); +pattern = /a[b-d]e/i; +string = 'ACE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ACE'); +addThis(); + +status = inSection(141); +pattern = /a[b-d]/i; +string = 'AAC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AC'); +addThis(); + +status = inSection(142); +pattern = /a[-b]/i; +string = 'A-'; +actualmatch = string.match(pattern); +expectedmatch = Array('A-'); +addThis(); + +status = inSection(143); +pattern = /a[b-]/i; +string = 'A-'; +actualmatch = string.match(pattern); +expectedmatch = Array('A-'); +addThis(); + +status = inSection(144); +pattern = /a]/i; +string = 'A]'; +actualmatch = string.match(pattern); +expectedmatch = Array('A]'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not + status = inSection(145); + pattern = /a[]]b/i; + string = 'A]B'; + actualmatch = string.match(pattern); + expectedmatch = Array('A]B'); + addThis(); +*/ + +status = inSection(146); +pattern = /a[^bc]d/i; +string = 'AED'; +actualmatch = string.match(pattern); +expectedmatch = Array('AED'); +addThis(); + +status = inSection(147); +pattern = /a[^-b]c/i; +string = 'ADC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ADC'); +addThis(); + +/* Perl supports ] & ^] inside a [], ECMA does not + status = inSection(148); + pattern = /a[^]b]c/i; + string = 'ADC'; + actualmatch = string.match(pattern); + expectedmatch = Array('ADC'); + addThis(); +*/ + +status = inSection(149); +pattern = /ab|cd/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(150); +pattern = /ab|cd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(151); +pattern = /()ef/i; +string = 'DEF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', ''); +addThis(); + +status = inSection(152); +pattern = /a\(b/i; +string = 'A(B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A(B'); +addThis(); + +status = inSection(153); +pattern = /a\(*b/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(154); +pattern = /a\(*b/i; +string = 'A((B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A((B'); +addThis(); + +status = inSection(155); +pattern = /a\\b/i; +string = 'A\\B'; +actualmatch = string.match(pattern); +expectedmatch = Array('A\\B'); +addThis(); + +status = inSection(156); +pattern = /((a))/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A'); +addThis(); + +status = inSection(157); +pattern = /(a)b(c)/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'A', 'C'); +addThis(); + +status = inSection(158); +pattern = /a+b+c/i; +string = 'AABBABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(159); +pattern = /a{1,}b{1,}c/i; +string = 'AABBABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(160); +pattern = /a.+?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(161); +pattern = /a.*?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(162); +pattern = /a.{0,5}?c/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC'); +addThis(); + +status = inSection(163); +pattern = /(a+|b)*/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(164); +pattern = /(a+|b){0,}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(165); +pattern = /(a+|b)+/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(166); +pattern = /(a+|b){1,}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'B'); +addThis(); + +status = inSection(167); +pattern = /(a+|b)?/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(168); +pattern = /(a+|b){0,1}/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(169); +pattern = /(a+|b){0,1}?/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('', undefined); +addThis(); + +status = inSection(170); +pattern = /[^ab]*/i; +string = 'CDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('CDE'); +addThis(); + +status = inSection(171); +pattern = /([abc])*d/i; +string = 'ABBBCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABBBCD', 'C'); +addThis(); + +status = inSection(172); +pattern = /([abc])*bcd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'A'); +addThis(); + +status = inSection(173); +pattern = /a|b|c|d|e/i; +string = 'E'; +actualmatch = string.match(pattern); +expectedmatch = Array('E'); +addThis(); + +status = inSection(174); +pattern = /(a|b|c|d|e)f/i; +string = 'EF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', 'E'); +addThis(); + +status = inSection(175); +pattern = /abcd*efg/i; +string = 'ABCDEFG'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCDEFG'); +addThis(); + +status = inSection(176); +pattern = /ab*/i; +string = 'XABYABBBZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB'); +addThis(); + +status = inSection(177); +pattern = /ab*/i; +string = 'XAYABBBZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('A'); +addThis(); + +status = inSection(178); +pattern = /(ab|cd)e/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('CDE', 'CD'); +addThis(); + +status = inSection(179); +pattern = /[abhgefdc]ij/i; +string = 'HIJ'; +actualmatch = string.match(pattern); +expectedmatch = Array('HIJ'); +addThis(); + +status = inSection(180); +pattern = /(abc|)ef/i; +string = 'ABCDEF'; +actualmatch = string.match(pattern); +expectedmatch = Array('EF', ''); +addThis(); + +status = inSection(181); +pattern = /(a|b)c*d/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('BCD', 'B'); +addThis(); + +status = inSection(182); +pattern = /(ab|ab*)bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'A'); +addThis(); + +status = inSection(183); +pattern = /a([bc]*)c*/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'BC'); +addThis(); + +status = inSection(184); +pattern = /a([bc]*)(c*d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC', 'D'); +addThis(); + +status = inSection(185); +pattern = /a([bc]+)(c*d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC', 'D'); +addThis(); + +status = inSection(186); +pattern = /a([bc]*)(c+d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'B', 'CD'); +addThis(); + +status = inSection(187); +pattern = /a[bcd]*dcdcde/i; +string = 'ADCDCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ADCDCDE'); +addThis(); + +status = inSection(188); +pattern = /(ab|a)b*c/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABC', 'AB'); +addThis(); + +status = inSection(189); +pattern = /((a)(b)c)(d)/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'ABC', 'A', 'B', 'D'); +addThis(); + +status = inSection(190); +pattern = /[a-zA-Z_][a-zA-Z0-9_]*/i; +string = 'ALPHA'; +actualmatch = string.match(pattern); +expectedmatch = Array('ALPHA'); +addThis(); + +status = inSection(191); +pattern = /^a(bc+|b[eh])g|.h$/i; +string = 'ABH'; +actualmatch = string.match(pattern); +expectedmatch = Array('BH', undefined); +addThis(); + +status = inSection(192); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'EFFGZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('EFFGZ', 'EFFGZ', undefined); +addThis(); + +status = inSection(193); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'IJ'; +actualmatch = string.match(pattern); +expectedmatch = Array('IJ', 'IJ', 'J'); +addThis(); + +status = inSection(194); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'REFFGZ'; +actualmatch = string.match(pattern); +expectedmatch = Array('EFFGZ', 'EFFGZ', undefined); +addThis(); + +status = inSection(195); +pattern = /((((((((((a))))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(196); +pattern = /((((((((((a))))))))))\10/i; +string = 'AA'; +actualmatch = string.match(pattern); +expectedmatch = Array('AA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(197); +pattern = /((((((((((a))))))))))/i; +string = 'A!'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(198); +pattern = /(((((((((a)))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A'); +addThis(); + +status = inSection(199); +pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))/i; +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', 'A'); +addThis(); + +status = inSection(200); +pattern = /(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))/i; +string = 'C'; +actualmatch = string.match(pattern); +expectedmatch = Array('C', 'C'); +addThis(); + +status = inSection(201); +pattern = /(.*)c(.*)/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCDE', 'AB', 'DE'); +addThis(); + +status = inSection(202); +pattern = /abcd/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD'); +addThis(); + +status = inSection(203); +pattern = /a(bc)d/i; +string = 'ABCD'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCD', 'BC'); +addThis(); + +status = inSection(204); +pattern = /a[-]?c/i; +string = 'AC'; +actualmatch = string.match(pattern); +expectedmatch = Array('AC'); +addThis(); + +status = inSection(205); +pattern = /(abc)\1/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCABC', 'ABC'); +addThis(); + +status = inSection(206); +pattern = /([a-c]*)\1/i; +string = 'ABCABC'; +actualmatch = string.match(pattern); +expectedmatch = Array('ABCABC', 'ABC'); +addThis(); + +status = inSection(207); +pattern = /a(?!b)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(208); +pattern = /a(?=d)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(209); +pattern = /a(?=c|d)./; +string = 'abad'; +actualmatch = string.match(pattern); +expectedmatch = Array('ad'); +addThis(); + +status = inSection(210); +pattern = /a(?:b|c|d)(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(211); +pattern = /a(?:b|c|d)*(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(212); +pattern = /a(?:b|c|d)+?(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'e'); +addThis(); + +status = inSection(213); +pattern = /a(?:b|c|d)+?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acd', 'd'); +addThis(); + +status = inSection(214); +pattern = /a(?:b|c|d)+(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(215); +pattern = /a(?:b|c|d){2}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdb', 'b'); +addThis(); + +status = inSection(216); +pattern = /a(?:b|c|d){4,5}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(217); +pattern = /a(?:b|c|d){4,5}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcd', 'd'); +addThis(); + +// MODIFIED - ECMA has different rules for paren contents +status = inSection(218); +pattern = /((foo)|(bar))*/; +string = 'foobar'; +actualmatch = string.match(pattern); +//expectedmatch = Array('foobar', 'bar', 'foo', 'bar'); +expectedmatch = Array('foobar', 'bar', undefined, 'bar'); +addThis(); + +status = inSection(219); +pattern = /a(?:b|c|d){6,7}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(220); +pattern = /a(?:b|c|d){6,7}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(221); +pattern = /a(?:b|c|d){5,6}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(222); +pattern = /a(?:b|c|d){5,6}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(223); +pattern = /a(?:b|c|d){5,7}(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdbe', 'e'); +addThis(); + +status = inSection(224); +pattern = /a(?:b|c|d){5,7}?(.)/; +string = 'acdbcdbe'; +actualmatch = string.match(pattern); +expectedmatch = Array('acdbcdb', 'b'); +addThis(); + +status = inSection(225); +pattern = /a(?:b|(c|e){1,2}?|d)+?(.)/; +string = 'ace'; +actualmatch = string.match(pattern); +expectedmatch = Array('ace', 'c', 'e'); +addThis(); + +status = inSection(226); +pattern = /^(.+)?B/; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = Array('AB', 'A'); +addThis(); + +/* MODIFIED - ECMA has different rules for paren contents */ +status = inSection(227); +pattern = /^([^a-z])|(\^)$/; +string = '.'; +actualmatch = string.match(pattern); +//expectedmatch = Array('.', '.', ''); +expectedmatch = Array('.', '.', undefined); +addThis(); + +status = inSection(228); +pattern = /^[<>]&/; +string = '<&OUT'; +actualmatch = string.match(pattern); +expectedmatch = Array('<&'); +addThis(); + +/* Can't refer to a capture before it's encountered & completed + status = inSection(229); + pattern = /^(a\1?){4}$/; + string = 'aaaaaaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaaaaaaaa', 'aaaa'); + addThis(); + + status = inSection(230); + pattern = /^(a(?(1)\1)){4}$/; + string = 'aaaaaaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaaaaaaaa', 'aaaa'); + addThis(); +*/ + +status = inSection(231); +pattern = /((a{4})+)/; +string = 'aaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa'); +addThis(); + +status = inSection(232); +pattern = /(((aa){2})+)/; +string = 'aaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa'); +addThis(); + +status = inSection(233); +pattern = /(((a{2}){2})+)/; +string = 'aaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = Array('aaaaaaaa', 'aaaaaaaa', 'aaaa', 'aa'); +addThis(); + +status = inSection(234); +pattern = /(?:(f)(o)(o)|(b)(a)(r))*/; +string = 'foobar'; +actualmatch = string.match(pattern); +//expectedmatch = Array('foobar', 'f', 'o', 'o', 'b', 'a', 'r'); +expectedmatch = Array('foobar', undefined, undefined, undefined, 'b', 'a', 'r'); +addThis(); + +/* ECMA supports (?: (?= and (?! but doesn't support (?< etc. + status = inSection(235); + pattern = /(?<=a)b/; + string = 'ab'; + actualmatch = string.match(pattern); + expectedmatch = Array('b'); + addThis(); + + status = inSection(236); + pattern = /(? + status = inSection(311); + pattern = /(?>a+)b/; + string = 'aaab'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaab'); + addThis(); +*/ + +status = inSection(312); +pattern = /([[:]+)/; + string = 'a:[b]:'; + actualmatch = string.match(pattern); + expectedmatch = Array(':[', ':['); + addThis(); + + status = inSection(313); + pattern = /([[=]+)/; + string = 'a=[b]='; + actualmatch = string.match(pattern); + expectedmatch = Array('=[', '=['); + addThis(); + + status = inSection(314); + pattern = /([[.]+)/; + string = 'a.[b].'; + actualmatch = string.match(pattern); + expectedmatch = Array('.[', '.['); + addThis(); + +/* ECMA doesn't have rules for [: + status = inSection(315); + pattern = /[a[:]b[:c]/; + string = 'abc'; + actualmatch = string.match(pattern); + expectedmatch = Array('abc'); + addThis(); +*/ + +/* ECMA doesn't support (?> + status = inSection(316); + pattern = /((?>a+)b)/; + string = 'aaab'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaab', 'aaab'); + addThis(); + + status = inSection(317); + pattern = /(?>(a+))b/; + string = 'aaab'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaab', 'aaa'); + addThis(); + + status = inSection(318); + pattern = /((?>[^()]+)|\([^()]*\))+/; + string = '((abc(ade)ufh()()x'; + actualmatch = string.match(pattern); + expectedmatch = Array('abc(ade)ufh()()x', 'x'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(319); + pattern = /\Z/; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(320); + pattern = /\z/; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(321); + pattern = /$/; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(322); + pattern = /\Z/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(323); + pattern = /\z/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(324); + pattern = /$/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(325); + pattern = /\Z/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(326); + pattern = /\z/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(327); + pattern = /$/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(328); + pattern = /\Z/m; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(329); + pattern = /\z/m; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(330); + pattern = /$/m; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(331); + pattern = /\Z/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(332); + pattern = /\z/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(333); + pattern = /$/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(334); + pattern = /\Z/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + + status = inSection(335); + pattern = /\z/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); +*/ + + status = inSection(336); + pattern = /$/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array(''); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(337); + pattern = /a\Z/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + +/* $ only matches end of input unless multiline + status = inSection(338); + pattern = /a$/; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(339); + pattern = /a\Z/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + + status = inSection(340); + pattern = /a\z/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + + status = inSection(341); + pattern = /a$/; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + + status = inSection(342); + pattern = /a$/m; + string = 'a\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(343); + pattern = /a\Z/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + + status = inSection(344); + pattern = /a$/m; + string = 'b\na\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(345); + pattern = /a\Z/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + + status = inSection(346); + pattern = /a\z/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); +*/ + + status = inSection(347); + pattern = /a$/m; + string = 'b\na'; + actualmatch = string.match(pattern); + expectedmatch = Array('a'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(348); + pattern = /aa\Z/; + string = 'b\naa\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + +/* $ only matches end of input unless multiline + status = inSection(349); + pattern = /aa$/; + string = 'b\naa\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(350); + pattern = /aa\Z/; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + + status = inSection(351); + pattern = /aa\z/; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + + status = inSection(352); + pattern = /aa$/; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + + status = inSection(353); + pattern = /aa$/m; + string = 'aa\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(354); + pattern = /aa\Z/m; + string = 'b\naa\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + + status = inSection(355); + pattern = /aa$/m; + string = 'b\naa\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(356); + pattern = /aa\Z/m; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + + status = inSection(357); + pattern = /aa\z/m; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); +*/ + + status = inSection(358); + pattern = /aa$/m; + string = 'b\naa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aa'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(359); + pattern = /ab\Z/; + string = 'b\nab\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + +/* $ only matches end of input unless multiline + status = inSection(360); + pattern = /ab$/; + string = 'b\nab\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(361); + pattern = /ab\Z/; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + + status = inSection(362); + pattern = /ab\z/; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + + status = inSection(363); + pattern = /ab$/; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + + status = inSection(364); + pattern = /ab$/m; + string = 'ab\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(365); + pattern = /ab\Z/m; + string = 'b\nab\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + + status = inSection(366); + pattern = /ab$/m; + string = 'b\nab\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(367); + pattern = /ab\Z/m; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + + status = inSection(368); + pattern = /ab\z/m; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); +*/ + + status = inSection(369); + pattern = /ab$/m; + string = 'b\nab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(370); + pattern = /abb\Z/; + string = 'b\nabb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + +/* $ only matches end of input unless multiline + status = inSection(371); + pattern = /abb$/; + string = 'b\nabb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(372); + pattern = /abb\Z/; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + + status = inSection(373); + pattern = /abb\z/; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + + status = inSection(374); + pattern = /abb$/; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + + status = inSection(375); + pattern = /abb$/m; + string = 'abb\nb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(376); + pattern = /abb\Z/m; + string = 'b\nabb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + + status = inSection(377); + pattern = /abb$/m; + string = 'b\nabb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + +/* Perl has \Z has end-of-line, ECMA doesn't + status = inSection(378); + pattern = /abb\Z/m; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + + status = inSection(379); + pattern = /abb\z/m; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); +*/ + + status = inSection(380); + pattern = /abb$/m; + string = 'b\nabb'; + actualmatch = string.match(pattern); + expectedmatch = Array('abb'); + addThis(); + + status = inSection(381); + pattern = /(^|x)(c)/; + string = 'ca'; + actualmatch = string.match(pattern); + expectedmatch = Array('c', '', 'c'); + addThis(); + + status = inSection(382); + pattern = /foo.bart/; + string = 'foo.bart'; + actualmatch = string.match(pattern); + expectedmatch = Array('foo.bart'); + addThis(); + + status = inSection(383); + pattern = /^d[x][x][x]/m; + string = 'abcd\ndxxx'; + actualmatch = string.match(pattern); + expectedmatch = Array('dxxx'); + addThis(); + + status = inSection(384); + pattern = /tt+$/; + string = 'xxxtt'; + actualmatch = string.match(pattern); + expectedmatch = Array('tt'); + addThis(); + +/* ECMA spec says that each atom in a range must be a single character + status = inSection(385); + pattern = /([a-\d]+)/; + string = 'za-9z'; + actualmatch = string.match(pattern); + expectedmatch = Array('9', '9'); + addThis(); + + status = inSection(386); + pattern = /([\d-z]+)/; + string = 'a0-za'; + actualmatch = string.match(pattern); + expectedmatch = Array('0-z', '0-z'); + addThis(); +*/ + +/* ECMA doesn't support [: + status = inSection(387); + pattern = /([a-[:digit:]]+)/; + string = 'za-9z'; + actualmatch = string.match(pattern); + expectedmatch = Array('a-9', 'a-9'); + addThis(); + + status = inSection(388); + pattern = /([[:digit:]-z]+)/; + string = '=0-z='; + actualmatch = string.match(pattern); + expectedmatch = Array('0-z', '0-z'); + addThis(); + + status = inSection(389); + pattern = /([[:digit:]-[:alpha:]]+)/; + string = '=0-z='; + actualmatch = string.match(pattern); + expectedmatch = Array('0-z', '0-z'); + addThis(); +*/ + + status = inSection(390); + pattern = /(\d+\.\d+)/; + string = '3.1415926'; + actualmatch = string.match(pattern); + expectedmatch = Array('3.1415926', '3.1415926'); + addThis(); + + status = inSection(391); + pattern = /\.c(pp|xx|c)?$/i; + string = 'IO.c'; + actualmatch = string.match(pattern); + expectedmatch = Array('.c', undefined); + addThis(); + + status = inSection(392); + pattern = /(\.c(pp|xx|c)?$)/i; + string = 'IO.c'; + actualmatch = string.match(pattern); + expectedmatch = Array('.c', '.c', undefined); + addThis(); + + status = inSection(393); + pattern = /(^|a)b/; + string = 'ab'; + actualmatch = string.match(pattern); + expectedmatch = Array('ab', 'a'); + addThis(); + + status = inSection(394); + pattern = /^([ab]*?)(b)?(c)$/; + string = 'abac'; + actualmatch = string.match(pattern); + expectedmatch = Array('abac', 'aba', undefined, 'c'); + addThis(); + + status = inSection(395); + pattern = /^(?:.,){2}c/i; + string = 'a,b,c'; + actualmatch = string.match(pattern); + expectedmatch = Array('a,b,c'); + addThis(); + + status = inSection(396); + pattern = /^(.,){2}c/i; + string = 'a,b,c'; + actualmatch = string.match(pattern); + expectedmatch = Array('a,b,c', 'b,'); + addThis(); + + status = inSection(397); + pattern = /^(?:[^,]*,){2}c/; + string = 'a,b,c'; + actualmatch = string.match(pattern); + expectedmatch = Array('a,b,c'); + addThis(); + + status = inSection(398); + pattern = /^([^,]*,){2}c/; + string = 'a,b,c'; + actualmatch = string.match(pattern); + expectedmatch = Array('a,b,c', 'b,'); + addThis(); + + status = inSection(399); + pattern = /^([^,]*,){3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(400); + pattern = /^([^,]*,){3,}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(401); + pattern = /^([^,]*,){0,3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(402); + pattern = /^([^,]{1,3},){3}d/i; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(403); + pattern = /^([^,]{1,3},){3,}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(404); + pattern = /^([^,]{1,3},){0,3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(405); + pattern = /^([^,]{1,},){3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(406); + pattern = /^([^,]{1,},){3,}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(407); + pattern = /^([^,]{1,},){0,3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(408); + pattern = /^([^,]{0,3},){3}d/i; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(409); + pattern = /^([^,]{0,3},){3,}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + + status = inSection(410); + pattern = /^([^,]{0,3},){0,3}d/; + string = 'aaa,b,c,d'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaa,b,c,d', 'c,'); + addThis(); + +/* ECMA doesn't support \A + status = inSection(411); + pattern = /(?!\A)x/m; + string = 'a\nxb\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('\n'); + addThis(); +*/ + + status = inSection(412); + pattern = /^(a(b)?)+$/; + string = 'aba'; + actualmatch = string.match(pattern); + expectedmatch = Array('aba', 'a', undefined); + addThis(); + + status = inSection(413); + pattern = /^(aa(bb)?)+$/; + string = 'aabbaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aabbaa', 'aa', undefined); + addThis(); + + status = inSection(414); + pattern = /^.{9}abc.*\n/m; + string = '123\nabcabcabcabc\n'; + actualmatch = string.match(pattern); + expectedmatch = Array('abcabcabcabc\n'); + addThis(); + + status = inSection(415); + pattern = /^(a)?a$/; + string = 'a'; + actualmatch = string.match(pattern); + expectedmatch = Array('a', undefined); + addThis(); + + status = inSection(416); + pattern = /^(a\1?)(a\1?)(a\2?)(a\3?)$/; + string = 'aaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaaaa', 'a', 'aa', 'a', 'aa'); + addThis(); + +/* Can't refer to a capture before it's encountered & completed + status = inSection(417); + pattern = /^(a\1?){4}$/; + string = 'aaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaaaa', 'aaa'); + addThis(); +*/ + + status = inSection(418); + pattern = /^(0+)?(?:x(1))?/; + string = 'x1'; + actualmatch = string.match(pattern); + expectedmatch = Array('x1', undefined, '1'); + addThis(); + + status = inSection(419); + pattern = /^([0-9a-fA-F]+)(?:x([0-9a-fA-F]+)?)(?:x([0-9a-fA-F]+))?/; + string = '012cxx0190'; + actualmatch = string.match(pattern); + expectedmatch = Array('012cxx0190', '012c', undefined, '0190'); + addThis(); + + status = inSection(420); + pattern = /^(b+?|a){1,2}c/; + string = 'bbbac'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbbac', 'a'); + addThis(); + + status = inSection(421); + pattern = /^(b+?|a){1,2}c/; + string = 'bbbbac'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbbbac', 'a'); + addThis(); + + status = inSection(422); + pattern = /((?:aaaa|bbbb)cccc)?/; + string = 'aaaacccc'; + actualmatch = string.match(pattern); + expectedmatch = Array('aaaacccc', 'aaaacccc'); + addThis(); + + status = inSection(423); + pattern = /((?:aaaa|bbbb)cccc)?/; + string = 'bbbbcccc'; + actualmatch = string.match(pattern); + expectedmatch = Array('bbbbcccc', 'bbbbcccc'); + addThis(); + + + + +//----------------------------------------------------------------------------- + test(); +//----------------------------------------------------------------------------- + + + + function addThis() + { + if(omitCurrentSection()) + return; + + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; + } + + + function omitCurrentSection() + { + try + { + // current section number is in global status variable + var n = status.match(/(\d+)/)[1]; + return ((n < cnLBOUND) || (n > cnUBOUND)); + } + catch(e) + { + return false; + } + } + + + function test() + { + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); + } diff --git a/js/src/tests/ecma_3/RegExp/perlstress-002.js b/js/src/tests/ecma_3/RegExp/perlstress-002.js new file mode 100644 index 000000000..126d12bc1 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/perlstress-002.js @@ -0,0 +1,1808 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 2002-07-07 + * SUMMARY: Testing JS RegExp engine against Perl 5 RegExp engine. + * Adjust cnLBOUND, cnUBOUND below to restrict which sections are tested. + * + * This test was created by running various patterns and strings through the + * Perl 5 RegExp engine. We saved the results below to test the JS engine. + * + * Each of the examples below is a negative test; that is, each produces a + * null match in Perl. Thus we set |expectedmatch| = |null| in each section. + * + * NOTE: ECMA/JS and Perl do differ on certain points. We have either commented + * out such sections altogether, or modified them to fit what we expect from JS. + * + * EXAMPLES: + * + * - ECMA does support (?: (?= and (?! operators, but doesn't support (?< etc. + * + * - ECMA doesn't support (?(condition) + * + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 85721; +var summary = 'Testing regular expression edge cases'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); +var cnLBOUND = 0; +var cnUBOUND = 1000; + + +status = inSection(1); +pattern = /abc/; +string = 'xbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(2); +pattern = /abc/; +string = 'axc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(3); +pattern = /abc/; +string = 'abx'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(4); +pattern = /ab+bc/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(5); +pattern = /ab+bc/; +string = 'abq'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(6); +pattern = /ab{1,}bc/; +string = 'abq'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(7); +pattern = /ab{4,5}bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(8); +pattern = /ab?bc/; +string = 'abbbbc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(9); +pattern = /^abc$/; +string = 'abcc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(10); +pattern = /^abc$/; +string = 'aabc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(11); +pattern = /abc$/; +string = 'aabcd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(12); +pattern = /a.*c/; +string = 'axyzd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(13); +pattern = /a[bc]d/; +string = 'abc'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(14); +pattern = /a[b-d]e/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(15); +pattern = /a[^bc]d/; +string = 'abd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(16); +pattern = /a[^-b]c/; +string = 'a-c'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(17); +pattern = /a[^]b]c/; +string = 'a]c'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(18); +pattern = /\by\b/; +string = 'xy'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(19); +pattern = /\by\b/; +string = 'yz'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(20); +pattern = /\by\b/; +string = 'xyz'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(21); +pattern = /\Ba\B/; +string = 'a-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(22); +pattern = /\Ba\B/; +string = '-a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(23); +pattern = /\Ba\B/; +string = '-a-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(24); +pattern = /\w/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(25); +pattern = /\W/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(26); +pattern = /a\sb/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(27); +pattern = /\d/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(28); +pattern = /\D/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(29); +pattern = /[\w]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(30); +pattern = /[\W]/; +string = 'a'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(31); +pattern = /a[\s]b/; +string = 'a-b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(32); +pattern = /[\d]/; +string = '-'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(33); +pattern = /[\D]/; +string = '1'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(34); +pattern = /$b/; +string = 'b'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(35); +pattern = /^(ab|cd)e/; +string = 'abcde'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(36); +pattern = /a[bcd]+dcdcde/; +string = 'adcdcde'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(37); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'effg'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(38); +pattern = /(bc+d$|ef*g.|h?i(j|k))/; +string = 'bcdd'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(39); +pattern = /[k]/; +string = 'ab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +// MODIFIED - ECMA has different rules for paren contents. +status = inSection(40); +pattern = /(a)|\1/; +string = 'x'; +actualmatch = string.match(pattern); +//expectedmatch = null; +expectedmatch = Array("", undefined); +addThis(); + +// MODIFIED - ECMA has different rules for paren contents. +status = inSection(41); +pattern = /((\3|b)\2(a)x)+/; +string = 'aaxabxbaxbbx'; +actualmatch = string.match(pattern); +//expectedmatch = null; +expectedmatch = Array("ax", "ax", "", "a"); +addThis(); + +status = inSection(42); +pattern = /abc/i; +string = 'XBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(43); +pattern = /abc/i; +string = 'AXC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(44); +pattern = /abc/i; +string = 'ABX'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(45); +pattern = /ab+bc/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(46); +pattern = /ab+bc/i; +string = 'ABQ'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(47); +pattern = /ab{1,}bc/i; +string = 'ABQ'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(48); +pattern = /ab{4,5}?bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(49); +pattern = /ab??bc/i; +string = 'ABBBBC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(50); +pattern = /^abc$/i; +string = 'ABCC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(51); +pattern = /^abc$/i; +string = 'AABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(52); +pattern = /a.*c/i; +string = 'AXYZD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(53); +pattern = /a[bc]d/i; +string = 'ABC'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(54); +pattern = /a[b-d]e/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(55); +pattern = /a[^bc]d/i; +string = 'ABD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(56); +pattern = /a[^-b]c/i; +string = 'A-C'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(57); +pattern = /a[^]b]c/i; +string = 'A]C'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(58); +pattern = /$b/i; +string = 'B'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(59); +pattern = /^(ab|cd)e/i; +string = 'ABCDE'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(60); +pattern = /a[bcd]+dcdcde/i; +string = 'ADCDCDE'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(61); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'EFFG'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(62); +pattern = /(bc+d$|ef*g.|h?i(j|k))/i; +string = 'BCDD'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(63); +pattern = /[k]/i; +string = 'AB'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(64); +pattern = /^(a\1?){4}$/; +string = 'aaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(65); +pattern = /^(a\1?){4}$/; +string = 'aaaaaaaaaaa'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* ECMA doesn't support (?( + status = inSection(66); + pattern = /^(a(?(1)\1)){4}$/; + string = 'aaaaaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(67); + pattern = /^(a(?(1)\1)){4}$/; + string = 'aaaaaaaaaaa'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); +*/ + +/* ECMA doesn't support (?< + status = inSection(68); + pattern = /(?<=a)b/; + string = 'cb'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(69); + pattern = /(?<=a)b/; + string = 'b'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); + + status = inSection(70); + pattern = /(?a+)ab/; +string = 'aaab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(106); +pattern = /a\Z/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(107); +pattern = /a\z/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(108); +pattern = /a$/; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(109); +pattern = /a\z/; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(110); +pattern = /a\z/m; +string = 'a\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(111); +pattern = /a\z/m; +string = 'b\na\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(112); +pattern = /aa\Z/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(113); +pattern = /aa\z/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(114); +pattern = /aa$/; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(115); +pattern = /aa\z/; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(116); +pattern = /aa\z/m; +string = 'aa\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(117); +pattern = /aa\z/m; +string = 'b\naa\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(118); +pattern = /aa\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(119); +pattern = /aa\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(120); +pattern = /aa$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(121); +pattern = /aa\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(122); +pattern = /aa\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(123); +pattern = /aa$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(124); +pattern = /aa\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(125); +pattern = /aa\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(126); +pattern = /aa$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(127); +pattern = /aa\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(128); +pattern = /aa\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(129); +pattern = /aa$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(130); +pattern = /aa\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(131); +pattern = /aa\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(132); +pattern = /aa$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(133); +pattern = /aa\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(134); +pattern = /aa\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(135); +pattern = /aa$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(136); +pattern = /aa\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(137); +pattern = /aa\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(138); +pattern = /aa$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(139); +pattern = /aa\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(140); +pattern = /aa\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(141); +pattern = /aa$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(142); +pattern = /aa\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(143); +pattern = /aa\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(144); +pattern = /aa$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(145); +pattern = /aa\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(146); +pattern = /aa\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(147); +pattern = /aa$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(148); +pattern = /aa\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(149); +pattern = /aa\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(150); +pattern = /aa$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(151); +pattern = /aa\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(152); +pattern = /aa\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(153); +pattern = /aa$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(154); +pattern = /ab\Z/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(155); +pattern = /ab\z/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(156); +pattern = /ab$/; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(157); +pattern = /ab\z/; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(158); +pattern = /ab\z/m; +string = 'ab\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(159); +pattern = /ab\z/m; +string = 'b\nab\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(160); +pattern = /ab\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(161); +pattern = /ab\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(162); +pattern = /ab$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(163); +pattern = /ab\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(164); +pattern = /ab\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(165); +pattern = /ab$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(166); +pattern = /ab\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(167); +pattern = /ab\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(168); +pattern = /ab$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(169); +pattern = /ab\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(170); +pattern = /ab\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(171); +pattern = /ab$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(172); +pattern = /ab\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(173); +pattern = /ab\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(174); +pattern = /ab$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(175); +pattern = /ab\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(176); +pattern = /ab\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(177); +pattern = /ab$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(178); +pattern = /ab\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(179); +pattern = /ab\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(180); +pattern = /ab$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(181); +pattern = /ab\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(182); +pattern = /ab\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(183); +pattern = /ab$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(184); +pattern = /ab\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(185); +pattern = /ab\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(186); +pattern = /ab$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(187); +pattern = /ab\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(188); +pattern = /ab\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(189); +pattern = /ab$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(190); +pattern = /ab\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(191); +pattern = /ab\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(192); +pattern = /ab$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(193); +pattern = /ab\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(194); +pattern = /ab\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(195); +pattern = /ab$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(196); +pattern = /abb\Z/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(197); +pattern = /abb\z/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(198); +pattern = /abb$/; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(199); +pattern = /abb\z/; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(200); +pattern = /abb\z/m; +string = 'abb\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(201); +pattern = /abb\z/m; +string = 'b\nabb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(202); +pattern = /abb\Z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(203); +pattern = /abb\z/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(204); +pattern = /abb$/; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(205); +pattern = /abb\Z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(206); +pattern = /abb\z/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(207); +pattern = /abb$/; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(208); +pattern = /abb\Z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(209); +pattern = /abb\z/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(210); +pattern = /abb$/; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(211); +pattern = /abb\Z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(212); +pattern = /abb\z/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(213); +pattern = /abb$/m; +string = 'ac\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(214); +pattern = /abb\Z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(215); +pattern = /abb\z/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(216); +pattern = /abb$/m; +string = 'b\nac\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(217); +pattern = /abb\Z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(218); +pattern = /abb\z/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(219); +pattern = /abb$/m; +string = 'b\nac'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(220); +pattern = /abb\Z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(221); +pattern = /abb\z/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(222); +pattern = /abb$/; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(223); +pattern = /abb\Z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(224); +pattern = /abb\z/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(225); +pattern = /abb$/; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(226); +pattern = /abb\Z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(227); +pattern = /abb\z/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(228); +pattern = /abb$/; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(229); +pattern = /abb\Z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(230); +pattern = /abb\z/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(231); +pattern = /abb$/m; +string = 'ca\nb\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(232); +pattern = /abb\Z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(233); +pattern = /abb\z/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(234); +pattern = /abb$/m; +string = 'b\nca\n'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(235); +pattern = /abb\Z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(236); +pattern = /abb\z/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(237); +pattern = /abb$/m; +string = 'b\nca'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(238); +pattern = /a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz/; +string = 'x'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(239); +pattern = /\GX.*X/; +string = 'aaaXbX'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(240); +pattern = /\.c(pp|xx|c)?$/i; +string = 'Changes'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(241); +pattern = /^([a-z]:)/; +string = 'C:/'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(242); +pattern = /(\w)?(abc)\1b/; +string = 'abcab'; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +/* ECMA doesn't support (?( + status = inSection(243); + pattern = /^(a)?(?(1)a|b)+$/; + string = 'a'; + actualmatch = string.match(pattern); + expectedmatch = null; + addThis(); +*/ + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + if(omitCurrentSection()) + return; + + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function omitCurrentSection() +{ + try + { + // current section number is in global status variable + var n = status.match(/(\d+)/)[1]; + return ((n < cnLBOUND) || (n > cnUBOUND)); + } + catch(e) + { + return false; + } +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-100199.js b/js/src/tests/ecma_3/RegExp/regress-100199.js new file mode 100644 index 000000000..2c162677b --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-100199.js @@ -0,0 +1,273 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 17 September 2001 + * + * SUMMARY: Regression test for Bugzilla bug 100199 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=100199 + * + * The empty character class [] is a valid RegExp construct: the condition + * that a given character belong to a set containing no characters. As such, + * it can never be met and is always FALSE. Similarly, [^] is a condition + * that matches any given character and is always TRUE. + * + * Neither one of these conditions should cause syntax errors in a RegExp. + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 100199; +var summary = '[], [^] are valid RegExp conditions. Should not cause errors -'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /[]/; +string = 'abc'; +status = inSection(1); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ''; +status = inSection(2); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '['; +status = inSection(3); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '/'; +status = inSection(4); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '['; +status = inSection(5); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ']'; +status = inSection(6); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '[]'; +status = inSection(7); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '[ ]'; +status = inSection(8); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ']['; +status = inSection(9); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +pattern = /a[]/; +string = 'abc'; +status = inSection(10); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ''; +status = inSection(11); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = 'a['; +status = inSection(12); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = 'a[]'; +status = inSection(13); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '['; +status = inSection(14); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ']'; +status = inSection(15); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '[]'; +status = inSection(16); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = '[ ]'; +status = inSection(17); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +string = ']['; +status = inSection(18); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +pattern = /[^]/; +string = 'abc'; +status = inSection(19); +actualmatch = string.match(pattern); +expectedmatch = Array('a'); +addThis(); + +string = ''; +status = inSection(20); +actualmatch = string.match(pattern); +expectedmatch = null; //there are no characters to test against the condition +addThis(); + +string = '\/'; +status = inSection(21); +actualmatch = string.match(pattern); +expectedmatch = Array('/'); +addThis(); + +string = '\['; +status = inSection(22); +actualmatch = string.match(pattern); +expectedmatch = Array('['); +addThis(); + +string = '['; +status = inSection(23); +actualmatch = string.match(pattern); +expectedmatch = Array('['); +addThis(); + +string = ']'; +status = inSection(24); +actualmatch = string.match(pattern); +expectedmatch = Array(']'); +addThis(); + +string = '[]'; +status = inSection(25); +actualmatch = string.match(pattern); +expectedmatch = Array('['); +addThis(); + +string = '[ ]'; +status = inSection(26); +actualmatch = string.match(pattern); +expectedmatch = Array('['); +addThis(); + +string = ']['; +status = inSection(27); +actualmatch = string.match(pattern); +expectedmatch = Array(']'); +addThis(); + + +pattern = /a[^]/; +string = 'abc'; +status = inSection(28); +actualmatch = string.match(pattern); +expectedmatch = Array('ab'); +addThis(); + +string = ''; +status = inSection(29); +actualmatch = string.match(pattern); +expectedmatch = null; //there are no characters to test against the condition +addThis(); + +string = 'a['; +status = inSection(30); +actualmatch = string.match(pattern); +expectedmatch = Array('a['); +addThis(); + +string = 'a]'; +status = inSection(31); +actualmatch = string.match(pattern); +expectedmatch = Array('a]'); +addThis(); + +string = 'a[]'; +status = inSection(32); +actualmatch = string.match(pattern); +expectedmatch = Array('a['); +addThis(); + +string = 'a[ ]'; +status = inSection(33); +actualmatch = string.match(pattern); +expectedmatch = Array('a['); +addThis(); + +string = 'a]['; +status = inSection(34); +actualmatch = string.match(pattern); +expectedmatch = Array('a]'); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-105972.js b/js/src/tests/ecma_3/RegExp/regress-105972.js new file mode 100644 index 000000000..4d08fa447 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-105972.js @@ -0,0 +1,123 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 22 October 2001 + * + * SUMMARY: Regression test for Bugzilla bug 105972: + * "/^.*?$/ will not match anything" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=105972 + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 105972; +var summary = 'Regression test for Bugzilla bug 105972'; +var cnEmptyString = ''; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * The bug: this match was coming up null in Rhino and SpiderMonkey. + * It should match the whole string. The reason: + * + * The * operator is greedy, but *? is non-greedy: it will stop + * at the simplest match it can find. But the pattern here asks us + * to match till the end of the string. So the simplest match must + * go all the way out to the end, and *? has no choice but to do it. + */ +status = inSection(1); +pattern = /^.*?$/; +string = 'Hello World'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + + +/* + * Leave off the '$' condition - here we expect the empty string. + * Unlike the above pattern, we don't have to match till the end of + * the string, so the non-greedy operator *? doesn't try to... + */ +status = inSection(2); +pattern = /^.*?/; +string = 'Hello World'; +actualmatch = string.match(pattern); +expectedmatch = Array(cnEmptyString); +addThis(); + + +/* + * Try '$' combined with an 'or' operator. + * + * The operator *? will consume the string from left to right, + * attempting to satisfy the condition (:|$). When it hits ':', + * the match will stop because the operator *? is non-greedy. + * + * The submatch $1 = (:|$) will contain the ':' + */ +status = inSection(3); +pattern = /^.*?(:|$)/; +string = 'Hello: World'; +actualmatch = string.match(pattern); +expectedmatch = Array('Hello:', ':'); +addThis(); + + +/* + * Again, '$' combined with an 'or' operator. + * + * The operator * will consume the string from left to right, + * attempting to satisfy the condition (:|$). When it hits ':', + * the match will not stop since * is greedy. The match will + * continue until it hits $, the end-of-string boundary. + * + * The submatch $1 = (:|$) will contain the empty string + * conceived to exist at the end-of-string boundary. + */ +status = inSection(4); +pattern = /^.*(:|$)/; +string = 'Hello: World'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, cnEmptyString); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-119909.js b/js/src/tests/ecma_3/RegExp/regress-119909.js new file mode 100644 index 000000000..f0d3d08f0 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-119909.js @@ -0,0 +1,58 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 14 Jan 2002 + * SUMMARY: Shouldn't crash on regexps with many nested parentheses + * See http://bugzilla.mozilla.org/show_bug.cgi?id=119909 + * + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = 119909; +var summary = "Shouldn't crash on regexps with many nested parentheses"; +var NO_BACKREFS = false; +var DO_BACKREFS = true; + + +//-------------------------------------------------- +test(); +//-------------------------------------------------- + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + testThis(500, NO_BACKREFS, 'hello', 'goodbye'); + testThis(500, DO_BACKREFS, 'hello', 'goodbye'); + + reportCompare('No Crash', 'No Crash', ''); + + exitFunc('test'); +} + + +/* + * Creates a regexp pattern like (((((((((hello))))))))) + * and tests str.search(), str.match(), str.replace() + */ +function testThis(numParens, doBackRefs, strOriginal, strReplace) +{ + var openParen = doBackRefs? '(' : '(?:'; + var closeParen = ')'; + var pattern = ''; + + for (var i=0; i((.*\n?)*?)<\/body>/i; +actualmatch = string.match(pattern); +expectedmatch = Array(sBody, '\n

Kibology for all

\n

All for Kibology

\n', '

All for Kibology

\n'); +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-169534.js b/js/src/tests/ecma_3/RegExp/regress-169534.js new file mode 100644 index 000000000..7c9d62135 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-169534.js @@ -0,0 +1,61 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 20 Sep 2002 + * SUMMARY: RegExp conformance test + * See http://bugzilla.mozilla.org/show_bug.cgi?id=169534 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 169534; +var summary = 'RegExp conformance test'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +status = inSection(1); +var re = /(\|)([\w\x81-\xff ]*)(\|)([\/a-z][\w:\/\.]*\.[a-z]{3,4})(\|)/ig; +var str = "To sign up click |here|https://www.xxxx.org/subscribe.htm|"; +actual = str.replace(re, '$2'); +expect = 'To sign up click here'; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i/g,'>'); + } + + h+='\n'; + h=h.replace(/&([^\s]+;)/g,'<&$1>'); + h=h.replace(new RegExp('','g'), S); + h=h.replace(/"[^"]*"/g,S); + h=h.replace(/'[^']*'/g,S); + + + h=h.replace(/<([^>]*)>/g, + function(s,p) + { + if(s.match(/!doctype/i)) + return'<' + p + '>'; + + p=p.replace(/\\'/g,'\\'').replace(/\\"/g,'\\"').replace(/^\s/,''); +p=p.replace(/(\s)([^<]+)$/g, + function(s,p1,p2) + { + p2=p2.replace(/(=)(\s*[^"'][^\s]*)(\s|$)/g,'$1$2$3'); + p2=p2.replace(/("[^"]*")/g,'$1'); + p2=p2.replace(/('[^']*')/g,'$1'); + return p1 + ''+p2+''; + } + ) + + return'<' + p + '>'; + } + ) + + + h=h.replace(/<(&[^\s]+;)>/g,'$1'); + h=h.replace(/(<!--[\s\S]*-->)/g,'$1'); + + + numer=1; + h=h.replace(/(.*\n)/g, + function(s,p) + { + return (numer++) +'. ' + p; + } + ) + + + return'' + h + ''; +} + + + +/* + * sanity check + */ +status = inSection(1); +actual = formatHTML('abc'); +expect = '1. abc\n'; +addThis(); + + +/* + * The real test: can we run this without crashing? + * We are not validating the result, just running it. + */ +status = inSection(2); +var HUGE_TEST_STRING = hugeString(); +formatHTML(HUGE_TEST_STRING); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i])*-->', 'g'), ''); +printStatus(data); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/RegExp/regress-309840.js b/js/src/tests/ecma_3/RegExp/regress-309840.js new file mode 100644 index 000000000..ff1e5927c --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-309840.js @@ -0,0 +1,24 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 309840; +var summary = 'Treat / in a literal regexp class as valid'; +var actual = 'No error'; +var expect = 'No error'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + var re = eval('/[/]/'); +} +catch(e) +{ + actual = e.toString(); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/RegExp/regress-312351.js b/js/src/tests/ecma_3/RegExp/regress-312351.js new file mode 100644 index 000000000..72a52a183 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-312351.js @@ -0,0 +1,17 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 312351; +var summary = 'Do not crash on RegExp(null)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var x = RegExp(null); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/RegExp/regress-31316.js b/js/src/tests/ecma_3/RegExp/regress-31316.js new file mode 100644 index 000000000..fc6fd94e3 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-31316.js @@ -0,0 +1,62 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 01 May 2001 + * + * SUMMARY: Regression test for Bugzilla bug 31316: + * "Rhino: Regexp matches return garbage" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=31316 + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 31316; +var summary = 'Regression test for Bugzilla bug 31316'; +var cnEmptyString = ''; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /<([^\/<>][^<>]*[^\/])>|<([^\/<>])>/; +string = '

Some
test

'; +actualmatch = string.match(pattern); +expectedmatch = Array('

', undefined, 'p'); +addThis(); + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-330684.js b/js/src/tests/ecma_3/RegExp/regress-330684.js new file mode 100644 index 000000000..f6a3bb760 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-330684.js @@ -0,0 +1,21 @@ +// |reftest| skip -- slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 330684; +var summary = 'Do not hang on RegExp'; +var actual = 'Do not hang on RegExp'; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var re = /^(?:(?:%[0-9A-Fa-f]{2})*[!\$&'\*-;=\?-Z_a-z]*)+$/; +var url = "http://tw.yimg.com/a/tw/wenchuan/cam_240x400_381615_030806_2.swf?clickTAG=javascript:VRECopenWindow(1)"; + +printStatus(re.test(url)); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/RegExp/regress-334158.js b/js/src/tests/ecma_3/RegExp/regress-334158.js new file mode 100644 index 000000000..a56144553 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-334158.js @@ -0,0 +1,25 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 334158; +var summary = 'Parse error in control letter escapes (RegExp)'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +expect = true; +actual = /\ca/.test( "\x01" ); +reportCompare(expect, actual, summary + ':/\ca/.test( "\x01" )'); + +expect = false + actual = /\ca/.test( "\\ca" ); +reportCompare(expect, actual, summary + ': /\ca/.test( "\\ca" )'); + +expect = false + actual = /\c[a/]/.test( "\x1ba/]" ); +reportCompare(expect, actual, summary + ': /\c[a/]/.test( "\x1ba/]" )'); diff --git a/js/src/tests/ecma_3/RegExp/regress-346090.js b/js/src/tests/ecma_3/RegExp/regress-346090.js new file mode 100644 index 000000000..265c3e8d8 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-346090.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346090; +var summary = 'Do not crash with this regexp'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var r = /%((h[^l]+)|(l[^h]+)){0,2}?a/g; + r.exec('%lld %d'); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-367888.js b/js/src/tests/ecma_3/RegExp/regress-367888.js new file mode 100644 index 000000000..d2e7529b6 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-367888.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 367888; +var summary = 'RegExp /(|)??x/g.exec("y") barfs'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = null; + actual = /(|)??x/g.exec("y"); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-375642.js b/js/src/tests/ecma_3/RegExp/regress-375642.js new file mode 100644 index 000000000..267abde7a --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-375642.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375642; +var summary = 'RegExp /(?:a??)+?/.exec("")'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + /(?:a??)+?/.exec("") + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-375651.js b/js/src/tests/ecma_3/RegExp/regress-375651.js new file mode 100644 index 000000000..8c8aa05c7 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-375651.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375651; +var summary = 'Do not assert with regexp quantifiers'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + /(.{2,3}){0,2}?t/.exec("abt"); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-375711.js b/js/src/tests/ecma_3/RegExp/regress-375711.js new file mode 100644 index 000000000..420b8ba49 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-375711.js @@ -0,0 +1,85 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375711; +var summary = 'Do not assert with /[Q-b]/i.exec("")'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var s; + + // see bug 416933 + print('see bug 416933 for changed behavior on Gecko 1.9'); + + try + { + s = '/[Q-b]/.exec("")'; + expect = 'No Error'; + print(s + ' expect ' + expect); + eval(s); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + s); + + try + { + s ='/[Q-b]/i.exec("")'; + expect = 'No Error'; + print(s + ' expect ' + expect); + eval(s); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + s); + + try + { + s = '/[q-b]/.exec("")'; + expect = 'SyntaxError: invalid range in character class'; + print(s + ' expect ' + expect); + eval(s); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + s); + + try + { + s ='/[q-b]/i.exec("")'; + expect = 'SyntaxError: invalid range in character class'; + print(s + ' expect ' + expect); + eval(s); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + s); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-375715-01-n.js b/js/src/tests/ecma_3/RegExp/regress-375715-01-n.js new file mode 100644 index 000000000..dbb988ea7 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-375715-01-n.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375715; +var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + // note that the assertion does not fire if the regexp is + // evald or used in new RegExp, so this test must be an -n + // with uncaught SyntaxError. + + /[\Wb-G]/.exec(""); + reportCompare(expect, actual, summary + ' /[\Wb-G]/.exec("")'); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-375715-02.js b/js/src/tests/ecma_3/RegExp/regress-375715-02.js new file mode 100644 index 000000000..7d1965ab6 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-375715-02.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375715; +var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + /[\s-:]/; + reportCompare(expect, actual, summary + '/[\s-:]/'); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-375715-03.js b/js/src/tests/ecma_3/RegExp/regress-375715-03.js new file mode 100644 index 000000000..f701997e6 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-375715-03.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375715; +var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + /[_-t]/i.exec(""); + reportCompare(expect, actual, summary + '/[_-t]/i.exec("")'); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-375715-04.js b/js/src/tests/ecma_3/RegExp/regress-375715-04.js new file mode 100644 index 000000000..bb37474b3 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-375715-04.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375715; +var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + expect = 'SyntaxError: invalid range in character class'; + (new RegExp("[\xDF-\xC7]]", "i")).exec(""); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + '(new RegExp("[\xDF-\xC7]]", "i")).exec("")'); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-436700.js b/js/src/tests/ecma_3/RegExp/regress-436700.js new file mode 100644 index 000000000..d595b0182 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-436700.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 436700; +var summary = 'Do not assert: 1 <= num && num <= 0x10000'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + /\2147483648/.exec(String.fromCharCode(140) + "7483648").toString(); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-465862.js b/js/src/tests/ecma_3/RegExp/regress-465862.js new file mode 100644 index 000000000..e771e68f1 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-465862.js @@ -0,0 +1,82 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465862; +var summary = 'Do case-insensitive matching correctly in JIT for non-ASCII-letters'; + +var i = 0; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + +// Note: we must call the RegExp constructor here instead of using +// literals. Otherwise, because the regexps are compiled at parse +// time, they will not be compiled to native code and we will not +// actually be testing jitted regexps. + + +status = inSection(1); +string = '@'; +pattern = new RegExp('@', 'i'); +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + +status = inSection(2); +string = '`'; +pattern = new RegExp('`', 'i'); +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + +status = inSection(3); +string = '@'; +pattern = new RegExp('`', 'i'); +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(4); +string = '`'; +pattern = new RegExp('@', 'i'); +print(string + ' ' + pattern); +actualmatch = string.match(pattern); +print('z ' + actualmatch); +print('`'.match(/@/i)); +expectedmatch = null; +addThis(); + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-57572.js b/js/src/tests/ecma_3/RegExp/regress-57572.js new file mode 100644 index 000000000..3f1383f10 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-57572.js @@ -0,0 +1,116 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 28 December 2000 + * + * SUMMARY: Testing regular expressions containing the ? character. + * Arose from Bugzilla bug 57572: "RegExp with ? matches incorrectly" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=57572 + * + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 57572; +var summary = 'Testing regular expressions containing "?"'; +var cnEmptyString = ''; var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +status = inSection(1); +pattern = /(\S+)?(.*)/; +string = 'Test this'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Test', ' this'); //single space in front of 'this' +addThis(); + +status = inSection(2); +pattern = /(\S+)? ?(.*)/; //single space between the ? characters +string= 'Test this'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Test', 'this'); //NO space in front of 'this' +addThis(); + +status = inSection(3); +pattern = /(\S+)?(.*)/; +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', ' phrase, with six - (short) words'); //single space in front of 'phrase' +addThis(); + +status = inSection(4); +pattern = /(\S+)? ?(.*)/; //single space between the ? characters +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', 'phrase, with six - (short) words'); //NO space in front of 'phrase' +addThis(); + + +// let's add an extra back-reference this time - three instead of two - +status = inSection(5); +pattern = /(\S+)?( ?)(.*)/; //single space before second ? character +string = 'Stupid phrase, with six - (short) words'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'Stupid', cnSingleSpace, 'phrase, with six - (short) words'); +addThis(); + +status = inSection(6); +pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character +string = 'AAABBB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAABB', cnEmptyString, 'B'); +addThis(); + +status = inSection(7); +pattern = /(\S+)?(!?)(.*)/; +string = 'WOW !!! !!!'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'WOW', cnEmptyString, ' !!! !!!'); +addThis(); + +status = inSection(8); +pattern = /(.+)?(!?)(!+)/; +string = 'WOW !!! !!!'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'WOW !!! !!', cnEmptyString, '!'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-57631.js b/js/src/tests/ecma_3/RegExp/regress-57631.js new file mode 100644 index 000000000..5995fe496 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-57631.js @@ -0,0 +1,118 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 26 November 2000 + * + * + * SUMMARY: This test arose from Bugzilla bug 57631: + * "RegExp with invalid pattern or invalid flag causes segfault" + * + * Either error should throw an exception of type SyntaxError, + * and we check to see that it does... + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = '57631'; +var summary = 'Testing new RegExp(pattern,flag) with illegal pattern or flag'; +var statprefix = 'Testing for error creating illegal RegExp object on pattern '; +var statsuffix = 'and flag '; +var cnSUCCESS = 'SyntaxError'; +var cnFAILURE = 'not a SyntaxError'; +var singlequote = "'"; +var i = -1; var j = -1; var s = ''; var f = ''; +var obj = {}; +var status = ''; var actual = ''; var expect = ''; var msg = ''; +var legalpatterns = new Array(); var illegalpatterns = new Array(); +var legalflags = new Array(); var illegalflags = new Array(); + + +// valid regular expressions to try - +legalpatterns[0] = ''; +legalpatterns[1] = 'abc'; +legalpatterns[2] = '(.*)(3-1)\s\w'; +legalpatterns[3] = '(.*)(...)\\s\\w'; +legalpatterns[4] = '[^A-Za-z0-9_]'; +legalpatterns[5] = '[^\f\n\r\t\v](123.5)([4 - 8]$)'; + +// invalid regular expressions to try - +illegalpatterns[0] = '(?)'; +illegalpatterns[1] = '(a'; +illegalpatterns[2] = '( ]'; +//illegalpatterns[3] = '\d{1,s}'; + +// valid flags to try - +legalflags[0] = 'i'; +legalflags[1] = 'g'; +legalflags[2] = 'm'; +legalflags[3] = undefined; + +// invalid flags to try - +illegalflags[0] = 'a'; +illegalflags[1] = 123; +illegalflags[2] = new RegExp(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + testIllegalRegExps(legalpatterns, illegalflags); + testIllegalRegExps(illegalpatterns, legalflags); + testIllegalRegExps(illegalpatterns, illegalflags); + + exitFunc ('test'); +} + + +// This function will only be called where all the patterns are illegal, or all the flags +function testIllegalRegExps(patterns, flags) +{ + for (i in patterns) + { + s = patterns[i]; + + for (j in flags) + { + f = flags[j]; + status = getStatus(s, f); + actual = cnFAILURE; + expect = cnSUCCESS; + + try + { + // This should cause an exception if either s or f is illegal - + eval('obj = new RegExp(s, f);'); + } + catch(e) + { + // We expect to get a SyntaxError - test for this: + if (e instanceof SyntaxError) + actual = cnSUCCESS; + } + + reportCompare(expect, actual, status); + } + } +} + + +function getStatus(regexp, flag) +{ + return (statprefix + quote(regexp) + statsuffix + quote(flag)); +} + + +function quote(text) +{ + return (singlequote + text + singlequote); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-67773.js b/js/src/tests/ecma_3/RegExp/regress-67773.js new file mode 100644 index 000000000..68cdae681 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-67773.js @@ -0,0 +1,177 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 06 February 2001 + * + * SUMMARY: Arose from Bugzilla bug 67773: + * "Regular subexpressions followed by + failing to run to completion" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=67773 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 67773; +var summary = 'Testing regular subexpressions followed by ? or +\n'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character +status = inSection(1); +string = 'AAABBB AAABBB '; //single space at middle and at end - +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(2); +string = 'AAABBB BBB'; //single space in the middle +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAABBB', cnSingleSpace, 'BBB'); +addThis(); + +status = inSection(3); +string = 'AAABBB AAABBB'; //single space in the middle +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + +pattern = /^(A+B)+$/; +status = inSection(4); +string = 'AABAAB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAB'); +addThis(); + +status = inSection(5); +string = 'ABAABAAAAAAB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AAAAAAB'); +addThis(); + +status = inSection(6); +string = 'ABAABAABAB'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AB'); +addThis(); + +status = inSection(7); +string = 'ABAABAABABB'; +actualmatch = string.match(pattern); +expectedmatch = null; // because string doesn't match at end +addThis(); + + +pattern = /^(A+1)+$/; +status = inSection(8); +string = 'AA1AA1'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'AA1'); +addThis(); + + +pattern = /^(\w+\-)+$/; +status = inSection(9); +string = ''; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(10); +string = 'bla-'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, string); +addThis(); + +status = inSection(11); +string = 'bla-bla'; // hyphen missing at end - +actualmatch = string.match(pattern); +expectedmatch = null; //because string doesn't match at end +addThis(); + +status = inSection(12); +string = 'bla-bla-'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'bla-'); +addThis(); + + +pattern = /^(\S+)+(A+)$/; +status = inSection(13); +string = 'asdldflkjAAA'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'asdldflkjAA', 'A'); +addThis(); + +status = inSection(14); +string = 'asdldflkj AAA'; // space in middle +actualmatch = string.match(pattern); +expectedmatch = null; //because of the space +addThis(); + + +pattern = /^(\S+)+(\d+)$/; +status = inSection(15); +string = 'asdldflkj122211'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'asdldflkj12221', '1'); +addThis(); + +status = inSection(16); +string = 'asdldflkj1111111aaa1'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, 'asdldflkj1111111aaa', '1'); +addThis(); + + +/* + * This one comes from Stephen Ostermiller. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 + */ +pattern = /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/; +status = inSection(17); +string = 'some.host.tld'; +actualmatch = string.match(pattern); +expectedmatch = Array(string, '.tld', '.'); +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-72964.js b/js/src/tests/ecma_3/RegExp/regress-72964.js new file mode 100644 index 000000000..b41b74c32 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-72964.js @@ -0,0 +1,87 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 2001-07-17 + * + * SUMMARY: Regression test for Bugzilla bug 72964: + * "String method for pattern matching failed for Chinese Simplified (GB2312)" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=72964 + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 72964; +var summary = 'Testing regular expressions containing non-Latin1 characters'; +var cnSingleSpace = ' '; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /[\S]+/; +// 4 low Unicode chars = Latin1; whole string should match +status = inSection(1); +string = '\u00BF\u00CD\u00BB\u00A7'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + +// Now put a space in the middle; first half of string should match +status = inSection(2); +string = '\u00BF\u00CD \u00BB\u00A7'; +actualmatch = string.match(pattern); +expectedmatch = Array('\u00BF\u00CD'); +addThis(); + + +// 4 high Unicode chars = non-Latin1; whole string should match +status = inSection(3); +string = '\u4e00\uac00\u4e03\u4e00'; +actualmatch = string.match(pattern); +expectedmatch = Array(string); +addThis(); + +// Now put a space in the middle; first half of string should match +status = inSection(4); +string = '\u4e00\uac00 \u4e03\u4e00'; +actualmatch = string.match(pattern); +expectedmatch = Array('\u4e00\uac00'); +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-76683.js b/js/src/tests/ecma_3/RegExp/regress-76683.js new file mode 100644 index 000000000..8b8406441 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-76683.js @@ -0,0 +1,80 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 01 May 2001 + * + * SUMMARY: Regression test for Bugzilla bug 76683 on Rhino: + * "RegExp regression (NullPointerException)" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=76683 + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 76683; +var summary = 'Regression test for Bugzilla bug 76683'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +/* + * Rhino (2001-04-19) crashed on the 3rd regular expression below. + * It didn't matter what the string was. No problem in SpiderMonkey - + */ +string = 'abc'; +status = inSection(1); +pattern = /()|(<([\$\w:\.\-]+)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))/; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +status = inSection(2); +pattern = /()|(<(tagPattern)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))/; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + +// This was the one causing a Rhino crash - +status = inSection(3); +pattern = /()|(<(tagPattern)((([ ][^\/>]*)?\/>)|(([ ][^>]*)?>)))|(<\/tagPattern[^>]*>)/; +actualmatch = string.match(pattern); +expectedmatch = null; +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-78156.js b/js/src/tests/ecma_3/RegExp/regress-78156.js new file mode 100644 index 000000000..0bd990977 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-78156.js @@ -0,0 +1,89 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 06 February 2001 + * + * SUMMARY: Arose from Bugzilla bug 78156: + * "m flag of regular expression does not work with $" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=78156 + * + * The m flag means a regular expression should search strings + * across multiple lines, i.e. across '\n', '\r'. + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 78156; +var summary = 'Testing regular expressions with ^, $, and the m flag -'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + +/* + * All patterns have an m flag; all strings are multiline. + * Looking for digit characters at beginning/end of lines. + */ + +string = 'aaa\n789\r\nccc\r\n345'; +status = inSection(1); +pattern = /^\d/gm; +actualmatch = string.match(pattern); +expectedmatch = ['7','3']; +addThis(); + +status = inSection(2); +pattern = /\d$/gm; +actualmatch = string.match(pattern); +expectedmatch = ['9','5']; +addThis(); + +string = 'aaa\n789\r\nccc\r\nddd'; +status = inSection(3); +pattern = /^\d/gm; +actualmatch = string.match(pattern); +expectedmatch = ['7']; +addThis(); + +status = inSection(4); +pattern = /\d$/gm; +actualmatch = string.match(pattern); +expectedmatch = ['9']; +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-85721.js b/js/src/tests/ecma_3/RegExp/regress-85721.js new file mode 100644 index 000000000..e04ae97f3 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-85721.js @@ -0,0 +1,243 @@ +// |reftest| random -- bogus perf test (bug 467263) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 14 Feb 2002 + * SUMMARY: Performance: Regexp performance degraded from 4.7 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=85721 + * + * Adjust this testcase if necessary. The FAST constant defines + * an upper bound in milliseconds for any execution to take. + * + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = 85721; +var summary = 'Performance: execution of regular expression'; +var FAST = 100; // execution should be 100 ms or less to pass the test +var MSG_FAST = 'Execution took less than ' + FAST + ' ms'; +var MSG_SLOW = 'Execution took '; +var MSG_MS = ' ms'; +var str = ''; +var re = ''; +var status = ''; +var actual = ''; +var expect= ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +function elapsedTime(startTime) +{ + return new Date() - startTime; +} + + +function isThisFast(ms) +{ + if (ms <= FAST) + return MSG_FAST; + return MSG_SLOW + ms + MSG_MS; +} + + + +/* + * The first regexp. We'll test for performance (Section 1) and accuracy (Section 2). + */ +str=' www.m.com drive.class\nfoo goo '; +re = /\s*\s*([^\r\n]*?)\s*<\/sql:url>\s*\s*([^\r\n]*?)\s*<\/sql:driver>\s*(\s*\s*([^\r\n]*?)\s*<\/sql:userId>\s*)?\s*(\s*\s*([^\r\n]*?)\s*<\/sql:password>\s*)?\s*<\/sql:connection>/; +expect = Array(" www.m.com drive.class\nfoo goo ","conn1","www.m.com","drive.class","foo ","foo","goo ","goo"); + +/* + * Check performance - + */ +status = inSection(1); +var start = new Date(); +var result = re.exec(str); +actual = elapsedTime(start); +reportCompare(isThisFast(FAST), isThisFast(actual), status); + +/* + * Check accuracy - + */ +status = inSection(2); +testRegExp([status], [re], [str], [result], [expect]); + + + +/* + * The second regexp (HUGE!). We'll test for performance (Section 3) and accuracy (Section 4). + * It comes from the O'Reilly book "Mastering Regular Expressions" by Jeffrey Friedl, Appendix B + */ + +//# Some things for avoiding backslashitis later on. +$esc = '\\\\'; +$Period = '\.'; +$space = '\040'; $tab = '\t'; +$OpenBR = '\\['; $CloseBR = '\\]'; +$OpenParen = '\\('; $CloseParen = '\\)'; +$NonASCII = '\x80-\xff'; $ctrl = '\000-\037'; +$CRlist = '\n\015'; //# note: this should really be only \015. +// Items 19, 20, 21 +$qtext = '[^' + $esc + $NonASCII + $CRlist + '\"]'; // # for within "..." +$dtext = '[^' + $esc + $NonASCII + $CRlist + $OpenBR + $CloseBR + ']'; // # for within [...] +$quoted_pair = $esc + '[^' + $NonASCII + ']'; // # an escaped character + +//############################################################################## +//# Items 22 and 23, comment. +//# Impossible to do properly with a regex, I make do by allowing at most one level of nesting. +$ctext = '[^' + $esc + $NonASCII + $CRlist + '()]'; + +//# $Cnested matches one non-nested comment. +//# It is unrolled, with normal of $ctext, special of $quoted_pair. +$Cnested = + $OpenParen + // # ( + $ctext + '*' + // # normal* + '(?:' + $quoted_pair + $ctext + '*)*' + // # (special normal*)* + $CloseParen; // # ) + + +//# $comment allows one level of nested parentheses +//# It is unrolled, with normal of $ctext, special of ($quoted_pair|$Cnested) +$comment = + $OpenParen + // # ( + $ctext + '*' + // # normal* + '(?:' + // # ( + '(?:' + $quoted_pair + '|' + $Cnested + ')' + // # special + $ctext + '*' + // # normal* + ')*' + // # )* + $CloseParen; // # ) + + +//############################################################################## +//# $X is optional whitespace/comments. +$X = + '[' + $space + $tab + ']*' + // # Nab whitespace. + '(?:' + $comment + '[' + $space + $tab + ']*)*'; // # If comment found, allow more spaces. + + +//# Item 10: atom +$atom_char = '[^(' + $space + '<>\@,;:\".' + $esc + $OpenBR + $CloseBR + $ctrl + $NonASCII + ']'; +$atom = + $atom_char + '+' + // # some number of atom characters... + '(?!' + $atom_char + ')'; // # ..not followed by something that could be part of an atom + +// # Item 11: doublequoted string, unrolled. +$quoted_str = + '\"' + // # " + $qtext + '*' + // # normal + '(?:' + $quoted_pair + $qtext + '*)*' + // # ( special normal* )* + '\"'; // # " + +//# Item 7: word is an atom or quoted string +$word = + '(?:' + + $atom + // # Atom + '|' + // # or + $quoted_str + // # Quoted string + ')' + +//# Item 12: domain-ref is just an atom + $domain_ref = $atom; + +//# Item 13: domain-literal is like a quoted string, but [...] instead of "..." +$domain_lit = + $OpenBR + // # [ + '(?:' + $dtext + '|' + $quoted_pair + ')*' + // # stuff + $CloseBR; // # ] + +// # Item 9: sub-domain is a domain-ref or domain-literal +$sub_domain = + '(?:' + + $domain_ref + + '|' + + $domain_lit + + ')' + + $X; // # optional trailing comments + +// # Item 6: domain is a list of subdomains separated by dots. +$domain = + $sub_domain + + '(?:' + + $Period + $X + $sub_domain + + ')*'; + +//# Item 8: a route. A bunch of "@ $domain" separated by commas, followed by a colon. +$route = + '\@' + $X + $domain + + '(?:,' + $X + '\@' + $X + $domain + ')*' + // # additional domains + ':' + + $X; // # optional trailing comments + +//# Item 6: local-part is a bunch of $word separated by periods +$local_part = + $word + $X + '(?:' + + $Period + $X + $word + $X + // # additional words + ')*'; + +// # Item 2: addr-spec is local@domain +$addr_spec = + $local_part + '\@' + $X + $domain; + +//# Item 4: route-addr is +$route_addr = + '<' + $X + // # < + '(?:' + $route + ')?' + // # optional route + $addr_spec + // # address spec + '>'; // # > + +//# Item 3: phrase........ +$phrase_ctrl = '\000-\010\012-\037'; // # like ctrl, but without tab + +//# Like atom-char, but without listing space, and uses phrase_ctrl. +//# Since the class is negated, this matches the same as atom-char plus space and tab +$phrase_char = + '[^()<>\@,;:\".' + $esc + $OpenBR + $CloseBR + $NonASCII + $phrase_ctrl + ']'; + +// # We've worked it so that $word, $comment, and $quoted_str to not consume trailing $X +// # because we take care of it manually. +$phrase = + $word + // # leading word + $phrase_char + '*' + // # "normal" atoms and/or spaces + '(?:' + + '(?:' + $comment + '|' + $quoted_str + ')' + // # "special" comment or quoted string + $phrase_char + '*' + // # more "normal" + ')*'; + +// ## Item #1: mailbox is an addr_spec or a phrase/route_addr +$mailbox = + $X + // # optional leading comment + '(?:' + + $phrase + $route_addr + // # name and address + '|' + // # or + $addr_spec + // # address + ')'; + + +//########################################################################### + + +re = new RegExp($mailbox, "g"); +str = 'Jeffy<"That Tall Guy"@ora.com (this address is no longer active)>'; +expect = Array('Jeffy<"That Tall Guy"@ora.com (this address is no longer active)>'); + +/* + * Check performance - + */ +status = inSection(3); +var start = new Date(); +var result = re.exec(str); +actual = elapsedTime(start); +reportCompare(isThisFast(FAST), isThisFast(actual), status); + +/* + * Check accuracy - + */ +status = inSection(4); +testRegExp([status], [re], [str], [result], [expect]); diff --git a/js/src/tests/ecma_3/RegExp/regress-87231.js b/js/src/tests/ecma_3/RegExp/regress-87231.js new file mode 100644 index 000000000..7f36519c1 --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-87231.js @@ -0,0 +1,111 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 22 June 2001 + * + * SUMMARY: Regression test for Bugzilla bug 87231: + * "Regular expression /(A)?(A.*)/ picks 'A' twice" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=87231 + * Key case: + * + * pattern = /^(A)?(A.*)$/; + * string = 'A'; + * expectedmatch = Array('A', '', 'A'); + * + * + * We expect the 1st subexpression (A)? NOT to consume the single 'A'. + * Recall that "?" means "match 0 or 1 times". Here, it should NOT do + * greedy matching: it should match 0 times instead of 1. This allows + * the 2nd subexpression to make the only match it can: the single 'A'. + * Such "altruism" is the only way there can be a successful global match... + */ +//----------------------------------------------------------------------------- +var i = 0; +var BUGNUMBER = 87231; +var cnEmptyString = ''; +var summary = 'Testing regular expression /(A)?(A.*)/'; +var status = ''; +var statusmessages = new Array(); +var pattern = ''; +var patterns = new Array(); +var string = ''; +var strings = new Array(); +var actualmatch = ''; +var actualmatches = new Array(); +var expectedmatch = ''; +var expectedmatches = new Array(); + + +pattern = /^(A)?(A.*)$/; +status = inSection(1); +string = 'AAA'; +actualmatch = string.match(pattern); +expectedmatch = Array('AAA', 'A', 'AA'); +addThis(); + +status = inSection(2); +string = 'AA'; +actualmatch = string.match(pattern); +expectedmatch = Array('AA', 'A', 'A'); +addThis(); + +status = inSection(3); +string = 'A'; +actualmatch = string.match(pattern); +expectedmatch = Array('A', undefined, 'A'); // 'altruistic' case: see above +addThis(); + + +pattern = /(A)?(A.*)/; +var strL = 'zxcasd;fl\\\ ^'; +var strR = 'aaAAaaaf;lrlrzs'; + +status = inSection(4); +string = strL + 'AAA' + strR; +actualmatch = string.match(pattern); +expectedmatch = Array('AAA' + strR, 'A', 'AA' + strR); +addThis(); + +status = inSection(5); +string = strL + 'AA' + strR; +actualmatch = string.match(pattern); +expectedmatch = Array('AA' + strR, 'A', 'A' + strR); +addThis(); + +status = inSection(6); +string = strL + 'A' + strR; +actualmatch = string.match(pattern); +expectedmatch = Array('A' + strR, undefined, 'A' + strR); // 'altruistic' case: see above +addThis(); + + + +//------------------------------------------------------------------------------------------------- +test(); +//------------------------------------------------------------------------------------------------- + + + +function addThis() +{ + statusmessages[i] = status; + patterns[i] = pattern; + strings[i] = string; + actualmatches[i] = actualmatch; + expectedmatches[i] = expectedmatch; + i++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/RegExp/regress-98306.js b/js/src/tests/ecma_3/RegExp/regress-98306.js new file mode 100644 index 000000000..fbe315acd --- /dev/null +++ b/js/src/tests/ecma_3/RegExp/regress-98306.js @@ -0,0 +1,65 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * Date: 04 September 2001 + * + * SUMMARY: Regression test for Bugzilla bug 98306 + * "JS parser crashes in ParseAtom for script using Regexp()" + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=98306 + */ +//----------------------------------------------------------------------------- +var BUGNUMBER = 98306; +var summary = "Testing that we don't crash on this code -"; +var cnUBOUND = 10; +var re; +var s; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + s = '"Hello".match(/[/]/)'; + tryThis(s); + + s = 're = /[/'; + tryThis(s); + + s = 're = /[/]/'; + tryThis(s); + + s = 're = /[//]/'; + tryThis(s); + + reportCompare('No Crash', 'No Crash', ''); + exitFunc ('test'); +} + + +// Try to provoke a crash - +function tryThis(sCode) +{ + // sometimes more than one attempt is necessary - + for (var i=0; i 5) + throw "bad"; + i++; + continue; + } + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Regress/regress-469937.js b/js/src/tests/ecma_3/Regress/regress-469937.js new file mode 100644 index 000000000..753735c15 --- /dev/null +++ b/js/src/tests/ecma_3/Regress/regress-469937.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469937; +var summary = 'Properties without DontEnum are sometimes not enumerated'; +var actual = false; +var expect = true; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +(function(){ + var o = { } + o.PageLeft = 1; + o.Rect2 = 6; + delete o.Rect2; + for (var p in o); + o.Rect3 = 7; + found = false; + for (var p in o) if (p == 'Rect3') found = true; + actual = found; +})(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/Regress/regress-580544.js b/js/src/tests/ecma_3/Regress/regress-580544.js new file mode 100644 index 000000000..4e0ca92f8 --- /dev/null +++ b/js/src/tests/ecma_3/Regress/regress-580544.js @@ -0,0 +1,30 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +var gTestfile = 'regress-580544.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 580544; +var summary = 'Do not assert: new (this.prototype = this)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try { + new (this.prototype = this); + } catch (e) { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Regress/shell.js b/js/src/tests/ecma_3/Regress/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/Statements/12.10-01.js b/js/src/tests/ecma_3/Statements/12.10-01.js new file mode 100644 index 000000000..031aac4ef --- /dev/null +++ b/js/src/tests/ecma_3/Statements/12.10-01.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 462734; +var summary = 'evaluating lhs "Reference" *before* evaluating rhs'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var x = 1; + var o = {}; + with (o) + x = o.x = 2; + print(x); + + expect = 4; + actual = x + o.x; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Statements/12.6.3.js b/js/src/tests/ecma_3/Statements/12.6.3.js new file mode 100644 index 000000000..a5092d750 --- /dev/null +++ b/js/src/tests/ecma_3/Statements/12.6.3.js @@ -0,0 +1,47 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 292731; +var summary = 'for-in should not call valueOf method'; +var actual = ''; +var expect = ''; +var i; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function MyObject() +{ +} + +MyObject.prototype.valueOf = function() +{ + actual += 'MyObject.prototype.valueOf called. '; +} + + var myobject = new MyObject(); + +var myfunction = new function() +{ + this.valueOf = function() + { + actual += 'this.valueOf called. '; + } +} + + actual = ''; +for (i in myobject) +{ + //calls valueOf +} +reportCompare(expect, actual, 'for-in custom object'); + +actual = ''; +for (i in myfunction) +{ + //calls valueOf +} +reportCompare(expect, actual, 'for-in function expression'); diff --git a/js/src/tests/ecma_3/Statements/browser.js b/js/src/tests/ecma_3/Statements/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/Statements/regress-121744.js b/js/src/tests/ecma_3/Statements/regress-121744.js new file mode 100644 index 000000000..369bc03cc --- /dev/null +++ b/js/src/tests/ecma_3/Statements/regress-121744.js @@ -0,0 +1,184 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 30 Jan 2002 + * Revised: 10 Apr 2002 + * Revised: 14 July 2002 + * + * SUMMARY: JS should error on |for(i in undefined)|, |for(i in null)| + * See http://bugzilla.mozilla.org/show_bug.cgi?id=121744 + * + * ECMA-262 3rd Edition Final spec says such statements should error. See: + * + * Section 12.6.4 The for-in Statement + * Section 9.9 ToObject + * + * + * BUT: SpiderMonkey has decided NOT to follow this; it's a bug in the spec. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=131348 + * + * UPDATE: Rhino has also decided not to follow the spec on this. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=136893 + * + + |--------------------------------------------------------------------| + | | + | So for now, adding an early return for this test so it won't run. | + | | + |--------------------------------------------------------------------| + + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 121744; +var summary = 'JS should error on |for(i in undefined)|, |for(i in null)|'; +var TEST_PASSED = 'TypeError'; +var TEST_FAILED = 'Generated an error, but NOT a TypeError!'; +var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + +/* + * AS OF 14 JULY 2002, DON'T RUN THIS TEST IN EITHER RHINO OR SPIDERMONKEY - + */ +quit(); + + +status = inSection(1); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * OK, this should generate a TypeError + */ +try +{ + for (var i in undefined) + { + print(i); + } +} +catch(e) +{ + if (e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + +status = inSection(2); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * OK, this should generate a TypeError + */ +try +{ + for (var i in null) + { + print(i); + } +} +catch(e) +{ + if (e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + +status = inSection(3); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * Variable names that cannot be looked up generate ReferenceErrors; however, + * property names like obj.ZZZ that cannot be looked up are set to |undefined| + * + * Therefore, this should indirectly test | for (var i in undefined) | + */ +try +{ + for (var i in this.ZZZ) + { + print(i); + } +} +catch(e) +{ + if(e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + +status = inSection(4); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * The result of an unsuccessful regexp match is the null value + * Therefore, this should indirectly test | for (var i in null) | + */ +try +{ + for (var i in 'bbb'.match(/aaa/)) + { + print(i); + } +} +catch(e) +{ + if(e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i 'aaZaa' + expect = strJim.replace(new RegExp(strA), strB); // expect 'aa$aaZ' + reportCompare(expect, actual, status); + + + * + * Note: 'Zabc' is the result we expect for 'abc'.replace('', 'Z'). + * + * The string '' is supposed to be equivalent to new RegExp('') = //. + * The regexp // means we should match the "empty string" conceived of + * at the beginning boundary of the word, before the first character. + * + status = 'Section F of test'; + strA = cnEmptyString; + actual = str.replace(strA, strB); + expect = 'Zabc'; + reportCompare(expect, actual, status); + + status = 'Section G of test'; + strA = cnEmptyString; + actual = str.replace(strA, strB); + expect = str.replace(new RegExp(strA), strB); + reportCompare(expect, actual, status); + + ************************* END OF INCORRECT CASES ****************************/ + + +////////////////////////// OK, LET'S START OVER ////////////////////////////// + + status = 'Section 1 of test'; + actual = 'abc'.replace('a', 'Z'); + expect = 'Zbc'; + reportCompare(expect, actual, status); + + status = 'Section 2 of test'; + actual = 'abc'.replace('b', 'Z'); + expect = 'aZc'; + reportCompare(expect, actual, status); + + status = 'Section 3 of test'; + actual = 'abc'.replace(undefined, 'Z'); + expect = 'abc'; // String(undefined) == 'undefined'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 4 of test'; + actual = 'abc'.replace(null, 'Z'); + expect = 'abc'; // String(null) == 'null'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 5 of test'; + actual = 'abc'.replace(true, 'Z'); + expect = 'abc'; // String(true) == 'true'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 6 of test'; + actual = 'abc'.replace(false, 'Z'); + expect = 'abc'; // String(false) == 'false'; no replacement possible + reportCompare(expect, actual, status); + + status = 'Section 7 of test'; + actual = 'aa$aa'.replace('$', 'Z'); + expect = 'aaZaa'; // NOT 'aa$aaZ' as in ECMA Final Draft; see above + reportCompare(expect, actual, status); + + status = 'Section 8 of test'; + actual = 'abc'.replace('.*', 'Z'); + expect = 'abc'; // not 'Z' as in EMCA Final Draft + reportCompare(expect, actual, status); + + status = 'Section 9 of test'; + actual = 'abc'.replace('', 'Z'); + expect = 'Zabc'; // Still expect 'Zabc' for this + reportCompare(expect, actual, status); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/String/shell.js b/js/src/tests/ecma_3/String/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/Unicode/browser.js b/js/src/tests/ecma_3/Unicode/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/Unicode/regress-352044-01.js b/js/src/tests/ecma_3/Unicode/regress-352044-01.js new file mode 100644 index 000000000..0c98d7267 --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/regress-352044-01.js @@ -0,0 +1,39 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352044; +var summary = 'issues with Unicode escape sequences in JavaScript source code'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'SyntaxError: illegal character'; + + try + { + var i = 1; + eval('i \\u002b= 1'); + print(i); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Unicode/regress-352044-02-n.js b/js/src/tests/ecma_3/Unicode/regress-352044-02-n.js new file mode 100644 index 000000000..ea975d4a4 --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/regress-352044-02-n.js @@ -0,0 +1,39 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352044; +var summary = 'issues with Unicode escape sequences in JavaScript source code'; +var actual = 'No Error'; +var expect = 'SyntaxError'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + print('This test case is expected to throw an uncaught SyntaxError'); + + try + { + var i = 1; + i \u002b= 1; + print(i); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/ecma_3/Unicode/shell.js b/js/src/tests/ecma_3/Unicode/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/ecma_3/Unicode/uc-001-n.js b/js/src/tests/ecma_3/Unicode/uc-001-n.js new file mode 100644 index 000000000..8ed4cfad6 --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/uc-001-n.js @@ -0,0 +1,26 @@ +/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode Characters 1C-1F negative test."); + printBugNumber (23612); + + reportCompare ("error", eval ("'no'\u001C+' error'"), + "Unicode whitespace test (1C.)"); + reportCompare ("error", eval ("'no'\u001D+' error'"), + "Unicode whitespace test (1D.)"); + reportCompare ("error", eval ("'no'\u001E+' error'"), + "Unicode whitespace test (1E.)"); + reportCompare ("error", eval ("'no'\u001F+' error'"), + "Unicode whitespace test (1F.)"); + + exitFunc ("test"); +} diff --git a/js/src/tests/ecma_3/Unicode/uc-001.js b/js/src/tests/ecma_3/Unicode/uc-001.js new file mode 100644 index 000000000..bfb8fd515 --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/uc-001.js @@ -0,0 +1,21 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode format-control character (Category Cf) test."); + printBugNumber (23610); + + reportCompare ("no error", eval('"no\u200E error"'), + "Unicode format-control character test (Category Cf.)"); + + exitFunc ("test"); +} diff --git a/js/src/tests/ecma_3/Unicode/uc-002-n.js b/js/src/tests/ecma_3/Unicode/uc-002-n.js new file mode 100644 index 000000000..0bf64bad8 --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/uc-002-n.js @@ -0,0 +1,19 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +DESCRIPTION = "Non-character escapes in identifiers negative test."; +EXPECTED = "error"; + +enterFunc ("test"); + +printStatus ("Non-character escapes in identifiers negative test."); +printBugNumber (23607); + +eval("\u0020 = 5"); +reportCompare('PASS', 'FAIL', "Previous statement should have thrown an error."); + +exitFunc ("test"); + diff --git a/js/src/tests/ecma_3/Unicode/uc-002.js b/js/src/tests/ecma_3/Unicode/uc-002.js new file mode 100644 index 000000000..6e33f1470 --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/uc-002.js @@ -0,0 +1,24 @@ +/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode non-breaking space character test."); + printBugNumber (23613); + + reportCompare ("no error", eval("'no'\u00A0+ ' error'"), + "Unicode non-breaking space character test."); + + var str = "\u00A0foo"; + reportCompare (0, str.search(/^\sfoo$/), + "Unicode non-breaking space character regexp test."); + + exitFunc ("test"); +} diff --git a/js/src/tests/ecma_3/Unicode/uc-003.js b/js/src/tests/ecma_3/Unicode/uc-003.js new file mode 100644 index 000000000..541cf36c6 --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/uc-003.js @@ -0,0 +1,30 @@ +/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +test(); + +function test() +{ + enterFunc ("test"); + + var \u0041 = 5; + var A\u03B2 = 15; + + printStatus ("Escapes in identifiers test."); + printBugNumber (23608); + printBugNumber (23607); + + reportCompare (5, eval("\u0041"), + "Escaped ASCII Identifier test."); + reportCompare (6, eval("++\u0041"), + "Escaped ASCII Identifier test"); + reportCompare (15, eval("A\u03B2"), + "Escaped non-ASCII Identifier test"); + reportCompare (16, eval("++A\u03B2"), + "Escaped non-ASCII Identifier test"); + + exitFunc ("test"); +} diff --git a/js/src/tests/ecma_3/Unicode/uc-004.js b/js/src/tests/ecma_3/Unicode/uc-004.js new file mode 100644 index 000000000..4c89a760e --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/uc-004.js @@ -0,0 +1,29 @@ +/* -*- tab-width: 8; indent-tabs-mode: nil; js-indent-level: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +test(); + +function test() +{ + enterFunc ("test"); + + printStatus ("Unicode Characters 1C-1F with regexps test."); + printBugNumber (23612); + + var ary = ["\u001Cfoo", "\u001Dfoo", "\u001Efoo", "\u001Ffoo"]; + + for (var i in ary) + { + reportCompare (0, ary[Number(i)].search(/^\Sfoo$/), + "Unicode characters 1C-1F in regexps, ary[" + + i + "] did not match \\S test (it should not.)"); + reportCompare (-1, ary[Number(i)].search(/^\sfoo$/), + "Unicode characters 1C-1F in regexps, ary[" + + i + "] matched \\s test (it should not.)"); + } + + exitFunc ("test"); +} diff --git a/js/src/tests/ecma_3/Unicode/uc-005.js b/js/src/tests/ecma_3/Unicode/uc-005.js new file mode 100644 index 000000000..4693d50cb --- /dev/null +++ b/js/src/tests/ecma_3/Unicode/uc-005.js @@ -0,0 +1,242 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 15 July 2002 + * SUMMARY: Testing identifiers with double-byte names + * See http://bugzilla.mozilla.org/show_bug.cgi?id=58274 + * + * Here is a sample of the problem: + * + * js> function f\u02B1 () {} + * + * js> f\u02B1.toSource(); + * function f¦() {} + * + * js> f\u02B1.toSource().toSource(); + * (new String("function f\xB1() {}")) + * + * + * See how the high-byte information (the 02) has been lost? + * The same thing was happening with the toString() method: + * + * js> f\u02B1.toString(); + * + * function f¦() { + * } + * + * js> f\u02B1.toString().toSource(); + * (new String("\nfunction f\xB1() {\n}\n")) + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 58274; +var summary = 'Testing identifiers with double-byte names'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +/* + * Define a function that uses double-byte identifiers in + * "every possible way" + * + * Then recover each double-byte identifier via f.toString(). + * To make this easier, put a 'Z' token before every one. + * + * Our eval string will be: + * + * sEval = "function Z\u02b1(Z\u02b2, b) { + * try { Z\u02b3 : var Z\u02b4 = Z\u02b1; } + * catch (Z\u02b5) { for (var Z\u02b6 in Z\u02b5) + * {for (1; 1<0; Z\u02b7++) {new Array()[Z\u02b6] = 1;} };} }"; + * + * It will be helpful to build this string in stages: + */ +var s0 = 'function Z'; +var s1 = '\u02b1(Z'; +var s2 = '\u02b2, b) {try { Z'; +var s3 = '\u02b3 : var Z'; +var s4 = '\u02b4 = Z'; +var s5 = '\u02b1; } catch (Z' + var s6 = '\u02b5) { for (var Z'; +var s7 = '\u02b6 in Z'; +var s8 = '\u02b5){for (1; 1<0; Z'; +var s9 = '\u02b7++) {new Array()[Z'; +var s10 = '\u02b6] = 1;} };} }'; + + +/* + * Concatenate these and eval() to create the function Z\u02b1 + */ +var sEval = s0 + s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10; +eval(sEval); + + +/* + * Recover all the double-byte identifiers via Z\u02b1.toString(). + * We'll recover the 1st one as arrID[1], the 2nd one as arrID[2], + * and so on ... + */ +var arrID = getIdentifiers(Z\u02b1); + + +/* + * Now check that we got back what we put in - + */ +status = inSection(1); +actual = arrID[1]; +expect = s1.charAt(0); +addThis(); + +status = inSection(2); +actual = arrID[2]; +expect = s2.charAt(0); +addThis(); + +status = inSection(3); +actual = arrID[3]; +expect = s3.charAt(0); +addThis(); + +status = inSection(4); +actual = arrID[4]; +expect = s4.charAt(0); +addThis(); + +status = inSection(5); +actual = arrID[5]; +expect = s5.charAt(0); +addThis(); + +status = inSection(6); +actual = arrID[6]; +expect = s6.charAt(0); +addThis(); + +status = inSection(7); +actual = arrID[7]; +expect = s7.charAt(0); +addThis(); + +status = inSection(8); +actual = arrID[8]; +expect = s8.charAt(0); +addThis(); + +status = inSection(9); +actual = arrID[9]; +expect = s9.charAt(0); +addThis(); + +status = inSection(10); +actual = arrID[10]; +expect = s10.charAt(0); +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +/* + * Goal: recover the double-byte identifiers from f.toString() + * by getting the very next character after each 'Z' token. + * + * The return value will be an array |arr| indexed such that + * |arr[1]| is the 1st identifier, |arr[2]| the 2nd, and so on. + * + * Note, however, f.toString() is implementation-independent. + * For example, it may begin with '\nfunction' instead of 'function'. + * + * Rhino uses a Unicode representation for f.toString(); whereas + * SpiderMonkey uses an ASCII representation, putting escape sequences + * for non-ASCII characters. For example, if a function is called f\u02B1, + * then in Rhino the toString() method will present a 2-character Unicode + * string for its name, whereas SpiderMonkey will present a 7-character + * ASCII string for its name: the string literal 'f\u02B1'. + * + * So we force the lexer to condense the string before we use it. + * This will give uniform results in Rhino and SpiderMonkey. + */ +function getIdentifiers(f) +{ + var str = condenseStr(f.toString()); + var arr = str.split('Z'); + + /* + * The identifiers are the 1st char of each split substring + * EXCEPT the first one, which is just ('\n' +) 'function '. + * + * Thus note the 1st identifier will be stored in |arr[1]|, + * the 2nd one in |arr[2]|, etc., making the indexing easy - + */ + for (i in arr) + arr[i] = arr[i].charAt(0); + return arr; +} + + +/* + * This function is the opposite of a functions like escape(), which take + * Unicode characters and return escape sequences for them. Here, we force + * the lexer to turn escape sequences back into single characters. + * + * Note we can't simply do |eval(str)|, since in practice |str| will be an + * identifier somewhere in the program (e.g. a function name); thus |eval(str)| + * would return the object that the identifier represents: not what we want. + * + * So we surround |str| lexicographically with quotes to force the lexer to + * evaluate it as a string. Have to strip out any linefeeds first, however - + */ +function condenseStr(str) +{ + /* + * You won't be able to do the next step if |str| has + * any carriage returns or linefeeds in it. For example: + * + * js> eval("'" + '\nHello' + "'"); + * 1: SyntaxError: unterminated string literal: + * 1: ' + * 1: ^ + * + * So replace them with the empty string - + */ + str = str.replace(/[\r\n]/g, '') + return eval("'" + str + "'") + } + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i?"; +var UntilRSBs = "[^]]*]([^]]+])*]+"; +var CDATA_CE = UntilRSBs + "([^]>]" + UntilRSBs + ")*>"; +var S = "[ \\n\\t\\r]+"; +var QuoteSE = '"[^"]' + "*" + '"' + "|'[^']*'"; +var DT_IdentSE = S + Name + "(" + S + "(" + Name + "|" + QuoteSE + "))*"; +var MarkupDeclCE = "([^]\"'><]+|" + QuoteSE + ")*>"; +var S1 = "[\\n\\r\\t ]"; +var UntilQMs = "[^?]*\\?+"; +var PI_Tail = "\\?>|" + S1 + UntilQMs + "([^>?]" + UntilQMs + ")*>"; +var DT_ItemSE = "<(!(--" + Until2Hyphens + ">|[^-]" + MarkupDeclCE + ")|\\?" + Name + "(" + PI_Tail + "))|%" + Name + ";|" + S; +var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*](" + S + ")?)?>?"; +var DeclCE = "--(" + CommentCE + ")?|\\[CDATA\\[(" + CDATA_CE + ")?|DOCTYPE(" + DocTypeCE + ")?"; +var PI_CE = Name + "(" + PI_Tail + ")?"; +var EndTagCE = Name + "(" + S + ")?>?"; +var AttValSE = '"[^<"]' + "*" + '"' + "|'[^<']*'"; +var ElemTagCE = Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>?"; +var MarkupSPE = "<(!(" + DeclCE + ")?|\\?(" + PI_CE + ")?|/(" + EndTagCE + ")?|(" + ElemTagCE + ")?)"; +var XML_SPE = TextSE + "|" + MarkupSPE; +var CommentRE = "