• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright JS Foundation and other contributors, http://js.foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// check properties
16
17function length_configurable()
18{
19  function is_es51() {
20    return (typeof g === "function");
21    { function g() {} }
22  }
23  return is_es51() ? false : true;
24}
25
26assert(Object.getOwnPropertyDescriptor(String.prototype.concat, 'length').configurable === length_configurable());
27
28assert(Object.getOwnPropertyDescriptor(String.prototype.concat, 'length').enumerable === false);
29
30assert(Object.getOwnPropertyDescriptor(String.prototype.concat, 'length').writable === false);
31
32// simple checks
33var s1 = "Hello ";
34var s2 = "world!";
35var s3 = " ";
36assert(s1.concat(s2, s3, 3, 10, "  ", ".") === "Hello world! 310  .");
37assert("Hello ".concat(s1) === "Hello Hello ");
38
39assert(s1.concat(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9) === "Hello 012345678901234567890123456789");
40
41assert("".concat() === "");
42
43// check unicode
44assert("\u0041".concat("\u0041", "\u1041") === "\u0041\u0041\u1041");
45assert("\u0041\u1D306A".concat("\u0041", "\u1041") === "\u0041\u1D306A\u0041\u1041");
46
47// check undefined
48var y;
49assert("Check ".concat(y) === "Check undefined");
50
51// check toString error in this object
52var y = {};
53y.toString = function () { throw new ReferenceError ("foo");}
54y.concat = String.prototype.concat;
55try {
56  y.concat("cat");
57  assert(false);
58} catch (e) {
59  assert(e instanceof ReferenceError);
60}
61
62// check toString error in arguments
63var x = {};
64x.toString = function () { throw new ReferenceError ("foo");}
65try {
66  "a".concat(x);
67  assert(false);
68} catch (e) {
69  assert(e instanceof ReferenceError);
70}
71