js/src/tests/ecma/LexicalConventions/7.7.4.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 File Name: 7.7.4.js
michael@0 9 ECMA Section: 7.7.4 String Literals
michael@0 10
michael@0 11 Description: A string literal is zero or more characters enclosed in
michael@0 12 single or double quotes. Each character may be
michael@0 13 represented by an escape sequence.
michael@0 14
michael@0 15
michael@0 16 Author: christine@netscape.com
michael@0 17 Date: 16 september 1997
michael@0 18 */
michael@0 19
michael@0 20 var SECTION = "7.7.4";
michael@0 21 var VERSION = "ECMA_1";
michael@0 22 startTest();
michael@0 23 var TITLE = "String Literals";
michael@0 24
michael@0 25 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 26
michael@0 27 // StringLiteral:: "" and ''
michael@0 28
michael@0 29 new TestCase( SECTION, "\"\"", "", "" );
michael@0 30 new TestCase( SECTION, "\'\'", "", '' );
michael@0 31
michael@0 32 // DoubleStringCharacters:: DoubleStringCharacter :: EscapeSequence :: CharacterEscapeSequence
michael@0 33 new TestCase( SECTION, "\\\"", String.fromCharCode(0x0022), "\"" );
michael@0 34 new TestCase( SECTION, "\\\'", String.fromCharCode(0x0027), "\'" );
michael@0 35 new TestCase( SECTION, "\\", String.fromCharCode(0x005C), "\\" );
michael@0 36 new TestCase( SECTION, "\\b", String.fromCharCode(0x0008), "\b" );
michael@0 37 new TestCase( SECTION, "\\f", String.fromCharCode(0x000C), "\f" );
michael@0 38 new TestCase( SECTION, "\\n", String.fromCharCode(0x000A), "\n" );
michael@0 39 new TestCase( SECTION, "\\r", String.fromCharCode(0x000D), "\r" );
michael@0 40 new TestCase( SECTION, "\\t", String.fromCharCode(0x0009), "\t" );
michael@0 41 new TestCase( SECTION, "\\v", String.fromCharCode(0x000B), "\v" );
michael@0 42
michael@0 43 // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::OctalEscapeSequence
michael@0 44
michael@0 45 new TestCase( SECTION, "\\00", String.fromCharCode(0x0000), "\00" );
michael@0 46 new TestCase( SECTION, "\\01", String.fromCharCode(0x0001), "\01" );
michael@0 47 new TestCase( SECTION, "\\02", String.fromCharCode(0x0002), "\02" );
michael@0 48 new TestCase( SECTION, "\\03", String.fromCharCode(0x0003), "\03" );
michael@0 49 new TestCase( SECTION, "\\04", String.fromCharCode(0x0004), "\04" );
michael@0 50 new TestCase( SECTION, "\\05", String.fromCharCode(0x0005), "\05" );
michael@0 51 new TestCase( SECTION, "\\06", String.fromCharCode(0x0006), "\06" );
michael@0 52 new TestCase( SECTION, "\\07", String.fromCharCode(0x0007), "\07" );
michael@0 53
michael@0 54 new TestCase( SECTION, "\\010", String.fromCharCode(0x0008), "\010" );
michael@0 55 new TestCase( SECTION, "\\011", String.fromCharCode(0x0009), "\011" );
michael@0 56 new TestCase( SECTION, "\\012", String.fromCharCode(0x000A), "\012" );
michael@0 57 new TestCase( SECTION, "\\013", String.fromCharCode(0x000B), "\013" );
michael@0 58 new TestCase( SECTION, "\\014", String.fromCharCode(0x000C), "\014" );
michael@0 59 new TestCase( SECTION, "\\015", String.fromCharCode(0x000D), "\015" );
michael@0 60 new TestCase( SECTION, "\\016", String.fromCharCode(0x000E), "\016" );
michael@0 61 new TestCase( SECTION, "\\017", String.fromCharCode(0x000F), "\017" );
michael@0 62 new TestCase( SECTION, "\\020", String.fromCharCode(0x0010), "\020" );
michael@0 63 new TestCase( SECTION, "\\042", String.fromCharCode(0x0022), "\042" );
michael@0 64
michael@0 65 new TestCase( SECTION, "\\0", String.fromCharCode(0x0000), "\0" );
michael@0 66 new TestCase( SECTION, "\\1", String.fromCharCode(0x0001), "\1" );
michael@0 67 new TestCase( SECTION, "\\2", String.fromCharCode(0x0002), "\2" );
michael@0 68 new TestCase( SECTION, "\\3", String.fromCharCode(0x0003), "\3" );
michael@0 69 new TestCase( SECTION, "\\4", String.fromCharCode(0x0004), "\4" );
michael@0 70 new TestCase( SECTION, "\\5", String.fromCharCode(0x0005), "\5" );
michael@0 71 new TestCase( SECTION, "\\6", String.fromCharCode(0x0006), "\6" );
michael@0 72 new TestCase( SECTION, "\\7", String.fromCharCode(0x0007), "\7" );
michael@0 73
michael@0 74 new TestCase( SECTION, "\\10", String.fromCharCode(0x0008), "\10" );
michael@0 75 new TestCase( SECTION, "\\11", String.fromCharCode(0x0009), "\11" );
michael@0 76 new TestCase( SECTION, "\\12", String.fromCharCode(0x000A), "\12" );
michael@0 77 new TestCase( SECTION, "\\13", String.fromCharCode(0x000B), "\13" );
michael@0 78 new TestCase( SECTION, "\\14", String.fromCharCode(0x000C), "\14" );
michael@0 79 new TestCase( SECTION, "\\15", String.fromCharCode(0x000D), "\15" );
michael@0 80 new TestCase( SECTION, "\\16", String.fromCharCode(0x000E), "\16" );
michael@0 81 new TestCase( SECTION, "\\17", String.fromCharCode(0x000F), "\17" );
michael@0 82 new TestCase( SECTION, "\\20", String.fromCharCode(0x0010), "\20" );
michael@0 83 new TestCase( SECTION, "\\42", String.fromCharCode(0x0022), "\42" );
michael@0 84
michael@0 85 new TestCase( SECTION, "\\000", String.fromCharCode(0), "\000" );
michael@0 86 new TestCase( SECTION, "\\111", String.fromCharCode(73), "\111" );
michael@0 87 new TestCase( SECTION, "\\222", String.fromCharCode(146), "\222" );
michael@0 88 new TestCase( SECTION, "\\333", String.fromCharCode(219), "\333" );
michael@0 89
michael@0 90 // following line commented out as it causes a compile time error
michael@0 91 // new TestCase( SECTION, "\\444", "444", "\444" );
michael@0 92
michael@0 93 // DoubleStringCharacters:DoubleStringCharacter::EscapeSequence::HexEscapeSequence
michael@0 94 new TestCase( SECTION, "\\xF0", String.fromCharCode(240), "\xF0" );
michael@0 95 new TestCase( SECTION, "\\xE1", String.fromCharCode(225), "\xE1" );
michael@0 96 new TestCase( SECTION, "\\xD2", String.fromCharCode(210), "\xD2" );
michael@0 97 new TestCase( SECTION, "\\xC3", String.fromCharCode(195), "\xC3" );
michael@0 98 new TestCase( SECTION, "\\xB4", String.fromCharCode(180), "\xB4" );
michael@0 99 new TestCase( SECTION, "\\xA5", String.fromCharCode(165), "\xA5" );
michael@0 100 new TestCase( SECTION, "\\x96", String.fromCharCode(150), "\x96" );
michael@0 101 new TestCase( SECTION, "\\x87", String.fromCharCode(135), "\x87" );
michael@0 102 new TestCase( SECTION, "\\x78", String.fromCharCode(120), "\x78" );
michael@0 103 new TestCase( SECTION, "\\x69", String.fromCharCode(105), "\x69" );
michael@0 104 new TestCase( SECTION, "\\x5A", String.fromCharCode(90), "\x5A" );
michael@0 105 new TestCase( SECTION, "\\x4B", String.fromCharCode(75), "\x4B" );
michael@0 106 new TestCase( SECTION, "\\x3C", String.fromCharCode(60), "\x3C" );
michael@0 107 new TestCase( SECTION, "\\x2D", String.fromCharCode(45), "\x2D" );
michael@0 108 new TestCase( SECTION, "\\x1E", String.fromCharCode(30), "\x1E" );
michael@0 109 new TestCase( SECTION, "\\x0F", String.fromCharCode(15), "\x0F" );
michael@0 110
michael@0 111 // string literals only take up to two hext digits. therefore, the third character in this string
michael@0 112 // should be interpreted as a StringCharacter and not part of the HextEscapeSequence
michael@0 113
michael@0 114 new TestCase( SECTION, "\\xF0F", String.fromCharCode(240)+"F", "\xF0F" );
michael@0 115 new TestCase( SECTION, "\\xE1E", String.fromCharCode(225)+"E", "\xE1E" );
michael@0 116 new TestCase( SECTION, "\\xD2D", String.fromCharCode(210)+"D", "\xD2D" );
michael@0 117 new TestCase( SECTION, "\\xC3C", String.fromCharCode(195)+"C", "\xC3C" );
michael@0 118 new TestCase( SECTION, "\\xB4B", String.fromCharCode(180)+"B", "\xB4B" );
michael@0 119 new TestCase( SECTION, "\\xA5A", String.fromCharCode(165)+"A", "\xA5A" );
michael@0 120 new TestCase( SECTION, "\\x969", String.fromCharCode(150)+"9", "\x969" );
michael@0 121 new TestCase( SECTION, "\\x878", String.fromCharCode(135)+"8", "\x878" );
michael@0 122 new TestCase( SECTION, "\\x787", String.fromCharCode(120)+"7", "\x787" );
michael@0 123 new TestCase( SECTION, "\\x696", String.fromCharCode(105)+"6", "\x696" );
michael@0 124 new TestCase( SECTION, "\\x5A5", String.fromCharCode(90)+"5", "\x5A5" );
michael@0 125 new TestCase( SECTION, "\\x4B4", String.fromCharCode(75)+"4", "\x4B4" );
michael@0 126 new TestCase( SECTION, "\\x3C3", String.fromCharCode(60)+"3", "\x3C3" );
michael@0 127 new TestCase( SECTION, "\\x2D2", String.fromCharCode(45)+"2", "\x2D2" );
michael@0 128 new TestCase( SECTION, "\\x1E1", String.fromCharCode(30)+"1", "\x1E1" );
michael@0 129 new TestCase( SECTION, "\\x0F0", String.fromCharCode(15)+"0", "\x0F0" );
michael@0 130
michael@0 131 // DoubleStringCharacter::EscapeSequence::CharacterEscapeSequence::\ NonEscapeCharacter
michael@0 132 new TestCase( SECTION, "\\a", "a", "\a" );
michael@0 133 new TestCase( SECTION, "\\c", "c", "\c" );
michael@0 134 new TestCase( SECTION, "\\d", "d", "\d" );
michael@0 135 new TestCase( SECTION, "\\e", "e", "\e" );
michael@0 136 new TestCase( SECTION, "\\g", "g", "\g" );
michael@0 137 new TestCase( SECTION, "\\h", "h", "\h" );
michael@0 138 new TestCase( SECTION, "\\i", "i", "\i" );
michael@0 139 new TestCase( SECTION, "\\j", "j", "\j" );
michael@0 140 new TestCase( SECTION, "\\k", "k", "\k" );
michael@0 141 new TestCase( SECTION, "\\l", "l", "\l" );
michael@0 142 new TestCase( SECTION, "\\m", "m", "\m" );
michael@0 143 new TestCase( SECTION, "\\o", "o", "\o" );
michael@0 144 new TestCase( SECTION, "\\p", "p", "\p" );
michael@0 145 new TestCase( SECTION, "\\q", "q", "\q" );
michael@0 146 new TestCase( SECTION, "\\s", "s", "\s" );
michael@0 147 new TestCase( SECTION, "\\w", "w", "\w" );
michael@0 148 new TestCase( SECTION, "\\y", "y", "\y" );
michael@0 149 new TestCase( SECTION, "\\z", "z", "\z" );
michael@0 150 new TestCase( SECTION, "\\9", "9", "\9" );
michael@0 151
michael@0 152 new TestCase( SECTION, "\\A", "A", "\A" );
michael@0 153 new TestCase( SECTION, "\\B", "B", "\B" );
michael@0 154 new TestCase( SECTION, "\\C", "C", "\C" );
michael@0 155 new TestCase( SECTION, "\\D", "D", "\D" );
michael@0 156 new TestCase( SECTION, "\\E", "E", "\E" );
michael@0 157 new TestCase( SECTION, "\\F", "F", "\F" );
michael@0 158 new TestCase( SECTION, "\\G", "G", "\G" );
michael@0 159 new TestCase( SECTION, "\\H", "H", "\H" );
michael@0 160 new TestCase( SECTION, "\\I", "I", "\I" );
michael@0 161 new TestCase( SECTION, "\\J", "J", "\J" );
michael@0 162 new TestCase( SECTION, "\\K", "K", "\K" );
michael@0 163 new TestCase( SECTION, "\\L", "L", "\L" );
michael@0 164 new TestCase( SECTION, "\\M", "M", "\M" );
michael@0 165 new TestCase( SECTION, "\\N", "N", "\N" );
michael@0 166 new TestCase( SECTION, "\\O", "O", "\O" );
michael@0 167 new TestCase( SECTION, "\\P", "P", "\P" );
michael@0 168 new TestCase( SECTION, "\\Q", "Q", "\Q" );
michael@0 169 new TestCase( SECTION, "\\R", "R", "\R" );
michael@0 170 new TestCase( SECTION, "\\S", "S", "\S" );
michael@0 171 new TestCase( SECTION, "\\T", "T", "\T" );
michael@0 172 new TestCase( SECTION, "\\U", "U", "\U" );
michael@0 173 new TestCase( SECTION, "\\V", "V", "\V" );
michael@0 174 new TestCase( SECTION, "\\W", "W", "\W" );
michael@0 175 new TestCase( SECTION, "\\X", "X", "\X" );
michael@0 176 new TestCase( SECTION, "\\Y", "Y", "\Y" );
michael@0 177 new TestCase( SECTION, "\\Z", "Z", "\Z" );
michael@0 178
michael@0 179 // DoubleStringCharacter::EscapeSequence::UnicodeEscapeSequence
michael@0 180
michael@0 181 new TestCase( SECTION, "\\u0020", " ", "\u0020" );
michael@0 182 new TestCase( SECTION, "\\u0021", "!", "\u0021" );
michael@0 183 new TestCase( SECTION, "\\u0022", "\"", "\u0022" );
michael@0 184 new TestCase( SECTION, "\\u0023", "#", "\u0023" );
michael@0 185 new TestCase( SECTION, "\\u0024", "$", "\u0024" );
michael@0 186 new TestCase( SECTION, "\\u0025", "%", "\u0025" );
michael@0 187 new TestCase( SECTION, "\\u0026", "&", "\u0026" );
michael@0 188 new TestCase( SECTION, "\\u0027", "'", "\u0027" );
michael@0 189 new TestCase( SECTION, "\\u0028", "(", "\u0028" );
michael@0 190 new TestCase( SECTION, "\\u0029", ")", "\u0029" );
michael@0 191 new TestCase( SECTION, "\\u002A", "*", "\u002A" );
michael@0 192 new TestCase( SECTION, "\\u002B", "+", "\u002B" );
michael@0 193 new TestCase( SECTION, "\\u002C", ",", "\u002C" );
michael@0 194 new TestCase( SECTION, "\\u002D", "-", "\u002D" );
michael@0 195 new TestCase( SECTION, "\\u002E", ".", "\u002E" );
michael@0 196 new TestCase( SECTION, "\\u002F", "/", "\u002F" );
michael@0 197 new TestCase( SECTION, "\\u0030", "0", "\u0030" );
michael@0 198 new TestCase( SECTION, "\\u0031", "1", "\u0031" );
michael@0 199 new TestCase( SECTION, "\\u0032", "2", "\u0032" );
michael@0 200 new TestCase( SECTION, "\\u0033", "3", "\u0033" );
michael@0 201 new TestCase( SECTION, "\\u0034", "4", "\u0034" );
michael@0 202 new TestCase( SECTION, "\\u0035", "5", "\u0035" );
michael@0 203 new TestCase( SECTION, "\\u0036", "6", "\u0036" );
michael@0 204 new TestCase( SECTION, "\\u0037", "7", "\u0037" );
michael@0 205 new TestCase( SECTION, "\\u0038", "8", "\u0038" );
michael@0 206 new TestCase( SECTION, "\\u0039", "9", "\u0039" );
michael@0 207
michael@0 208 test();

mercurial