StarImportTest.java revision 961
553N/A * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 553N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary Basher for star-import scopes for (
int i =
0; i <
count; i++) {
* Select a random element from an array of choices. * Write a message to stderr. * Write a message to stderr, and dump a scope. * Write an error message to stderr. /** Class to encapsulate a test run. */ * Setup env by creating pseudo-random collection of names, packages and classes. * Set up a random number of names. log(
"setup: creating " +
count +
" new names");
for (
int i =
0; i <
count; i++) {
* Set up a package containing a random number of member elements. log(
"setup: creating package " +
name +
" with " +
count +
" entries");
for (
int i =
0; i <
count; i++) {
// log("setup: created " + c1); // log("setup: created " + c2); // log("package " + p, p.members_field); * Set up a class containing a random number of member elements. log(
"setup: creating class " +
name +
" with " +
count +
" entries");
// log("setup: created " + c); for (
int i =
0; i <
count; i++) {
// log("setup: created " + ic); * Create a star-import scope and a model therof, from the packages and * classes created by setupPackages and setupClasses. * @throws Exception for fatal errors, such as from reflection log (
"createStarImportScope");
// if StarImportScope exists, use it, otherwise, for testing legacy code, // fall back on ImportScope // log("importAll", members); // The following lines are taken from MemberEnter.importAll, // before the use of StarImportScope.importAll. // log("star-import scope", starImportScope); * The core of the test. In a random order, move nested classes from * the package in which they created to the class which should own them. // select a random nested class to move from package to class log(
"adjusting class " +
sym);
// remove from star import model // owner should be a package // log(sym + " owner: " + sym.owner, sym.owner.members()); // log("outer: " + outerName + " " + outer); // rename and insert into class error(
"no entries for " +
sym.
name +
" found in reference model");
// log(sym.name + "(" + sym + ") removed from reference model"); * Check the contents of a scope // First, check all entries in scope are in map log(
"Warning: " +
sym.
name +
":" +
sym +
" appears to be bogus");
error(
"check: no entries found for " +
sym.
name +
":" +
sym +
" in reference map");
error(
"check: symbol " +
sym.
name +
":" +
sym +
" not found in reference map");
log(
"Warning: " +
bogusCount +
" other bogus entries previously reported");
// Second, check all entries in map are in scope error(
"check: no entries found for " +
name +
" in scope");
error(
"check: symbol " +
sym +
" not found in scope");