BC_ifnull.java revision 12651:6ef01bd40ce2
1251881Speter/*
2251881Speter * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
3251881Speter * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4251881Speter *
5251881Speter * This code is free software; you can redistribute it and/or modify it
6251881Speter * under the terms of the GNU General Public License version 2 only, as
7251881Speter * published by the Free Software Foundation.
8251881Speter *
9251881Speter * This code is distributed in the hope that it will be useful, but WITHOUT
10251881Speter * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11251881Speter * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12251881Speter * version 2 for more details (a copy is included in the LICENSE file that
13251881Speter * accompanied this code).
14251881Speter *
15251881Speter * You should have received a copy of the GNU General Public License version
16251881Speter * 2 along with this work; if not, write to the Free Software Foundation,
17251881Speter * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18251881Speter *
19251881Speter * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20251881Speter * or visit www.oracle.com if you need additional information or have any
21251881Speter * questions.
22251881Speter */
23251881Speterpackage org.graalvm.compiler.jtt.bytecode;
24251881Speter
25251881Speterimport org.junit.Test;
26251881Speter
27251881Speterimport org.graalvm.compiler.jtt.JTTTest;
28251881Speter
29251881Speter/*
30251881Speter */
31251881Speterpublic class BC_ifnull extends JTTTest {
32251881Speter
33251881Speter    public static int test(Object a) {
34251881Speter        int n = 0;
35251881Speter        if (a != null) {
36251881Speter            n += 1;
37251881Speter        } else {
38251881Speter            n -= 1;
39251881Speter        }
40251881Speter        if (a == null) {
41251881Speter            n -= 1;
42251881Speter        } else {
43251881Speter            n += 1;
44251881Speter        }
45251881Speter        return n;
46251881Speter    }
47251881Speter
48251881Speter    @Test
49251881Speter    public void run0() throws Throwable {
50251881Speter        runTest("test", (Object) null);
51251881Speter    }
52251881Speter
53251881Speter    @Test
54251881Speter    public void run1() throws Throwable {
55251881Speter        runTest("test", "");
56251881Speter    }
57251881Speter
58251881Speter}
59251881Speter