jrose@267: #!/bin/sh jrose@267: jrose@267: # jrose@267: # Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. jrose@267: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jrose@267: # jrose@267: # This code is free software; you can redistribute it and/or modify it jrose@267: # under the terms of the GNU General Public License version 2 only, as jrose@267: # published by the Free Software Foundation. jrose@267: # jrose@267: # This code is distributed in the hope that it will be useful, but WITHOUT jrose@267: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jrose@267: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jrose@267: # version 2 for more details (a copy is included in the LICENSE file that jrose@267: # accompanied this code). jrose@267: # jrose@267: # You should have received a copy of the GNU General Public License version jrose@267: # 2 along with this work; if not, write to the Free Software Foundation, jrose@267: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jrose@267: # jrose@267: # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, jrose@267: # CA 95054 USA or visit www.sun.com if you need additional information or jrose@267: # have any questions. jrose@267: # jrose@267: jrose@267: # @test jrose@267: # @bug 6746458 jrose@267: # @summary Verify correct rejection of illegal quoted identifiers. jrose@267: # @run shell MakeNegTests.sh jrose@267: jrose@267: default_template=QuotedIdent.java jrose@267: # the rest of this file is a generic "//BAD"-line tester jrose@267: jrose@267: : ${TESTSRC=.} ${TESTCLASSES=.} jrose@267: javac="${TESTJAVA+${TESTJAVA}/bin/}javac" jrose@267: jrose@267: verbose=false quiet=false jrose@267: jrose@267: main() { jrose@267: case "${@-}" in jrose@267: *.java*) jrose@267: for template in "$@"; do jrose@267: expand_and_test "$template" jrose@267: done;; jrose@267: *) expand_and_test "${TESTSRC}/$default_template";; jrose@267: esac jrose@267: } jrose@267: jrose@267: expand_and_test() { jrose@267: template=$1 jrose@267: expand "$@" jrose@267: testneg "$@" jrose@267: } jrose@267: jrose@267: expand() { jrose@267: template=$1 jrose@267: badlines=` grep -n < "$template" '//BAD' ` jrose@267: badcount=` echo "$badlines" | wc -l ` jrose@267: [ $badcount -gt 0 ] || { echo "No negative test cases in $template"; exit 1; } jrose@267: $quiet || echo "Expanding $badcount negative test cases from $template:" jrose@267: $quiet || echo "$badlines" jrose@267: badnums=` echo "$badlines" | sed 's/:.*//' ` jrose@267: casestem=` getcasestem "$template" ` jrose@267: tclassname=` basename "$template" .java ` jrose@267: rm "$casestem"*.java jrose@267: for badnum in $badnums; do jrose@267: casefile="$casestem"${badnum}.java jrose@267: cclassname=` basename "$casefile" .java ` jrose@267: sed < "$template" > "$casefile" " jrose@267: s|@compile|@compile/fail| jrose@267: / @[a-z]/s|@|##| jrose@267: ${badnum}s:^ *[/*]*: : jrose@267: s/${tclassname}/${cclassname}/g jrose@267: " jrose@267: $verbose && diff -u "$template" "$casefile" jrose@267: done jrose@267: } jrose@267: jrose@267: getcasestem() { jrose@267: echo "$1" | sed 's/\.java$//;s/_BAD[0-9]*$//;s/$/_BAD/' jrose@267: } jrose@267: jrose@267: testneg() { jrose@267: template=$1 jrose@267: for casefile in ` getcasestem "$template" `*.java; do jrose@267: $quiet || echo -------- $javac "$casefile" jrose@267: $javac "$casefile" > "$casefile".errlog 2>&1 && { jrose@267: echo "*** Compilation unexpectedly succeeded: $casefile" jrose@267: exit 1 jrose@267: } jrose@267: $quiet || echo "Compilation failed as expected" jrose@267: $quiet || head ` $verbose || echo -3 ` < "$casefile".errlog jrose@267: rm "$casefile".errlog jrose@267: done jrose@267: } jrose@267: jrose@267: main "$@"