JDK-8062799.js revision 1571:fd97b9047199
187384Simp/*
287384Simp * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
387384Simp * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
487384Simp *
587384Simp * This code is free software; you can redistribute it and/or modify it
687384Simp * under the terms of the GNU General Public License version 2 only, as
787384Simp * published by the Free Software Foundation.
887384Simp *
987384Simp * This code is distributed in the hope that it will be useful, but WITHOUT
1087384Simp * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1187384Simp * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1287384Simp * version 2 for more details (a copy is included in the LICENSE file that
1387384Simp * accompanied this code).
1487384Simp *
1597748Sschweikh * You should have received a copy of the GNU General Public License version
1687384Simp * 2 along with this work; if not, write to the Free Software Foundation,
1787384Simp * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1887384Simp *
1987384Simp * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2087384Simp * or visit www.oracle.com if you need additional information or have any
2187384Simp * questions.
2287384Simp */
2387384Simp
2487384Simp/**
2587384Simp * JDK-8062799: Binary logical expressions can have numeric types
2687384Simp *
2787384Simp * @test
2887384Simp * @run
2987384Simp */
3087384Simp
3187384Simp(function() {
3287384Simp    var inspect = Java.type("jdk.nashorn.test.tools.StaticTypeInspector").inspect;
3387384Simp
3487384Simp    var b = true;
3587384Simp    var i = 1;
3687384Simp    var d = 2.1;
3787384Simp    var o = "foo";
3887384Simp
3987384Simp    print(inspect(b || b, "b || b"));
4087384Simp    print(inspect(b || i, "b || i"));
4187384Simp    print(inspect(b || d, "b || d"));
4287384Simp    print(inspect(b || o, "b || o"));
4387384Simp
4487384Simp    print(inspect(i || b, "i || b"));
4587384Simp    print(inspect(i || i, "i || i"));
46    print(inspect(i || d, "i || d"));
47    print(inspect(i || o, "i || o"));
48
49    print(inspect(d || b, "d || b"));
50    print(inspect(d || i, "d || i"));
51    print(inspect(d || d, "d || d"));
52    print(inspect(d || o, "d || o"));
53
54    print(inspect(o || b, "o || b"));
55    print(inspect(o || i, "o || i"));
56    print(inspect(o || d, "o || d"));
57    print(inspect(o || o, "o || o"));
58
59    print(inspect(b && b, "b && b"));
60    print(inspect(b && i, "b && i"));
61    print(inspect(b && d, "b && d"));
62    print(inspect(b && o, "b && o"));
63
64    print(inspect(i && b, "i && b"));
65    print(inspect(i && i, "i && i"));
66    print(inspect(i && d, "i && d"));
67    print(inspect(i && o, "i && o"));
68
69    print(inspect(d && b, "d && b"));
70    print(inspect(d && i, "d && i"));
71    print(inspect(d && d, "d && d"));
72    print(inspect(d && o, "d && o"));
73
74    print(inspect(o && b, "o && b"));
75    print(inspect(o && i, "o && i"));
76    print(inspect(o && d, "o && d"));
77    print(inspect(o && o, "o && o"));
78})();
79
80
81
82
83