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 */ 23 24 /** 25 * test arithmetic operations on boolean variables 26 * 27 * @test 28 * @run 29 */ 30 31 function printOp(text, value) { 32 print(text + value); 33 } 34 35 (function () { 36 var t = true; 37 var f = false; 38 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)) 44 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)) 50 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)) 56 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)) 62 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)) 68 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)) 74 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)) 80 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)) 86 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)) 92 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)) 98 99 print("~") 100 printOp("f: ", (~f)) 101 printOp("t: ", (~t)) 102 103 print("+") 104 printOp("f: ", (+f)) 105 printOp("t: ", (+t)) 106 107 print("-") 108 printOp("f: ", (-f)) 109 printOp("t: ", (-t)) 110 111 printOp("1/-f: ", (1/-f)) 112 113 })();