1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * JDK-8062799: Binary logical expressions can have numeric types
  26  *
  27  * @test
  28  * @run
  29  */
  30 
  31 (function() {
  32     var inspect = Java.type("jdk.nashorn.test.tools.StaticTypeInspector").inspect;
  33     
  34     var b = true;
  35     var i = 1;
  36     var d = 2.1;
  37     var o = "foo";
  38 
  39     print(inspect(b || b, "b || b"));
  40     print(inspect(b || i, "b || i"));
  41     print(inspect(b || d, "b || d"));
  42     print(inspect(b || o, "b || o"));
  43         
  44     print(inspect(i || b, "i || b"));
  45     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