Mon, 07 Dec 2015 13:15:47 -0800
Merge
attila@963 | 1 | /* |
attila@963 | 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
attila@963 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
attila@963 | 4 | * |
attila@963 | 5 | * This code is free software; you can redistribute it and/or modify it |
attila@963 | 6 | * under the terms of the GNU General Public License version 2 only, as |
attila@963 | 7 | * published by the Free Software Foundation. |
attila@963 | 8 | * |
attila@963 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
attila@963 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
attila@963 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
attila@963 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
attila@963 | 13 | * accompanied this code). |
attila@963 | 14 | * |
attila@963 | 15 | * You should have received a copy of the GNU General Public License version |
attila@963 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
attila@963 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
attila@963 | 18 | * |
attila@963 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
attila@963 | 20 | * or visit www.oracle.com if you need additional information or have any |
attila@963 | 21 | * questions. |
attila@963 | 22 | */ |
attila@963 | 23 | |
attila@963 | 24 | /** |
attila@963 | 25 | * test arithmetic operations on boolean variables |
attila@963 | 26 | * |
attila@963 | 27 | * @test |
attila@963 | 28 | * @run |
attila@963 | 29 | */ |
attila@963 | 30 | |
attila@963 | 31 | function printOp(text, value) { |
attila@963 | 32 | print(text + value); |
attila@963 | 33 | } |
attila@963 | 34 | |
attila@963 | 35 | (function () { |
attila@963 | 36 | var t = true; |
attila@963 | 37 | var f = false; |
attila@963 | 38 | |
attila@963 | 39 | print("+") |
attila@963 | 40 | printOp("f, f: ", (f + f)) |
attila@963 | 41 | printOp("f, t: ", (f + t)) |
attila@963 | 42 | printOp("t, f: ", (t + f)) |
attila@963 | 43 | printOp("t, t: ", (t + t)) |
attila@963 | 44 | |
attila@963 | 45 | print("-") |
attila@963 | 46 | printOp("f, f: ", (f - f)) |
attila@963 | 47 | printOp("f, t: ", (f - t)) |
attila@963 | 48 | printOp("t, f: ", (t - f)) |
attila@963 | 49 | printOp("t, t: ", (t - t)) |
attila@963 | 50 | |
attila@963 | 51 | print("*") |
attila@963 | 52 | printOp("f, f: ", (f * f)) |
attila@963 | 53 | printOp("f, t: ", (f * t)) |
attila@963 | 54 | printOp("t, f: ", (t * f)) |
attila@963 | 55 | printOp("t, t: ", (t * t)) |
attila@963 | 56 | |
attila@963 | 57 | print("/") |
attila@963 | 58 | printOp("f, f: ", (f / f)) |
attila@963 | 59 | printOp("f, t: ", (f / t)) |
attila@963 | 60 | printOp("t, f: ", (t / f)) |
attila@963 | 61 | printOp("t, t: ", (t / t)) |
attila@963 | 62 | |
attila@963 | 63 | print("<<") |
attila@963 | 64 | printOp("f, f: ", (f << f)) |
attila@963 | 65 | printOp("f, t: ", (f << t)) |
attila@963 | 66 | printOp("t, f: ", (t << f)) |
attila@963 | 67 | printOp("t, t: ", (t << t)) |
attila@963 | 68 | |
attila@963 | 69 | print(">>") |
attila@963 | 70 | printOp("f, f: ", (f >> f)) |
attila@963 | 71 | printOp("f, t: ", (f >> t)) |
attila@963 | 72 | printOp("t, f: ", (t >> f)) |
attila@963 | 73 | printOp("t, t: ", (t >> t)) |
attila@963 | 74 | |
attila@963 | 75 | print(">>>") |
attila@963 | 76 | printOp("f, f: ", (f >>> f)) |
attila@963 | 77 | printOp("f, t: ", (f >>> t)) |
attila@963 | 78 | printOp("t, f: ", (t >>> f)) |
attila@963 | 79 | printOp("t, t: ", (t >>> t)) |
attila@963 | 80 | |
attila@963 | 81 | print("|") |
attila@963 | 82 | printOp("f, f: ", (f | f)) |
attila@963 | 83 | printOp("f, t: ", (f | t)) |
attila@963 | 84 | printOp("t, f: ", (t | f)) |
attila@963 | 85 | printOp("t, t: ", (t | t)) |
attila@963 | 86 | |
attila@963 | 87 | print("&") |
attila@963 | 88 | printOp("f, f: ", (f & f)) |
attila@963 | 89 | printOp("f, t: ", (f & t)) |
attila@963 | 90 | printOp("t, f: ", (t & f)) |
attila@963 | 91 | printOp("t, t: ", (t & t)) |
attila@963 | 92 | |
attila@963 | 93 | print("^") |
attila@963 | 94 | printOp("f, f: ", (f ^ f)) |
attila@963 | 95 | printOp("f, t: ", (f ^ t)) |
attila@963 | 96 | printOp("t, f: ", (t ^ f)) |
attila@963 | 97 | printOp("t, t: ", (t ^ t)) |
attila@963 | 98 | |
attila@963 | 99 | print("~") |
attila@963 | 100 | printOp("f: ", (~f)) |
attila@963 | 101 | printOp("t: ", (~t)) |
attila@963 | 102 | |
attila@963 | 103 | print("+") |
attila@963 | 104 | printOp("f: ", (+f)) |
attila@963 | 105 | printOp("t: ", (+t)) |
attila@963 | 106 | |
attila@963 | 107 | print("-") |
attila@963 | 108 | printOp("f: ", (-f)) |
attila@963 | 109 | printOp("t: ", (-t)) |
attila@963 | 110 | |
attila@963 | 111 | printOp("1/-f: ", (1/-f)) |
attila@963 | 112 | |
attila@963 | 113 | })(); |