test/nashorn/script/basic/JDK-8023531.js
author hannesw
Mon, 23 Apr 2018 17:45:05 +0200
changeset 49855 3739e9a5b6b5
parent 47216 71c04702a3d5
permissions -rw-r--r--
8201466: Nashorn: defineProperty setters/getters on prototype object ignored with numeric property names Reviewed-by: sundar, jlaskey
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19621
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
     1
/*
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19621
diff changeset
     4
 *
19621
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19621
diff changeset
     8
 *
19621
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    13
 * accompanied this code).
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19621
diff changeset
    14
 *
19621
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19621
diff changeset
    18
 *
19621
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    21
 * questions.
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    22
 */
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    23
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    24
/**
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    25
 * JDK-8023531: new RegExp('').toString() should return '/(?:)/'
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    26
 *
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    27
 * @test
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    28
 * @run
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    29
 */
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    30
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    31
if (new RegExp("").toString() !== "/(?:)/") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    32
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    33
} else if (!(new RegExp("").test(""))) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    34
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    35
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    36
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    37
if (new RegExp("", "g").toString() !== "/(?:)/g") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    38
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    39
} else if (!(new RegExp("", "g").test(""))) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    40
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    41
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    42
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    43
if (new RegExp("", "i").toString() !== "/(?:)/i") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    44
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    45
} else if (!(new RegExp("", "i").test(""))) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    46
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    47
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    48
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    49
if (new RegExp("", "m").toString() !== "/(?:)/m") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    50
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    51
} else if (!(new RegExp("", "m").test(""))) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    52
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    53
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    54
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    55
if (RegExp("").toString() !== "/(?:)/") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    56
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    57
} else if (!RegExp("").test("")) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    58
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    59
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    60
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    61
if (RegExp("", "g").toString() !== "/(?:)/g") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    62
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    63
} else if (!RegExp("", "g").test("")) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    64
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    65
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    66
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    67
if (RegExp("", "i").toString() !== "/(?:)/i") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    68
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    69
} else if (!RegExp("", "i").test("")) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    70
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    71
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    72
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    73
if (RegExp("", "m").toString() !== "/(?:)/m") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    74
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    75
} else if (!RegExp("", "m").test("")) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    76
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    77
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    78
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    79
var re = /abc/;
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    80
re.compile("");
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    81
if (re.toString() !== "/(?:)/") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    82
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    83
} else if (!re.test("")) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    84
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    85
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    86
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    87
re.compile("", "g");
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    88
if (re.toString() !== "/(?:)/g") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    89
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    90
} else if (!re.test("")) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    91
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    92
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    93
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    94
re.compile("", "i");
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    95
if (re.toString() !== "/(?:)/i") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    96
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    97
} else if (!re.test("")) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    98
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
    99
}
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
   100
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
   101
re.compile("", "m");
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
   102
if (re.toString() !== "/(?:)/m") {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
   103
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
   104
} else if (!re.test("")) {
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
   105
    throw new Error();
1b2a79d8924c 8023531: new RegExp('').toString() should return '/(?:)/'
hannesw
parents:
diff changeset
   106
}