instanceof.js revision 6:5a1b0714df0e
1893Salanb/* 23261Sohair * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3893Salanb * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4893Salanb * 5893Salanb * This code is free software; you can redistribute it and/or modify it 6893Salanb * under the terms of the GNU General Public License version 2 only, as 7893Salanb * published by the Free Software Foundation. 8893Salanb * 9893Salanb * This code is distributed in the hope that it will be useful, but WITHOUT 10893Salanb * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11893Salanb * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12893Salanb * version 2 for more details (a copy is included in the LICENSE file that 13893Salanb * accompanied this code). 14893Salanb * 15893Salanb * You should have received a copy of the GNU General Public License version 16893Salanb * 2 along with this work; if not, write to the Free Software Foundation, 17893Salanb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18893Salanb * 192362Sohair * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 202362Sohair * or visit www.oracle.com if you need additional information or have any 212362Sohair * questions. 22893Salanb */ 23893Salanb 24893Salanb/** 25893Salanb * Verify instanceof operator. 26893Salanb * 27893Salanb * @test 2811822Sdarcy * @run 29893Salanb */ 30893Salanb 31893Salanbvar b = new Boolean(true); 32893Salanbvar s = new String("hello"); 33893Salanbvar r = /java/; 34893Salanb 35893Salanbfunction MyConstructor(fooval) { 36893Salanb this.foo = fooval; 37893Salanb} 38893Salanb 39893Salanbvar c = new MyConstructor("world"); 40893Salanb 41893Salanbprint(b instanceof Boolean); 42893Salanbprint(b instanceof String); 43893Salanbprint(b instanceof RegExp); 44893Salanbprint(b instanceof MyConstructor); 45893Salanbprint("------"); 46893Salanb 47893Salanbprint(s instanceof Boolean); 48893Salanbprint(s instanceof String); 49893Salanbprint(s instanceof RegExp); 50893Salanbprint(s instanceof MyConstructor); 51893Salanbprint("------"); 52893Salanb 53893Salanbprint(r instanceof Boolean); 54893Salanbprint(r instanceof String); 55893Salanbprint(r instanceof RegExp); 56893Salanbprint(r instanceof MyConstructor); 57893Salanbprint("------"); 58893Salanb 59893Salanbprint(c instanceof Boolean); 60893Salanbprint(c instanceof String); 61893Salanbprint(c instanceof RegExp); 62893Salanbprint(c instanceof MyConstructor); 63893Salanbprint("------"); 64893Salanb 652546Salanbvar b = new Boolean(true); 662546Salanbprint(b instanceof Boolean); 672546Salanb