Слияние кода завершено, страница обновится автоматически
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function must_throw (str)
{
try
{
eval ("switch (1) { default: " + str + "}");
assert (false);
}
catch (e)
{
}
try
{
eval (str);
assert (false);
}
catch (e)
{
}
}
var a = 'A';
var b = 'B';
switch (1)
{
default:
``;
`abc`;
`ab${a+b}${ `x` }c`;
assert (`` === '');
assert (`abc` === 'abc');
assert (`ab\
c` === 'ab c');
assert (`ab
c` === 'ab\n c');
assert (`prefix${a}` === 'prefixA');
assert (`${a}postfix` === 'Apostfix');
assert (`prefix${a}postfix` === 'prefixApostfix');
assert (`${a}${b}` === 'AB');
assert (`${a},${b}` === 'A,B');
assert (`${a}${b}${a}${b}` === 'ABAB');
assert (`${a},${b},${a},${b}` === 'A,B,A,B');
assert (`$${a},${b},${a},${b}$` === '$A,B,A,B$');
assert (`\${}` === '${}');
assert (`$\{}` === '${}');
assert (`x${ `y` + `z` }x` === 'xyzx');
assert (`x${ `y` , `z` }x` === 'xzx');
function f(x) { return x + 1; }
/* Precedence. */
var c = 1;
assert (`x${ f(1) * f(2) }x${ c = 4 }` === 'x6x4');
assert (c === 4);
assert (`m${0 || 93}n${7 && 0}o` === 'm93n0o');
/* Result is always a string. */
assert (`${ function() { return true } () }` === 'true');
assert (`${ function() { return a.length } () }` === '1');
/* Result is a single string with its properties. */
assert(`${a}${b}${a}${b}`.length === 4);
}
must_throw ("`");
must_throw ("`${");
must_throw ("`${7");
must_throw ("`${}`");
must_throw ("`${1}");
must_throw ("`${1}.${");
must_throw ("`${1}.${2}");
// line break normalization
var cr = eval("`a" + String.fromCharCode(13) + "b`");
var lf = eval("`a" + String.fromCharCode(10) + "b`");
var crlf = eval("`a" + String.fromCharCode(13,10) + "b`");
assert(cr.length === 3);
assert(lf.length === 3);
assert(crlf.length === 3);
assert(cr[1] === lf[1]);
assert(lf[1] === crlf[1]);
assert(crlf[1] === '\n');
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарий ( 0 )