test/script/basic/boolean_arithmetic.js

Mon, 03 Oct 2016 11:11:43 -0700

author
asaha
date
Mon, 03 Oct 2016 11:11:43 -0700
changeset 2002
31dad6c4e1be
parent 963
e2497b11a021
permissions
-rw-r--r--

Added tag jdk8u121-b03 for changeset 112c17eb13c7

     1 /*
     2  * Copyright (c) 2010, 2013, 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  */
    24 /**
    25  * test arithmetic operations on boolean variables
    26  *
    27  * @test
    28  * @run
    29  */
    31 function printOp(text, value) {
    32     print(text + value);
    33 }
    35 (function () {
    36 var t = true;
    37 var f = false;
    39 print("+")
    40 printOp("f, f: ", (f + f))
    41 printOp("f, t: ", (f + t))
    42 printOp("t, f: ", (t + f))
    43 printOp("t, t: ", (t + t))
    45 print("-")
    46 printOp("f, f: ", (f - f))
    47 printOp("f, t: ", (f - t))
    48 printOp("t, f: ", (t - f))
    49 printOp("t, t: ", (t - t))
    51 print("*")
    52 printOp("f, f: ", (f * f))
    53 printOp("f, t: ", (f * t))
    54 printOp("t, f: ", (t * f))
    55 printOp("t, t: ", (t * t))
    57 print("/")
    58 printOp("f, f: ", (f / f))
    59 printOp("f, t: ", (f / t))
    60 printOp("t, f: ", (t / f))
    61 printOp("t, t: ", (t / t))
    63 print("<<")
    64 printOp("f, f: ", (f << f))
    65 printOp("f, t: ", (f << t))
    66 printOp("t, f: ", (t << f))
    67 printOp("t, t: ", (t << t))
    69 print(">>")
    70 printOp("f, f: ", (f >> f))
    71 printOp("f, t: ", (f >> t))
    72 printOp("t, f: ", (t >> f))
    73 printOp("t, t: ", (t >> t))
    75 print(">>>")
    76 printOp("f, f: ", (f >>> f))
    77 printOp("f, t: ", (f >>> t))
    78 printOp("t, f: ", (t >>> f))
    79 printOp("t, t: ", (t >>> t))
    81 print("|")
    82 printOp("f, f: ", (f | f))
    83 printOp("f, t: ", (f | t))
    84 printOp("t, f: ", (t | f))
    85 printOp("t, t: ", (t | t))
    87 print("&")
    88 printOp("f, f: ", (f & f))
    89 printOp("f, t: ", (f & t))
    90 printOp("t, f: ", (t & f))
    91 printOp("t, t: ", (t & t))
    93 print("^")
    94 printOp("f, f: ", (f ^ f))
    95 printOp("f, t: ", (f ^ t))
    96 printOp("t, f: ", (t ^ f))
    97 printOp("t, t: ", (t ^ t))
    99 print("~")
   100 printOp("f: ", (~f))
   101 printOp("t: ", (~t))
   103 print("+")
   104 printOp("f: ", (+f))
   105 printOp("t: ", (+t))
   107 print("-")
   108 printOp("f: ", (-f))
   109 printOp("t: ", (-t))
   111 printOp("1/-f: ", (1/-f))
   113 })();

mercurial