T6366196.java revision 553
407N/A/*
407N/A * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
1356N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
407N/A *
1549N/A * This code is free software; you can redistribute it and/or modify it
407N/A * under the terms of the GNU General Public License version 2 only, as
407N/A * published by the Free Software Foundation.
919N/A *
919N/A * This code is distributed in the hope that it will be useful, but WITHOUT
919N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
919N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
919N/A * version 2 for more details (a copy is included in the LICENSE file that
919N/A * accompanied this code).
919N/A *
919N/A * You should have received a copy of the GNU General Public License version
919N/A * 2 along with this work; if not, write to the Free Software Foundation,
919N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
919N/A *
919N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
919N/A * or visit www.oracle.com if you need additional information or have any
919N/A * questions.
919N/A */
919N/A
919N/A/*
407N/A * @test
407N/A * @bug 6359661 6366196
407N/A * @summary Unit test for corner cases of position encoding
407N/A * @author Wei Tao
493N/A * @run main T6366196
407N/A */
407N/A
1549N/Aimport com.sun.tools.javac.util.*;
407N/A
911N/Apublic class T6366196 {
1549N/A public static final int MIDLINE = Position.MAXPOS>>>Position.LINESHIFT; // 0x00200000
1549N/A
1549N/A public static void main(String[] args) {
911N/A positiveTest(10, Position.MAXCOLUMN);
407N/A negativeTest(20, Position.MAXCOLUMN + 1);
414N/A positiveTest(MIDLINE, Position.MAXCOLUMN);
407N/A positiveTest(Position.MAXLINE, 40);
1356N/A negativeTest(Position.MAXLINE, Position.MAXCOLUMN);
1356N/A negativeTest(Position.MAXLINE + 1, 1);
1356N/A }
970N/A
970N/A public static void positiveTest(int line, int col) {
970N/A if (Position.encodePosition(line, col) == Position.NOPOS) {
970N/A throw new Error("test failed at line = " + line + ", column = " + col);
970N/A } else {
970N/A System.out.println("test passed at line = " + line + ", column = " + col);
970N/A }
1549N/A }
1549N/A
970N/A public static void negativeTest(int line, int col) {
407N/A if (Position.encodePosition(line, col) != Position.NOPOS) {
1549N/A throw new Error("test failed at line = " + line + ", column = " + col);
493N/A } else {
407N/A System.out.println("test passed at line = " + line + ", column = " + col);
851N/A }
851N/A }
851N/A}
1425N/A