Thu, 12 Oct 2017 19:52:15 +0800
merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
attila@962 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
attila@962 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
attila@962 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
attila@962 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | */ |
aoqi@0 | 23 | |
aoqi@0 | 24 | /** |
aoqi@0 | 25 | * NASHORN-592: test all combos of field types and getters and setters |
aoqi@0 | 26 | * |
aoqi@0 | 27 | * @test |
aoqi@0 | 28 | * @run |
aoqi@0 | 29 | */ |
aoqi@0 | 30 | |
aoqi@0 | 31 | //fortype undefined |
aoqi@0 | 32 | var a; |
aoqi@0 | 33 | |
aoqi@0 | 34 | print(a & 0xff); |
aoqi@0 | 35 | print(a >>> 1); |
aoqi@0 | 36 | print(a * 2); |
aoqi@0 | 37 | print(a + "hej!"); |
aoqi@0 | 38 | |
aoqi@0 | 39 | var b; |
aoqi@0 | 40 | b = 17; //set undefined->int |
aoqi@0 | 41 | |
aoqi@0 | 42 | print(b & 0xff); |
aoqi@0 | 43 | print(b >>> 1); |
aoqi@0 | 44 | print(b * 2); |
aoqi@0 | 45 | print(b + "hej!"); |
aoqi@0 | 46 | |
aoqi@0 | 47 | var c; |
aoqi@0 | 48 | c = 17.4711 //set undefined->double |
aoqi@0 | 49 | |
aoqi@0 | 50 | print(c & 0xff); |
aoqi@0 | 51 | print(c >>> 1); |
aoqi@0 | 52 | print(c * 2); |
aoqi@0 | 53 | print(c + "hej!"); |
aoqi@0 | 54 | |
aoqi@0 | 55 | var d; // set undefined->double |
aoqi@0 | 56 | d = "Fame and fortune Salamander Yahoo!"; |
aoqi@0 | 57 | |
aoqi@0 | 58 | print(d & 0xff); |
aoqi@0 | 59 | print(d >>> 1); |
aoqi@0 | 60 | print(d * 2); |
aoqi@0 | 61 | print(d + "hej!"); |
aoqi@0 | 62 | |
aoqi@0 | 63 | // now we have exhausted all getters and undefined->everything setters. |
aoqi@0 | 64 | |
aoqi@0 | 65 | |
aoqi@0 | 66 | var e = 23; // int to everything setters, |
aoqi@0 | 67 | e = 24; //int to int |
aoqi@0 | 68 | print(e); |
aoqi@0 | 69 | e = (22222 >>> 1); //int to long; |
aoqi@0 | 70 | print(e); |
aoqi@0 | 71 | e = 23.23; //int to double |
aoqi@0 | 72 | print(e); |
aoqi@0 | 73 | e = 23; //double to int - still double |
aoqi@0 | 74 | print(e); |
aoqi@0 | 75 | print(e & 0xff); |
aoqi@0 | 76 | e = "Have some pie!" //double to string |
aoqi@0 | 77 | print(e); |
aoqi@0 | 78 | e = 4711.17; |
aoqi@0 | 79 | print(e); //still an object not a double |
aoqi@0 | 80 | |
aoqi@0 | 81 | |
aoqi@0 | 82 | var f = (23222 >>> 1); // long to everything setters, |
aoqi@0 | 83 | f = 34344 >>> 1; //long to long |
aoqi@0 | 84 | print(f); |
aoqi@0 | 85 | f = 23; //long to int - still long |
aoqi@0 | 86 | print(f); |
aoqi@0 | 87 | f = 23.23; //long to double |
aoqi@0 | 88 | print(f); |
aoqi@0 | 89 | f = 23; //double to int - still double |
aoqi@0 | 90 | print(f); |
aoqi@0 | 91 | print(f & 0xff); |
aoqi@0 | 92 | f = "Have some pie!" //double to string |
aoqi@0 | 93 | print(f); |
aoqi@0 | 94 | f = 4711.17; |
aoqi@0 | 95 | print(f); //still an object not a double |
aoqi@0 | 96 | |
aoqi@0 | 97 | var g = 4811.16; |
aoqi@0 | 98 | g = 23; //still double |
aoqi@0 | 99 | print(g); |
aoqi@0 | 100 | g = (222 >>> 1); //still double |
aoqi@0 | 101 | print(g); |
aoqi@0 | 102 | g = 4711.16; //double->double |
aoqi@0 | 103 | print(g); |
aoqi@0 | 104 | g = "I like cake!"; |
aoqi@0 | 105 | print(g); //object to various |
aoqi@0 | 106 | print(g & 0xff); |
aoqi@0 | 107 | print(g * 2); |
aoqi@0 | 108 | print(g >>> 2); |
aoqi@0 | 109 | print(g); |
aoqi@0 | 110 | |
aoqi@0 | 111 | var h = {x:17, y:17.4711, z:"salamander"}; |
aoqi@0 | 112 | print(h.x); |
aoqi@0 | 113 | print(h.y); |
aoqi@0 | 114 | print(h.z); |
aoqi@0 | 115 | h.x = 4711.17; |
aoqi@0 | 116 | h.y = "axolotl"; |
aoqi@0 | 117 | h.z = "lizard"; |
aoqi@0 | 118 | print(h.x); |
aoqi@0 | 119 | print(h.y); |
aoqi@0 | 120 | print(h.z); |