aoqi@0: /* aoqi@0: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. attila@962: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. attila@962: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). attila@962: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. attila@962: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: /** aoqi@0: * NASHORN-592: test all combos of field types and getters and setters aoqi@0: * aoqi@0: * @test aoqi@0: * @run aoqi@0: */ aoqi@0: aoqi@0: //fortype undefined aoqi@0: var a; aoqi@0: aoqi@0: print(a & 0xff); aoqi@0: print(a >>> 1); aoqi@0: print(a * 2); aoqi@0: print(a + "hej!"); aoqi@0: aoqi@0: var b; aoqi@0: b = 17; //set undefined->int aoqi@0: aoqi@0: print(b & 0xff); aoqi@0: print(b >>> 1); aoqi@0: print(b * 2); aoqi@0: print(b + "hej!"); aoqi@0: aoqi@0: var c; aoqi@0: c = 17.4711 //set undefined->double aoqi@0: aoqi@0: print(c & 0xff); aoqi@0: print(c >>> 1); aoqi@0: print(c * 2); aoqi@0: print(c + "hej!"); aoqi@0: aoqi@0: var d; // set undefined->double aoqi@0: d = "Fame and fortune Salamander Yahoo!"; aoqi@0: aoqi@0: print(d & 0xff); aoqi@0: print(d >>> 1); aoqi@0: print(d * 2); aoqi@0: print(d + "hej!"); aoqi@0: aoqi@0: // now we have exhausted all getters and undefined->everything setters. aoqi@0: aoqi@0: aoqi@0: var e = 23; // int to everything setters, aoqi@0: e = 24; //int to int aoqi@0: print(e); aoqi@0: e = (22222 >>> 1); //int to long; aoqi@0: print(e); aoqi@0: e = 23.23; //int to double aoqi@0: print(e); aoqi@0: e = 23; //double to int - still double aoqi@0: print(e); aoqi@0: print(e & 0xff); aoqi@0: e = "Have some pie!" //double to string aoqi@0: print(e); aoqi@0: e = 4711.17; aoqi@0: print(e); //still an object not a double aoqi@0: aoqi@0: aoqi@0: var f = (23222 >>> 1); // long to everything setters, aoqi@0: f = 34344 >>> 1; //long to long aoqi@0: print(f); aoqi@0: f = 23; //long to int - still long aoqi@0: print(f); aoqi@0: f = 23.23; //long to double aoqi@0: print(f); aoqi@0: f = 23; //double to int - still double aoqi@0: print(f); aoqi@0: print(f & 0xff); aoqi@0: f = "Have some pie!" //double to string aoqi@0: print(f); aoqi@0: f = 4711.17; aoqi@0: print(f); //still an object not a double aoqi@0: aoqi@0: var g = 4811.16; aoqi@0: g = 23; //still double aoqi@0: print(g); aoqi@0: g = (222 >>> 1); //still double aoqi@0: print(g); aoqi@0: g = 4711.16; //double->double aoqi@0: print(g); aoqi@0: g = "I like cake!"; aoqi@0: print(g); //object to various aoqi@0: print(g & 0xff); aoqi@0: print(g * 2); aoqi@0: print(g >>> 2); aoqi@0: print(g); aoqi@0: aoqi@0: var h = {x:17, y:17.4711, z:"salamander"}; aoqi@0: print(h.x); aoqi@0: print(h.y); aoqi@0: print(h.z); aoqi@0: h.x = 4711.17; aoqi@0: h.y = "axolotl"; aoqi@0: h.z = "lizard"; aoqi@0: print(h.x); aoqi@0: print(h.y); aoqi@0: print(h.z);