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
16/* Create bound implicit class constructor */
17class myArray extends Array { };
18
19var array = new myArray (1);
20array.push (2);
21assert (array.length === 2);
22assert (array instanceof myArray);
23assert (array instanceof Array);
24assert (!([] instanceof myArray));
25
26/* Add a new element to the bound function chain */
27class mySecretArray extends myArray { };
28
29var secretArray = new mySecretArray (1, 2);
30secretArray.push (3);
31assert (secretArray.length === 3);
32assert (secretArray instanceof mySecretArray);
33assert (secretArray instanceof myArray);
34assert (secretArray instanceof Array);
35assert (!([] instanceof mySecretArray));
36
37/* Add a new element to the bound function chain */
38class myEpicSecretArray extends mySecretArray { };
39
40var epicSecretArray = new myEpicSecretArray (1, 2, 3);
41epicSecretArray.push (4);
42assert (epicSecretArray.length === 4);
43assert (epicSecretArray instanceof myEpicSecretArray);
44assert (epicSecretArray instanceof mySecretArray);
45assert (epicSecretArray instanceof myArray);
46assert (epicSecretArray instanceof Array);
47assert (!([] instanceof myEpicSecretArray));
48